You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't an issue, more of a question on how to implement a new gesture handler. If this isn't appropriate, please delete, and I apologize.
In detection.js, there is this code:
// call Hammer.gesture handlersUtils.each(this.gestures, functiontriggerGesture(gesture) {
// only when the instance options have enabled this gestureif(!this.stopped && inst.enabled && instOptions[gesture.name]) {
// if a handler returns false, we stop with the detectionif(gesture.handler.call(gesture, eventData, inst) === false) {
this.stopDetect();
returnfalse;
}
}
}, this);
Where the comments say:
// if a handler returns false, we stop with the detection
But I don't see how any of the provided handlers return anything, either true or false. Or does the call only return false if there is no handler?
For example, here is the handler for swipe.js ... it doesn't explicitly return anything, it just returns. I'm not very comfortable with the function prototype call and closure, so maybe it is obvious to others.
Hammer.gestures.Swipe = {
name: 'swipe',
index: 40,
defaults: {
/* < SNIPPED > */
},
handler: functionswipeGesture(ev, inst) {
if(ev.eventType == EVENT_RELEASE) {
vartouches = ev.touches.length,
options = inst.options;
// max touchesif(touches < options.swipeMinTouches ||
touches > options.swipeMaxTouches) {
return;
}
// when the distance we moved is too small we skip this gesture// or we can be already in draggingif(ev.velocityX > options.swipeVelocityX ||
ev.velocityY > options.swipeVelocityY) {
// trigger swipe eventsinst.trigger(this.name, ev);
inst.trigger(this.name + ev.direction, ev);
}
}
}
};
Thanks!!
The text was updated successfully, but these errors were encountered:
I guess this is kind of deprecated code, that could be removed. It does exactly the same as calling stopDetect(). Currently it isn't used anywhere in the default gestures like you said.
Ok, that’s what I thought, but since I’m not 100% sure with java and closure, I wanted to make sure I wasn’t misreading the code.
Thanks for following up!
-John Slagel
From: Jorik Tangelder [mailto:notifications@github.com]
Sent: Thursday, May 01, 2014 1:32 PM
To: EightMedia/hammer.js
Cc: John Slagel
Subject: Re: [hammer.js] Gester detection handler clarification? (#545)
I guess this is kind of deprecated code, that could be removed. It does exactly the same as calling stopDetect(). Currently it isn't used anywhere in the default gestures like you said.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/545#issuecomment-41940503.
This isn't an issue, more of a question on how to implement a new gesture handler. If this isn't appropriate, please delete, and I apologize.
In detection.js, there is this code:
Where the comments say:
// if a handler returns false, we stop with the detection
But I don't see how any of the provided handlers return anything, either true or false. Or does the call only return false if there is no handler?
For example, here is the handler for swipe.js ... it doesn't explicitly return anything, it just returns. I'm not very comfortable with the function prototype call and closure, so maybe it is obvious to others.
Thanks!!
The text was updated successfully, but these errors were encountered: