Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
listenForSwipeDown (swipeableElementRef) {
if (swipeableElementRef === this.currentSwipeableElementRef) {
// don't set hammer up for the same element more than once
return;
}
this.hammer = new Hammer.Manager(swipeableElementRef);
this.hammer.add(new Hammer.Pan({
direction: Hammer.DIRECTION_DOWN,
threshold: 0
}) );
this.hammer.on('pan', (ev) => {
if (this.props.swipeEnabled) {
handleSwipeDown(ev, this.props.onSwipeEnd, swipeableElementRef);
}
});
this.currentSwipeableElementRef = swipeableElementRef;
}
it('should set direction to "down" when swiping down', function() {
simulateSwipeGestureMoves(hammerInstance, { deltaY: 0 }, { deltaY: 2 });
CustomSwipeGesture.handler(endEvent, hammerInstance);
expect(endEvent.direction).toBe(Hammer.DIRECTION_DOWN);
});
it('should use the dimension with the larger delta when determining direction', function() {
it('should use the dimension with the larger delta when determining direction', function() {
simulateSwipeGestureMoves(hammerInstance,
{ deltaX: 0, deltaY: 0 },
{ deltaX: 2, deltaY: 4 }
);
CustomSwipeGesture.handler(endEvent, hammerInstance);
expect(endEvent.direction).toBe(Hammer.DIRECTION_DOWN);
});
});
}
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;
}
if (horizontalDirections.length && verticalDirections.length) {
const recognizers: RecognizerTuple[] = []
if (onPinchEnd) recognizers.push([Hammer.Pinch, { threshold: 0.5 }])
if (onTap) recognizers.push([Hammer.Tap])
if (onDoubleTap)
recognizers.push([
Hammer.Tap,
{ event: "doubletap", taps: 2, posThreshold: 40 },
])
if (onThreeFingerSwipeDown) {
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,
componentDidMount: function() {
this.refs.scroller.consuming = true;
this.refs.scroller.origin = 0;
var hammer = (this.hammer = new Hammer(this.refs.swipeArea.getDOMNode()));
hammer.get('swipe').set({
direction: Hammer.DIRECTION_DOWN,
velocity: 0.3,
threshold: 7,
});
hammer.on('swipe', this.swipeDown);
},
listenForSwipeDown (expandedPlayerRef) {
this.hammer = new Hammer.Manager(expandedPlayerRef);
this.hammer.add(new Hammer.Pan({
direction: Hammer.DIRECTION_DOWN,
threshold: 0
}) );
this.hammer.on('pan', (ev) => {
const onSwipeEnd = playerActions.onMinimise;
handleSwipeDown(ev, onSwipeEnd, expandedPlayerRef);
});
this.expandedPlayerListensSwipe = expandedPlayerRef;
}
const recognizers: RecognizerTuple[] = []
if (onPinchEnd) recognizers.push([Hammer.Pinch, { threshold: 0.5 }])
if (onTap) recognizers.push([Hammer.Tap])
if (onDoubleTap)
recognizers.push([
Hammer.Tap,
{ event: "doubletap", taps: 2, posThreshold: 40 },
])
if (onThreeFingerSwipeDown) {
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,