From f10f65c625d30eeb2572eddbf9e7865644a607b6 Mon Sep 17 00:00:00 2001 From: joni <johnfshaughnessy@gmail.com> Date: Wed, 6 Jun 2018 16:19:40 -0700 Subject: [PATCH] Fix case where primary up ends grab action. --- src/utils/action-event-handler.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils/action-event-handler.js b/src/utils/action-event-handler.js index 1884a7313..f6177c3b8 100644 --- a/src/utils/action-event-handler.js +++ b/src/utils/action-event-handler.js @@ -3,6 +3,7 @@ export default class ActionEventHandler { this.scene = scene; this.cursor = cursor; this.isCursorInteracting = false; + this.isCursorInteractingOnGrab = false; this.isTeleporting = false; this.handThatAlsoDrivesCursor = null; this.hovered = false; @@ -57,6 +58,9 @@ export default class ActionEventHandler { return; } else { this.isCursorInteracting = this.cursor.startInteraction(); + if (this.isCursorInteracting) { + this.isCursorInteractingOnGrab = true; + } return; } } else { @@ -66,8 +70,14 @@ export default class ActionEventHandler { } onRelease(e) { - if (this.isCursorInteracting && this.handThatAlsoDrivesCursor && this.handThatAlsoDrivesCursor === e.target) { + if ( + this.isCursorInteracting && + this.isCursorInteractingOnGrab && + this.handThatAlsoDrivesCursor && + this.handThatAlsoDrivesCursor === e.target + ) { this.isCursorInteracting = false; + this.isCursorInteractingOnGrab = false; this.cursor.endInteraction(); } else { e.target.emit("hand_release"); @@ -75,6 +85,7 @@ export default class ActionEventHandler { } onPrimaryDown(e) { + if (this.isCursorInteractingOnGrab) return; if (this.handThatAlsoDrivesCursor && this.handThatAlsoDrivesCursor === e.target) { if (this.isCursorInteracting) { return; @@ -94,6 +105,7 @@ export default class ActionEventHandler { } onPrimaryUp(e) { + if (this.isCursorInteractingOnGrab) return; const isCursorHand = this.handThatAlsoDrivesCursor && this.handThatAlsoDrivesCursor === e.target; if (this.isCursorInteracting && isCursorHand) { this.isCursorInteracting = false; -- GitLab