1
/*!
2
* @fileOverview TouchSwipe - jQuery Plugin
3
* @version 1.6.18
4
*
5
* @author Matt Bryson http://www.github.com/mattbryson
6
* @see https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
7
* @see http://labs.rampinteractive.co.uk/touchSwipe/
8
* @see http://plugins.jquery.com/project/touchSwipe
9
* @license
10
* Copyright (c) 2010-2015 Matt Bryson
11
* Dual licensed under the MIT or GPL Version 2 licenses.
12
*
13
*/
14
!function(factory){"function"==typeof define&&define.amd&&define.amd.jQuery?define(["jquery"],factory):factory("undefined"!=typeof module&&module.exports?require("jquery"):jQuery)}
15
((function($){"use strict";function init(options){return!options||void 0!==options.allowPageScroll||void 0===options.swipe&&void 0===options.swipeStatus||(options.allowPageScroll=NONE),void 0!==options.click&&void 0===options.tap&&(options.tap=options.click),options||(options={}
16
),options=$.extend({}
17
,$.fn.swipe.defaults,options),this.each((function(){var $this=$(this),plugin=$this.data(PLUGIN_NS);plugin||(plugin=new TouchSwipe(this,options),$this.data(PLUGIN_NS,plugin))}
18
))}
19
function TouchSwipe(element,options){function touchStart(jqEvent){if(!(!0===$element.data(PLUGIN_NS+"_intouch")||$(jqEvent.target).closest(options.excludedElements,$element).length>0)){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent;if(!event.pointerType||"mouse"!=event.pointerType||0!=options.fallbackToMouseEvents){var ret,touches=event.touches,evt=touches?touches[0]:event;return phase=PHASE_START,touches?fingerCount=touches.length:!1!==options.preventDefaultEvents&&jqEvent.preventDefault(),distance=0,direction=null,currentDirection=null,pinchDirection=null,duration=0,startTouchesDistance=0,endTouchesDistance=0,pinchZoom=1,pinchDistance=0,(maxData={}
20
)[LEFT]=createMaximumVO(LEFT),maxData[RIGHT]=createMaximumVO(RIGHT),maxData[UP]=createMaximumVO(UP),maxData[DOWN]=createMaximumVO(DOWN),maximumsMap=maxData,cancelMultiFingerRelease(),createFingerData(0,evt),!touches||fingerCount===options.fingers||options.fingers===ALL_FINGERS||hasPinches()?(startTime=getTimeStamp(),2==fingerCount&&(createFingerData(1,touches[1]),startTouchesDistance=endTouchesDistance=calculateTouchesDistance(fingerData[0].start,fingerData[1].start)),(options.swipeStatus||options.pinchStatus)&&(ret=triggerHandler(event,phase))):ret=!1,!1===ret?(triggerHandler(event,phase=PHASE_CANCEL),ret):(options.hold&&(holdTimeout=setTimeout($.proxy((function(){$element.trigger("hold",[event.target]),options.hold&&(ret=options.hold.call($element,event,event.target))}
21
),this),options.longTapThreshold)),setTouchInProgress(!0),null)}
22
}
23
var maxData}
24
function touchMove(jqEvent){var el,offset,startPoint,endPoint,event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent;if(phase!==PHASE_END&&phase!==PHASE_CANCEL&&!inMultiFingerRelease()){var ret,touches=event.touches,currentFinger=updateFingerData(touches?touches[0]:event);if(endTime=getTimeStamp(),touches&&(fingerCount=touches.length),options.hold&&clearTimeout(holdTimeout),phase=PHASE_MOVE,2==fingerCount&&(0==startTouchesDistance?(createFingerData(1,touches[1]),startTouchesDistance=endTouchesDistance=calculateTouchesDistance(fingerData[0].start,fingerData[1].start)):(updateFingerData(touches[1]),endTouchesDistance=calculateTouchesDistance(fingerData[0].end,fingerData[1].end),fingerData[0].end,fingerData[1].end,pinchDirection=1>pinchZoom?OUT:IN),pinchZoom=(endTouchesDistance/startTouchesDistance*1).toFixed(2),pinchDistance=Math.abs(startTouchesDistance-endTouchesDistance)),fingerCount===options.fingers||options.fingers===ALL_FINGERS||!touches||hasPinches()){if(direction=calculateDirection(currentFinger.start,currentFinger.end),function(jqEvent,direction){if(!1!==options.preventDefaultEvents)if(options.allowPageScroll===NONE)jqEvent.preventDefault();else{var auto=options.allowPageScroll===AUTO;switch(direction){case LEFT:(options.swipeLeft&&auto||!auto&&options.allowPageScroll!=HORIZONTAL)&&jqEvent.preventDefault();break;case RIGHT:(options.swipeRight&&auto||!auto&&options.allowPageScroll!=HORIZONTAL)&&jqEvent.preventDefault();break;case UP:(options.swipeUp&&auto||!auto&&options.allowPageScroll!=VERTICAL)&&jqEvent.preventDefault();break;case DOWN:(options.swipeDown&&auto||!auto&&options.allowPageScroll!=VERTICAL)&&jqEvent.preventDefault()}
25
}
26
}
27
(jqEvent,currentDirection=calculateDirection(currentFinger.last,currentFinger.end)),startPoint=currentFinger.start,endPoint=currentFinger.end,distance=Math.round(Math.sqrt(Math.pow(endPoint.x-startPoint.x,2)+Math.pow(endPoint.y-startPoint.y,2))),duration=calculateDuration(),function(direction,distance){direction!=NONE&&(distance=Math.max(distance,getMaxDistance(direction)),maximumsMap[direction].distance=distance)}
28
(direction,distance),ret=triggerHandler(event,phase),!options.triggerOnTouchEnd||options.triggerOnTouchLeave){var inBounds=!0;if(options.triggerOnTouchLeave){var bounds={left:(offset=(el=$(el=this)).offset()).left,right:offset.left+el.outerWidth(),top:offset.top,bottom:offset.top+el.outerHeight()}
29
;inBounds=function(point,bounds){return point.x>bounds.left&&point.x<bounds.right&&point.y>bounds.top&&point.y<bounds.bottom}
30
(currentFinger.end,bounds)}
31
!options.triggerOnTouchEnd&&inBounds?phase=getNextPhase(PHASE_MOVE):options.triggerOnTouchLeave&&!inBounds&&(phase=getNextPhase(PHASE_END)),phase!=PHASE_CANCEL&&phase!=PHASE_END||triggerHandler(event,phase)}
32
}
33
else triggerHandler(event,phase=PHASE_CANCEL);!1===ret&&triggerHandler(event,phase=PHASE_CANCEL)}
34
}
35
function touchEnd(jqEvent){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent,touches=event.touches;if(touches){if(touches.length&&!inMultiFingerRelease())return function(event){previousTouchEndTime=getTimeStamp(),fingerCountAtRelease=event.touches.length+1}
36
(event),!0;if(touches.length&&inMultiFingerRelease())return!0}
37
return inMultiFingerRelease()&&(fingerCount=fingerCountAtRelease),endTime=getTimeStamp(),duration=calculateDuration(),didSwipeBackToCancel()||!validateSwipeDistance()?triggerHandler(event,phase=PHASE_CANCEL):options.triggerOnTouchEnd||!1===options.triggerOnTouchEnd&&phase===PHASE_MOVE?(!1!==options.preventDefaultEvents&&!1!==jqEvent.cancelable&&jqEvent.preventDefault(),triggerHandler(event,phase=PHASE_END)):!options.triggerOnTouchEnd&&hasTap()?triggerHandlerForGesture(event,phase=PHASE_END,TAP):phase===PHASE_MOVE&&triggerHandler(event,phase=PHASE_CANCEL),setTouchInProgress(!1),null}
38
function touchCancel(){fingerCount=0,endTime=0,startTime=0,startTouchesDistance=0,endTouchesDistance=0,pinchZoom=1,cancelMultiFingerRelease(),setTouchInProgress(!1)}
39
function touchLeave(jqEvent){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent;options.triggerOnTouchLeave&&triggerHandler(event,phase=getNextPhase(PHASE_END))}
40
function removeListeners(){$element.off(START_EV,touchStart),$element.off(CANCEL_EV,touchCancel),$element.off(MOVE_EV,touchMove),$element.off(END_EV,touchEnd),LEAVE_EV&&$element.off(LEAVE_EV,touchLeave),setTouchInProgress(!1)}
...
</html>