Merge pull request #681 from paulocfjunior/fix-drag-canvas-state

Fix DragCanvasState to stop handling events after mouse is released
This commit is contained in:
Dylan Vorster
2020-08-01 16:23:12 +02:00
committed by GitHub

View File

@@ -35,6 +35,15 @@ export abstract class AbstractDisplacementState<E extends CanvasEngine = CanvasE
type: InputType.MOUSE_MOVE,
fire: (actionEvent: ActionEvent<React.MouseEvent>) => {
const { event } = actionEvent;
if (event.buttons === 0) {
// If buttons is 0, it means the mouse is not down, the user may have released it
// outside of the canvas, then we eject the state
this.eject();
return;
}
this.fireMouseMoved({
displacementX: event.clientX - this.initialX,
displacementY: event.clientY - this.initialY,