react-konva
react-konva copied to clipboard
Cancel dragging shape
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
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);
}}