Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obj.getBoundingRect returns old value after modifing selection #4540

Closed
nag5000 opened this issue Dec 7, 2017 · 3 comments
Closed

obj.getBoundingRect returns old value after modifing selection #4540

nag5000 opened this issue Dec 7, 2017 · 3 comments

Comments

@nag5000
Copy link

nag5000 commented Dec 7, 2017

Version

Tested on 1.7.20, 2.0.0-rc.3

Test Case

http://jsfiddle.net/w1uk1r8j/

Steps to reproduce

  1. Add 3 rectangles to canvas.
  2. var A = canvas.getObjects().map(o => o.getBoundingRect(true, true));
  3. Select 3 rectangles.
  4. Resize selection.
  5. var B = canvas.getObjects().map(o => o.getBoundingRect(true, true));

Expected Behavior

B differs from A.

Actual Behavior

B[i].width === A[i].width; B[i].height === A[i].height

If it is not a bug, how can I get new bounding rects?

@blobinabottle
Copy link
Contributor

For what I understand it's the logic of fabric: activeSelection apply its transform only when you deselect. That's the same for a group, you'll only apply transforms to child of a group when ungrouping.

You need to apply the transform of the activeSelection itself to the objects into the selection. objRects.map(o => o.width * sel.scaleX)

@asturur
Copy link
Member

asturur commented Dec 9, 2017

So activeSelection is just a facade to be able the code of a single object to move around multiple objects without going crazy with code changes.

Is also comfortable because the activeSelection transform is going to transform the canvas and give us the illusion of transforming the objects.

There is no a method to calculate the bbrect outside of a group of an activeSelection, i think we should just make it.

Now going to naming, as always, that is not easy.

We are using the word absolute for getting a bbrect that represent the bbrect in canvas coordinate when the zoom and padding are neutral, and skipping the control padding.
This in opposition to the old bbrect that was just based on control ( and maybe should have been removed before 2.0 transition )

using a third boolean looks terrible to me, any other idea?

@ShaMan123
Copy link
Contributor

http://jsfiddle.net/2wnx60za/1/
Seems fixed by #7669

@ShaMan123 ShaMan123 linked a pull request Mar 8, 2022 that will close this issue
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants