index.js
/**
		* Event handler for a touch start event.
		* Stops the default click event from triggering and stores where we touched
		* @inner
		* @param {object} jqEvent The normalised jQuery event object.
		*/
Event handler for a touch start event.
Stops the default click event from triggering and stores where we touched
@inner
@param {object} jqEvent The normalised jQuery event object.
Event handler for a touch start event . Stops the default click event from triggering and stores where we touched @inner @param { object } jqEvent The normalised jQuery event object .
function touchStart(jqEvent) {
			if( getTouchInProgress() )
				return;
			if( $(jqEvent.target).closest( options.excludedElements, $element ).length>0 )
				return;
			var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
			var ret,
				evt = SUPPORTS_TOUCH ? event.touches[0] : event;
			phase = PHASE_START;
			if (SUPPORTS_TOUCH) {
				fingerCount = event.touches.length;
			}
			else {
				jqEvent.preventDefault(); 
			}
			distance = 0;
			direction = null;
			pinchDirection=null;
			duration = 0;
			startTouchesDistance=0;
			endTouchesDistance=0;
			pinchZoom = 1;
			pinchDistance = 0;
			fingerData=createAllFingerData();
			maximumsMap=createMaximumsData();
			cancelMultiFingerRelease();
			if (!SUPPORTS_TOUCH || (fingerCount === options.fingers || options.fingers === ALL_FINGERS) || hasPinches()) {
				createFingerData( 0, evt );
				startTime = getTimeStamp();
				if(fingerCount==2) {
					createFingerData( 1, event.touches[1] );
					startTouchesDistance = endTouchesDistance = calculateTouchesDistance(fingerData[0].start, fingerData[1].start);
				}
				if (options.swipeStatus || options.pinchStatus) {
					ret = triggerHandler(event, phase);
				}
			}
			else {
				ret = false;
			}
			if (ret === false) {
				phase = PHASE_CANCEL;
				triggerHandler(event, phase);
				return ret;
			}
			else {
				setTouchInProgress(true);
			}
            return null;
		}
function touchStart ( jqEvent ) { if ( getTouchInProgress ( ) ) return ; if ( $ ( jqEvent . target ) . closest ( options . excludedElements , $element ) . length > 0 ) return ; var event = jqEvent . originalEvent ? jqEvent . originalEvent : jqEvent ; var ret , evt = SUPPORTS_TOUCH ? event . touches [ 0 ] : event ; phase = PHASE_START ; if ( SUPPORTS_TOUCH ) { fingerCount = event . touches . length ; } else { jqEvent . preventDefault ( ) ; } distance = 0 ; direction = null ; pinchDirection = null ; duration = 0 ; startTouchesDistance = 0 ; endTouchesDistance = 0 ; pinchZoom = 1 ; pinchDistance = 0 ; fingerData = createAllFingerData ( ) ; maximumsMap = createMaximumsData ( ) ; cancelMultiFingerRelease ( ) ; if ( ! SUPPORTS_TOUCH || ( fingerCount === options . fingers || options . fingers === ALL_FINGERS ) || hasPinches ( ) ) { createFingerData ( 0 , evt ) ; startTime = getTimeStamp ( ) ; if ( fingerCount == 2 ) { createFingerData ( 1 , event . touches [ 1 ] ) ; startTouchesDistance = endTouchesDistance = calculateTouchesDistance ( fingerData [ 0 ] . start , fingerData [ 1 ] . start ) ; } if ( options . swipeStatus || options . pinchStatus ) { ret = triggerHandler ( event , phase ) ; } } else { ret = false ; } if ( ret === false ) { phase = PHASE_CANCEL ; triggerHandler ( event , phase ) ; return ret ; } else { setTouchInProgress ( true ) ; } return null ; }
Event handler for a touch start event.
Event handler for a touch start event .
//If we already in a touch event (a finger already in use) then ignore subsequent ones.. //Check if this element matches any in the excluded elements selectors,  or its parent is excluded, if so, DON'T swipe //As we use Jquery bind for events, we need to target the original event object //If these events are being programmatically triggered, we don't have an original event object, so use the Jq one. //If we support touches, get the finger count // get the total number of fingers touching the screen //Else this is the desktop, so stop the browser from dragging the image //call this on jq event so we are cross browser //clear vars.. // check the number of fingers is what we are looking for, or we are capturing pinches // get the coordinates of the touch //Keep track of the initial pinch distance, so we can calculate the diff later //Store second finger data as start //A touch with more or less than the fingers we are looking for, so cancel //If we have a return value from the users handler, then return and cancel