react-konva icon indicating copy to clipboard operation
react-konva copied to clipboard

Cancel dragging shape

Open maxaug999 opened this issue 1 year ago • 1 comments

With Konva for React, I am trying to cancel the dragging shape back to the position it was first clicked at (when it enters collision with another shape). I was wondering if there was a method (or event maybe?) for onDragEnd() specially

e.cancelBubble = true; does not work for me

maxaug999 avatar Jul 28 '22 04:07 maxaug999

There are many ways. They may change depending on how you track position of a node into state.

The simplest is manual position set:

onDragStart={(e) => {
  setInitialPosition(e.target.position());
}}
onDragEnd={(e) => {
  e.target.position(initialPosition);
}}

lavrton avatar Jul 30 '22 04:07 lavrton