Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should set direction to "up" when swiping up', function() {
simulateSwipeGestureMoves(hammerInstance, { deltaY: 0 }, { deltaY: -2 });
CustomSwipeGesture.handler(endEvent, hammerInstance);
expect(endEvent.direction).toBe(Hammer.DIRECTION_UP);
});
it('should set direction to "down" when swiping down', function() {
function getDirection() {
var start = moves[0];
var end = moves[moves.length - 1];
var deltaX = Math.abs(end.deltaX - start.deltaX);
var deltaY = Math.abs(end.deltaY - start.deltaY);
if (deltaX >= deltaY) {
return start.deltaX > end.deltaX ? Hammer.DIRECTION_LEFT : Hammer.DIRECTION_RIGHT;
}
return start.deltaY > end.deltaY ? Hammer.DIRECTION_UP : Hammer.DIRECTION_DOWN;
}
recognizers.push([
Hammer.Swipe,
{
event: "threeFingerSwipeDown",
pointers: 3,
direction: Hammer.DIRECTION_DOWN,
},
])
}
if (onThreeFingerSwipeUp) {
recognizers.push([
Hammer.Swipe,
{
event: "threeFingerSwipeUp",
pointers: 3,
direction: Hammer.DIRECTION_UP,
},
])
}
this.hammer = new Hammer.Manager(this.ref, {
recognizers,
})
this.hammer.on("pinchend", this.handle("onPinchEnd"))
this.hammer.on("tap", this.handle("onTap"))
this.hammer.on("doubletap", this.handle("onDoubleTap"))
this.hammer.on(
"threeFingerSwipeDown",
this.handle("onThreeFingerSwipeDown"),
)
this.hammer.on("threeFingerSwipeUp", this.handle("onThreeFingerSwipeUp"))
}
recognizers.push([
Hammer.Swipe,
{
event: "threeFingerSwipeDown",
pointers: 1,
direction: Hammer.DIRECTION_DOWN,
},
])
}
if (onThreeFingerSwipeUp) {
recognizers.push([
Hammer.Swipe,
{
event: "threeFingerSwipeUp",
pointers: 3,
direction: Hammer.DIRECTION_UP,
},
])
}
this.hammer = new Hammer.Manager(this.base, {
recognizers,
})
this.hammer.on("pinchend", this.handle("onPinchEnd"))
this.hammer.on("tap", this.handle("onTap"))
this.hammer.on("doubletap", this.handle("onDoubleTap"))
this.hammer.on(
"threeFingerSwipeDown",
this.handle("onThreeFingerSwipeDown"),
)
this.hammer.on("threeFingerSwipeUp", this.handle("onThreeFingerSwipeUp"))
}
if (!isnan(minDist)) {
return Hammer.DIRECTION_ALL;
}
if (!isnan(activeOffsetXStart))
horizontalDirections.push(Hammer.DIRECTION_LEFT);
if (!isnan(activeOffsetXEnd))
horizontalDirections.push(Hammer.DIRECTION_RIGHT);
if (horizontalDirections.length === 2)
horizontalDirections = [Hammer.DIRECTION_HORIZONTAL];
directions = directions.concat(horizontalDirections);
let verticalDirections = [];
if (!isnan(activeOffsetYStart))
verticalDirections.push(Hammer.DIRECTION_UP);
if (!isnan(activeOffsetYEnd))
verticalDirections.push(Hammer.DIRECTION_DOWN);
if (verticalDirections.length === 2)
verticalDirections = [Hammer.DIRECTION_VERTICAL];
directions = directions.concat(verticalDirections);
if (!directions.length) {
return Hammer.DIRECTION_NONE;
}
if (
directions[0] === Hammer.DIRECTION_HORIZONTAL &&
directions[1] === Hammer.DIRECTION_VERTICAL
) {
return Hammer.DIRECTION_ALL;