I created a kind of "polygon selector" or "polygon maker" using fabric.js. Each click creates a polygon corner that can be selected, moved, etc. .... double-clicking on the starting point “closes” the polygon. At this moment, I take all the circles / lines that make up the polygons and group them. So far so good.
If such a group is pressed twice, I would like it to ungroup and return to the moving nodes (i.e. moving the circles changed the polygon, etc.); but some kind of weird thing happens - check what happens when you move the circles, some lines seem to be “not connected” to the circles ...
I have already covered every fabric.js theme related to / ungroup (here / there / everywhere). It seems that not one of them covers the type of “related” objects that I have.
The script I put together to show the problem says it is better than I can: http://jsfiddle.net/bhilleli/4v8mkw6q/
Broken code bit: @:
items = p._objects;
p._restoreObjectsState();
canvas.remove(p);
for (var i = items.length - 1; i >= 0; i--) {
canvas.add(items[i]);
}
canvas.renderAll();
source
share