dist/toolkit.js
function() {
            var self = $(this),
                start,
                target;

            /**
             * There's a major bug in Android devices where `touchend` events do not fire
             * without calling `preventDefault()` in `touchstart` or `touchmove`.
             * Because of this, we have to hack-ily implement functionality into `touchmove`.
             * We also can't use `touchcancel` as that fires prematurely and unbinds our move event.
             * More information on these bugs can be found here:
             *
             * https://code.google.com/p/android/issues/detail?id=19827
             * https://code.google.com/p/chromium/issues/detail?id=260732
             *
             * Using `touchcancel` is also rather unpredictable, as described here:
             *
             * http://alxgbsn.co.uk/2011/12/23/different-ways-to-trigger-touchcancel-in-mobile-browsers/
             */
            function move(e) {
                var to = coords(e);

                // Trigger `preventDefault()` if `x` is larger than `y` (scrolling horizontally).
                // If we `preventDefault()` while scrolling vertically, the window will not scroll.
                if (abs(start.x - to.x) > abs(start.y - to.y)) {
                    e.preventDefault();
                }
            }

            /**
             * When `touchend` or `touchcancel` is triggered, clean up the swipe state.
             * Also unbind `touchmove` events until another swipe occurs.
             */
            function cleanup() {
                start = target = null;
                swiping = false;

                self.off(moveEvent, move);
            }

            // Initialize the state when a touch occurs
            self.on(startEvent, function(e) {

                // Calling `preventDefault()` on start will disable clicking of elements (links, inputs, etc)
                // So only do it on an `img` element so it cannot be dragged
                if (!isTouch && e.target.tagName.toLowerCase() === 'img') {
                    e.preventDefault();
                }

                // Exit early if another swipe is occurring
                if (swiping) {
                    return;
                }

                start = coords(e);
                target = e.target;
                swiping = true;

                // Non-touch devices don't make use of the move event
                if (isTouch) {
                    self.on(moveEvent, move);
                }
            });

            // Trigger the swipe event when the touch finishes
            self.on(stopEvent, function(e) {
                swipe(start, coords(e), self, target);
                cleanup();
            });

            // Reset the state when the touch is cancelled
            self.on('touchcancel', cleanup);
        }
function() {
            var self = $(this),
                start,
                target;

            /**
             * There's a major bug in Android devices where `touchend` events do not fire
             * without calling `preventDefault()` in `touchstart` or `touchmove`.
             * Because of this, we have to hack-ily implement functionality into `touchmove`.
             * We also can't use `touchcancel` as that fires prematurely and unbinds our move event.
             * More information on these bugs can be found here:
             *
             * https://code.google.com/p/android/issues/detail?id=19827
             * https://code.google.com/p/chromium/issues/detail?id=260732
             *
             * Using `touchcancel` is also rather unpredictable, as described here:
             *
             * http://alxgbsn.co.uk/2011/12/23/different-ways-to-trigger-touchcancel-in-mobile-browsers/
             */
            function move(e) {
                var to = coords(e);

                // Trigger `preventDefault()` if `x` is larger than `y` (scrolling horizontally).
                // If we `preventDefault()` while scrolling vertically, the window will not scroll.
                if (abs(start.x - to.x) > abs(start.y - to.y)) {
                    e.preventDefault();
                }
            }

            /**
             * When `touchend` or `touchcancel` is triggered, clean up the swipe state.
             * Also unbind `touchmove` events until another swipe occurs.
             */
            function cleanup() {
                start = target = null;
                swiping = false;

                self.off(moveEvent, move);
            }

            // Initialize the state when a touch occurs
            self.on(startEvent, function(e) {

                // Calling `preventDefault()` on start will disable clicking of elements (links, inputs, etc)
                // So only do it on an `img` element so it cannot be dragged
                if (!isTouch && e.target.tagName.toLowerCase() === 'img') {
                    e.preventDefault();
                }

                // Exit early if another swipe is occurring
                if (swiping) {
                    return;
                }

                start = coords(e);
                target = e.target;
                swiping = true;

                // Non-touch devices don't make use of the move event
                if (isTouch) {
                    self.on(moveEvent, move);
                }
            });

            // Trigger the swipe event when the touch finishes
            self.on(stopEvent, function(e) {
                swipe(start, coords(e), self, target);
                cleanup();
            });

            // Reset the state when the touch is cancelled
            self.on('touchcancel', cleanup);
        }
function ( ) { var self = $ ( this ) , start , target ; /**
             * There's a major bug in Android devices where `touchend` events do not fire
             * without calling `preventDefault()` in `touchstart` or `touchmove`.
             * Because of this, we have to hack-ily implement functionality into `touchmove`.
             * We also can't use `touchcancel` as that fires prematurely and unbinds our move event.
             * More information on these bugs can be found here:
             *
             * https://code.google.com/p/android/issues/detail?id=19827
             * https://code.google.com/p/chromium/issues/detail?id=260732
             *
             * Using `touchcancel` is also rather unpredictable, as described here:
             *
             * http://alxgbsn.co.uk/2011/12/23/different-ways-to-trigger-touchcancel-in-mobile-browsers/
             */ function move ( e ) { var to = coords ( e ) ; // Trigger `preventDefault()` if `x` is larger than `y` (scrolling horizontally). // If we `preventDefault()` while scrolling vertically, the window will not scroll. if ( abs ( start . x - to . x ) > abs ( start . y - to . y ) ) { e . preventDefault ( ) ; } } /**
             * When `touchend` or `touchcancel` is triggered, clean up the swipe state.
             * Also unbind `touchmove` events until another swipe occurs.
             */ function cleanup ( ) { start = target = null ; swiping = false ; self . off ( moveEvent , move ) ; } // Initialize the state when a touch occurs self . on ( startEvent , function ( e ) { // Calling `preventDefault()` on start will disable clicking of elements (links, inputs, etc) // So only do it on an `img` element so it cannot be dragged if ( ! isTouch && e . target . tagName . toLowerCase ( ) === 'img' ) { e . preventDefault ( ) ; } // Exit early if another swipe is occurring if ( swiping ) { return ; } start = coords ( e ) ; target = e . target ; swiping = true ; // Non-touch devices don't make use of the move event if ( isTouch ) { self . on ( moveEvent , move ) ; } } ) ; // Trigger the swipe event when the touch finishes self . on ( stopEvent , function ( e ) { swipe ( start , coords ( e ) , self , target ) ; cleanup ( ) ; } ) ; // Reset the state when the touch is cancelled self . on ( 'touchcancel' , cleanup ) ; }
Maximum distance to travel in the opposite direction
Maximum distance to travel in the opposite direction