konvajs / react-konva

React + Canvas = Love. JavaScript library for drawing complex canvas graphics using React.
https://konvajs.github.io/docs/react/
MIT License
5.8k stars 260 forks source link

Cannot drag the group if I do not drag the elements inside it #804

Closed Jihed-Yahyaoui closed 6 months ago

Jihed-Yahyaoui commented 6 months ago

I am trying to drag a group containing a couple of elements. however, I cannot drag the group if I do not drag the elements inside it. I want to drag the group by clicking anywhere inside it.

This is the actual behavior of my code

This is the behavior I want to achieve

This is a minimal reproducible example of my code

This may not be an "issue" per se, since groups and transformers probably do not perform that way at all, but I am desperately trying to find a way to do this. I tried to add an invisible rectangle to the group and give it the same size and coords of the group to capture any drag events but did not work. I checked for the setPointerCapture() and hitFunc props but apparently the Group component does not have them. Please tell me if there is a solution or if I should refactor my code and use smth else entirely.

Jihed-Yahyaoui commented 6 months ago

Nevermind, I have found that I can drag a child declaratively using Konva.Node.startDrag(). I still want to drag multiple elements selected with a transformer, but find this method is a big step to solving that problem.