How to use the hammerjs.EVENT_END function in hammerjs

To help you get started, we’ve selected a few hammerjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Workiva / wf-uicomponents / test / awesome_map / CustomSwipeGestureSpec.js View on Github external
it('should not trigger swipe if max touches constraint fails', function() {
            var hammerInstance = createHammerInstance({
                swipe_max_touches: 1,
                swipe_velocity: 0
            });
            // Simulate a transform
            var transformEvent = createFakeEvent({
                eventType: Hammer.EVENT_MOVE,
                touches: ['faketouch', 'faketouch']
            });
            var endEvent = createFakeEvent({
                eventType: Hammer.EVENT_END,
                touches: ['faketouch']
            });
            simulateSwipeGestureMoves(hammerInstance, { deltaX: 0 }, { deltaX: 2 });
            CustomSwipeGesture.handler(transformEvent, hammerInstance);
            CustomSwipeGesture.handler(endEvent, hammerInstance);
            expect(hammerInstance.trigger).not.toHaveBeenCalled();
        });
        it('should not trigger swipe if velocityX and velocityY are below threshold', function() {
github Workiva / wf-uicomponents / src / awesome_map / CustomSwipeGesture.js View on Github external
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
                // entire interaction, from start to end.
                moves.splice(0, Math.max(0, moves.length - EVALUATION_DEPTH));
                var velocityX = getVelocity('x');
                var velocityY = getVelocity('y');

                // If either of the velocities are greater than the
github Workiva / wf-uicomponents / test / awesome_map / CustomSwipeGestureSpec.js View on Github external
beforeEach(function() {
            endEvent = createFakeEvent({ eventType: Hammer.EVENT_END });
        });
        describe('when velocityX is greater than configured threshold', function() {