Skip to content

Commit 77a3494

Browse files
committed
improve gesture flow via listener registration order
1 parent 4f320ec commit 77a3494

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

dist/super-hands.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
1+
(function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
22
'use strict';
33

44
/* global AFRAME */
@@ -186,9 +186,9 @@ AFRAME.registerComponent('super-hands', {
186186
},
187187
onStretchEndButton: function (evt) {
188188
const stretched = this.state.get(this.STRETCH_EVENT);
189-
const endEvt = { hand: this.el, buttonEvent: evt };
190-
// check if end event accepted
191-
if (stretched && !this.emitCancelable(stretched, this.UNSTRETCH_EVENT, endEvt)) {
189+
const endEvt = { hand: this.el, buttonEvent: evt
190+
// check if end event accepted
191+
};if (stretched && !this.emitCancelable(stretched, this.UNSTRETCH_EVENT, endEvt)) {
192192
this.promoteHoveredEl(stretched);
193193
this.state.delete(this.STRETCH_EVENT);
194194
this.hover();
@@ -402,24 +402,26 @@ AFRAME.registerComponent('super-hands', {
402402
this.el.addEventListener(this.data.colliderEndEvent, this.unWatch);
403403
this.el.addEventListener(this.data.colliderEndEvent, this.unHover);
404404

405+
// binding order to keep grabEnd from triggering dragover
406+
// again before dragDropEnd can delete its carried state
405407
this.data.grabStartButtons.forEach(b => {
406408
this.el.addEventListener(b, this.onGrabStartButton);
407409
});
408-
this.data.grabEndButtons.forEach(b => {
409-
this.el.addEventListener(b, this.onGrabEndButton);
410-
});
411410
this.data.stretchStartButtons.forEach(b => {
412411
this.el.addEventListener(b, this.onStretchStartButton);
413412
});
414-
this.data.stretchEndButtons.forEach(b => {
415-
this.el.addEventListener(b, this.onStretchEndButton);
416-
});
417413
this.data.dragDropStartButtons.forEach(b => {
418414
this.el.addEventListener(b, this.onDragDropStartButton);
419415
});
420416
this.data.dragDropEndButtons.forEach(b => {
421417
this.el.addEventListener(b, this.onDragDropEndButton);
422418
});
419+
this.data.stretchEndButtons.forEach(b => {
420+
this.el.addEventListener(b, this.onStretchEndButton);
421+
});
422+
this.data.grabEndButtons.forEach(b => {
423+
this.el.addEventListener(b, this.onGrabEndButton);
424+
});
423425
},
424426
unRegisterListeners: function (data) {
425427
data = data || this.data;
@@ -1119,9 +1121,9 @@ AFRAME.registerComponent('grabbable', inherit(base, {
11191121
this.deltaPositionIsValid = false;
11201122
this.grabDistance = undefined;
11211123
this.grabDirection = { x: 0, y: 0, z: -1 };
1122-
this.grabOffset = { x: 0, y: 0, z: 0 };
1123-
// persistent object speeds up repeat setAttribute calls
1124-
this.destPosition = { x: 0, y: 0, z: 0 };
1124+
this.grabOffset = { x: 0, y: 0, z: 0
1125+
// persistent object speeds up repeat setAttribute calls
1126+
};this.destPosition = { x: 0, y: 0, z: 0 };
11251127
this.deltaPosition = new THREE.Vector3();
11261128
this.targetPosition = new THREE.Vector3();
11271129
this.physicsInit();

0 commit comments

Comments
 (0)