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

adding to group doesn't obey originX/Y #3837

Closed
dmccuskey opened this issue Apr 9, 2017 · 1 comment
Closed

adding to group doesn't obey originX/Y #3837

dmccuskey opened this issue Apr 9, 2017 · 1 comment

Comments

@dmccuskey
Copy link

dmccuskey commented Apr 9, 2017

Version

1.7.7 (jsfiddle), 1.7.9 (my project, npm install)

Test Case

https://jsfiddle.net/dmccuskey/0L9e32hx/

Steps to reproduce

see fiddle

Expected Behavior

i expect both canvases to look the same - both rectangles added to group should be group-origin aligned to Top / Left.

Actual Behavior

when using group.add(), inserted objects are not aligned with the container's originX/Y values. they are instead added at 'center', 'center'.

ps, this could be along the same vein as this bug report (ie, added objects aren't being correctly positioned) : #2073

the issue is also mentioned in this stack overflow: http://stackoverflow.com/questions/27358708/how-does-fabric-group-positioning-work
"i am not too sure why I have to subtract half of group width and height from group's left and top."

with originX/Y as Top/Left, you shouldn't have to subtract half of width/height to get the proper behavior.

note, that the correct behavior IS observed if the objects are added in the group constructor. in most of the live examples for the project, objects are only added to group via the constructor, never via group.add() after the group has been created. http://fabricjs.com/test/misc/grouporigin.html

@dmccuskey dmccuskey changed the title adding to group doesn't adding to group doesn't obey originX/Y Apr 9, 2017
@asturur
Copy link
Member

asturur commented Apr 9, 2017

https://jsfiddle.net/0L9e32hx/5/

Using addWithUpdate is better.
Add is just wrong in my opinion and should be removed.

Either create a group with the objects already passed as argument ( best ) of the app does not allow for this, just use addWithUpdate This will recalculate the group size every time, but gives better result.

Using the collection concept for both canvas and group, and sharing the add method has been a decision made when groups where created that now does not fit most of the group requirements.

@asturur asturur closed this as completed Apr 9, 2017
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

No branches or pull requests

2 participants