0

I have "Transformer" and several closed "Line". For the Line onDragMove I got a function defined that manually changes the x and y of the Line. The function first get the matrix, then resets the Line x and y to its old state, which is saved in a useState, and finally sets the new x and y to the useState with the given matrix.

The Problem: If I select two "Line" by adding them to the "Transformer" nodes and starting to drag Line 1, then the onDragMove function of Line 1 gets called one extra times at the beginning. I gave both Lines an ID and logged it out on call of the onDragMove function.

The Problem with that behavior is that now Line 1 got dragged a little more than Line 2.

Thank you for your help !

ps: I added a sandbox to better understand the problem.

Jurek O.
  • 9
  • 4
  • Check your code and assumptions - this won't be a bug in Konva. – Vanquished Wombat Apr 28 '23 at 13:42
  • Hey @VanquishedWombat, i made a [sandbox](https://codesandbox.io/s/delicate-sound-46305c?file=/src/App.js) to better understand the problem. If you select both rects and move them you will see in the console that ondragmove was called two times for the rect you clicked on. – Jurek O. Apr 28 '23 at 16:20
  • If anyone comes by and has the same problem. For me, after checking my code and assumptions, it looks like the drag of the rect fires first and only after that the Transformer starts to take over and control the drag but I could not find a fix for that. – Jurek O. May 08 '23 at 15:31
  • In your onDrag listener for the rect, check if the rect is in the transformer nodes list and break out of it if true. – Vanquished Wombat May 09 '23 at 09:24
  • Hey @VanquishedWombat, I implemented your idea but there is a problem with that solution. I defined a drag behavior for the rect and might as well define a different one for a triangle or something else. I would like to define that drag behavior at the component of (Rect, Triangle,...) because otherwise I have to check for every nodes type (rect, triangle, ... ) and define all the different drag behaviors at the onDragMove of the Transformer. But still thank you very much for the help. – Jurek O. May 09 '23 at 13:04

0 Answers0