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

Add object to nested group #6738

Closed
jameszhong2008 opened this issue Dec 19, 2020 · 6 comments · Fixed by #6774
Closed

Add object to nested group #6738

jameszhong2008 opened this issue Dec 19, 2020 · 6 comments · Fixed by #6774
Labels

Comments

@jameszhong2008
Copy link

jameszhong2008 commented Dec 19, 2020

Hi, I use fabric's group recently, I understand when you want to add object to group and update it, you can use addWithUpdate, it works great when when the group is just under canvas.
like that: canvas->group works

but when the group(group1) is under another group, it doesn't work anymore, group and it's object's position will be wrong after use addWithUpdate
canvas->group->group1 does not work

check it here
https://jsfiddle.net/zhongjian2008/0re3hjyp/16/

Now i find a workaround it before add object to group in other group, ungroup it first, then group them back. but when there is many group, in deep structure, it makes things complex.

This issue is relate use ActiveSelection to group multi objects that already under a group or deep group.
canvas->group->group01(node1, node2)
->group1->group02(node3, node4)
var sel = new fabric.ActiveSelection([node1, node3]); // does not work
canvas.setActiveObject(sel);
canvas.requestRenderAll();

Is there any other solution? thanks a lot.

@andrewzolotukhin
Copy link

Actually does Fabric already has a support of nested groups?

@asturur
Copy link
Member

asturur commented Dec 19, 2020

yes nested groups are ok.
Did you try updating the innergroup first and then the outer group? You can call addWithUpdate() without addind anything

@jameszhong2008
Copy link
Author

jameszhong2008 commented Dec 20, 2020

@asturur thank you for quick response, I use addWithUpdate(rect6), and call addWithUpdate() on the outer group. it still doesn't work. (nested group's position change incorrectly), am i doing it wrong, could you please check it here.

click AddNode Error and check it.
https://jsfiddle.net/zhongjian2008/0re3hjyp/37/

Thanks a lot!

@jameszhong2008 jameszhong2008 changed the title Add object to deep group Add object to nested group Dec 23, 2020
@asturur
Copy link
Member

asturur commented Jan 2, 2021

Ok this is definitely broken i need to fix it.
I would expect something like that to work

@asturur asturur added the bug label Jan 2, 2021
@asturur
Copy link
Member

asturur commented Jan 2, 2021

This is way more complicated than i expected

i can get it to work from this
image

to this
image

Meaning that i m quite right, but usually those things are completely broken or perfect, and this quite right means that fixing it will be a pain of understanding.

@asturur
Copy link
Member

asturur commented Jan 31, 2021

I repopend my PR for this, i need a moment to recap what i did, and we can fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants