Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handler: function swipeGesture(ev, inst) {
// Enforce the max touches option.
if (inst.options.swipe_max_touches > 0 &&
ev.touches.length > inst.options.swipe_max_touches
) {
this.cancel = true;
return;
}
if (ev.eventType === Hammer.EVENT_START) {
moves = [ev, ev];
}
else if (ev.eventType === Hammer.EVENT_MOVE) {
moves.push(ev);
}
else if (ev.eventType === Hammer.EVENT_END) {
// If canceling due to multitouch gesture, then bail out after
// flipping the switch so the next swipe begins detection anew.
if (this.cancel) {
this.cancel = false;
return;
}
// Calculate the velocity and direction using the last N moves
// in an attempt to provide for a more "instantaneous" velocity.
// By default, hammer calcs velocity and direction over the
function simulateSwipeGestureMoves(hammerInstance, move1Props, move2Props) {
var startEvent = createFakeEvent({
eventType: Hammer.EVENT_START
});
var moveEvent1 = createFakeEvent(_.defaults(move1Props, {
eventType: Hammer.EVENT_MOVE,
timeStamp: 1
}));
var moveEvent2 = createFakeEvent(_.defaults(move2Props, {
eventType: Hammer.EVENT_MOVE,
timeStamp: 2
}));
CustomSwipeGesture.handler(startEvent, hammerInstance);
CustomSwipeGesture.handler(moveEvent1, hammerInstance);
CustomSwipeGesture.handler(moveEvent2, hammerInstance);
}
var endEvent;