0

I want to create a "select and group" functionality for my KonvaJS application.

For the select functionality, I'm using this example that works well: selecting by drawing a box around objects in konva

But the group function is not working as I expect. This is what's happening:

Example

First I create an empty group like this:

selectGroup = new Konva.Group({
    x: 50,
    y: 50,
    draggable: true
});

When a shape is hit I add it like this:

selectGroup.add(shapeObject);

And when I finish the selection I call the Transform functionality like this:

var tr = new Konva.Transformer();
layer.add(tr);
tr.attachTo(selectGroup);
layer.draw();

I don't why when I add a shape it disappears. And when I finish and I call the transform functionality it doesn't seem to be working.

Any ideas?

Community
  • 1
  • 1
  • Can you make a small demo? Probably when you add shape into the group its absolute is getting out of visible view. – lavrton Oct 22 '18 at 15:45
  • Sure @lavrton. Here's a demo: https://jsbin.com/pubovu/edit?html,js,output – Santiago Pitluk Oct 22 '18 at 20:07
  • Did you add `selectGroup` to the layer? Looks like it is not on the layer, so you don't see the shapes. – lavrton Oct 23 '18 at 03:24
  • Thanks lavrton. That was the problem. Now is working fine. I can't drag the group, but that's another story. I'll continue investigating. Thanks again for this amazing framework! – Santiago Pitluk Oct 26 '18 at 04:03

1 Answers1

0

Thanks to lavrton I saw that the problem was that I didn't add the selectGroup to the layer.

Right now is working fine. Problem fixed.