From 74d69cc2e8c0f0838cb7d955001362b029410e86 Mon Sep 17 00:00:00 2001 From: Kevin Lee <kevin@infinite-lee.com> Date: Thu, 26 Jul 2018 17:01:05 -0700 Subject: [PATCH] fix hand switching --- package.json | 2 +- src/components/grabbable-toggle.js | 10 ++++++++++ yarn.lock | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 744b8d815..c5648ef06 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "react-intl": "^2.4.0", "react-router-dom": "^4.2.2", "screenfull": "^3.3.2", - "super-hands": "https://github.com/mozillareality/aframe-super-hands-component#hubs/master", + "super-hands": "https://github.com/mozillareality/aframe-super-hands-component#feature/drawing-work-branch", "uuid": "^3.2.1", "webrtc-adapter": "^6.0.2" }, diff --git a/src/components/grabbable-toggle.js b/src/components/grabbable-toggle.js index ef5f41f98..54b62bc57 100644 --- a/src/components/grabbable-toggle.js +++ b/src/components/grabbable-toggle.js @@ -6,6 +6,8 @@ AFRAME.registerComponent("grabbable-toggle", { init() { this.toggle = false; + this.currentHand = null; + this.onGrabEnd = this.onGrabEnd.bind(this); this.el.addEventListener("grab-end", this.onGrabEnd); this.el.classList.add("sticky"); @@ -18,11 +20,19 @@ AFRAME.registerComponent("grabbable-toggle", { onGrabEnd(e) { const type = e.detail && e.detail.buttonEvent ? e.detail.buttonEvent.type : null; + + if (this.toggle && this.currentHand !== null && this.currentHand !== e.detail.hand) { + this.toggle = false; + this.currentHand = null; + } + if ((this.isPrimaryRelease(type) && !this.toggle) || this.isSecondaryRelease(type)) { this.toggle = true; + this.currentHand = e.detail.hand; e.stopImmediatePropagation(); //prevents grabbable from calling preventDefault } else if (this.toggle && this.isPrimaryRelease(type)) { this.toggle = false; + this.currentHand = null; } }, diff --git a/yarn.lock b/yarn.lock index 2ace6bd5d..5ce48fa1b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7858,9 +7858,9 @@ subarg@^1.0.0: dependencies: minimist "^1.1.0" -"super-hands@https://github.com/mozillareality/aframe-super-hands-component#hubs/master": +"super-hands@https://github.com/mozillareality/aframe-super-hands-component#feature/drawing-work-branch": version "3.0.0" - resolved "https://github.com/mozillareality/aframe-super-hands-component#ae01ff079032177fd8cd16a2881d459b71318207" + resolved "https://github.com/mozillareality/aframe-super-hands-component#5d82ce660b6e8f2ee49a368248fd4d1c4627b8c8" supports-color@1.3.1: version "1.3.1" -- GitLab