plugins/touchswipe.js
function touchMove(jqEvent) {
			
			//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.
			var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
			
			//If we are ending, cancelling, or within the threshold of 2 fingers being released, don't track anything..
			if (phase === PHASE_END || phase === PHASE_CANCEL || inMultiFingerRelease())
				return;

			var ret,
				touches = event.touches,
				evt = touches ? touches[0] : event;
			

			//Update the  finger data 
			var currentFinger = updateFingerData(evt);
			endTime = getTimeStamp();
			
			if (touches) {
				fingerCount = touches.length;
			}

			if (options.hold)
				clearTimeout(holdTimeout);

			phase = PHASE_MOVE;

			//If we have 2 fingers get Touches distance as well
			if(fingerCount==2) {
				
				//Keep track of the initial pinch distance, so we can calculate the diff later
				//We do this here as well as the start event, in case they start with 1 finger, and the press 2 fingers
				if(startTouchesDistance==0) {
					//Create second finger if this is the first time...
					createFingerData( 1, touches[1] );
					
					startTouchesDistance = endTouchesDistance = calculateTouchesDistance(fingerData[0].start, fingerData[1].start);
				} else {
					//Else just update the second finger
					updateFingerData(touches[1]);
				
					endTouchesDistance = calculateTouchesDistance(fingerData[0].end, fingerData[1].end);
					pinchDirection = calculatePinchDirection(fingerData[0].end, fingerData[1].end);
				}
				
				
				pinchZoom = calculatePinchZoom(startTouchesDistance, endTouchesDistance);
				pinchDistance = Math.abs(startTouchesDistance - endTouchesDistance);
			}
			
			
			

			if ( (fingerCount === options.fingers || options.fingers === ALL_FINGERS) || !touches || hasPinches() ) {
				
				direction = calculateDirection(currentFinger.start, currentFinger.end);
				
				//Check if we need to prevent default event (page scroll / pinch zoom) or not
				validateDefaultEvent(jqEvent, direction);

				//Distance and duration are all off the main finger
				distance = calculateDistance(currentFinger.start, currentFinger.end);
				duration = calculateDuration();

                //Cache the maximum distance we made in this direction
                setMaxDistance(direction, distance);


				if (options.swipeStatus || options.pinchStatus) {
					ret = triggerHandler(event, phase);
				}
				
				
				//If we trigger end events when threshold are met, or trigger events when touch leaves element
				if(!options.triggerOnTouchEnd || options.triggerOnTouchLeave) {
					
					var inBounds = true;
					
					//If checking if we leave the element, run the bounds check (we can use touchleave as its not supported on webkit)
					if(options.triggerOnTouchLeave) {
						var bounds = getbounds( this );
						inBounds = isInBounds( currentFinger.end, bounds );
					}
					
					//Trigger end handles as we swipe if thresholds met or if we have left the element if the user has asked to check these..
					if(!options.triggerOnTouchEnd && inBounds) {
						phase = getNextPhase( PHASE_MOVE );
					} 
					//We end if out of bounds here, so set current phase to END, and check if its modified 
					else if(options.triggerOnTouchLeave && !inBounds ) {
						phase = getNextPhase( PHASE_END );
					}
						
					if(phase==PHASE_CANCEL || phase==PHASE_END)	{
						triggerHandler(event, phase);
					}				
				}
			}
			else {
				phase = PHASE_CANCEL;
				triggerHandler(event, phase);
			}

			if (ret === false) {
				phase = PHASE_CANCEL;
				triggerHandler(event, phase);
			}
		}
function touchMove(jqEvent) {
			
			//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.
			var event = jqEvent.originalEvent ? jqEvent.originalEvent : jqEvent;
			
			//If we are ending, cancelling, or within the threshold of 2 fingers being released, don't track anything..
			if (phase === PHASE_END || phase === PHASE_CANCEL || inMultiFingerRelease())
				return;

			var ret,
				touches = event.touches,
				evt = touches ? touches[0] : event;
			

			//Update the  finger data 
			var currentFinger = updateFingerData(evt);
			endTime = getTimeStamp();
			
			if (touches) {
				fingerCount = touches.length;
			}

			if (options.hold)
				clearTimeout(holdTimeout);

			phase = PHASE_MOVE;

			//If we have 2 fingers get Touches distance as well
			if(fingerCount==2) {
				
				//Keep track of the initial pinch distance, so we can calculate the diff later
				//We do this here as well as the start event, in case they start with 1 finger, and the press 2 fingers
				if(startTouchesDistance==0) {
					//Create second finger if this is the first time...
					createFingerData( 1, touches[1] );
					
					startTouchesDistance = endTouchesDistance = calculateTouchesDistance(fingerData[0].start, fingerData[1].start);
				} else {
					//Else just update the second finger
					updateFingerData(touches[1]);
				
					endTouchesDistance = calculateTouchesDistance(fingerData[0].end, fingerData[1].end);
					pinchDirection = calculatePinchDirection(fingerData[0].end, fingerData[1].end);
				}
				
				
				pinchZoom = calculatePinchZoom(startTouchesDistance, endTouchesDistance);
				pinchDistance = Math.abs(startTouchesDistance - endTouchesDistance);
			}
			
			
			

			if ( (fingerCount === options.fingers || options.fingers === ALL_FINGERS) || !touches || hasPinches() ) {
				
				direction = calculateDirection(currentFinger.start, currentFinger.end);
				
				//Check if we need to prevent default event (page scroll / pinch zoom) or not
				validateDefaultEvent(jqEvent, direction);

				//Distance and duration are all off the main finger
				distance = calculateDistance(currentFinger.start, currentFinger.end);
				duration = calculateDuration();

                //Cache the maximum distance we made in this direction
                setMaxDistance(direction, distance);


				if (options.swipeStatus || options.pinchStatus) {
					ret = triggerHandler(event, phase);
				}
				
				
				//If we trigger end events when threshold are met, or trigger events when touch leaves element
				if(!options.triggerOnTouchEnd || options.triggerOnTouchLeave) {
					
					var inBounds = true;
					
					//If checking if we leave the element, run the bounds check (we can use touchleave as its not supported on webkit)
					if(options.triggerOnTouchLeave) {
						var bounds = getbounds( this );
						inBounds = isInBounds( currentFinger.end, bounds );
					}
					
					//Trigger end handles as we swipe if thresholds met or if we have left the element if the user has asked to check these..
					if(!options.triggerOnTouchEnd && inBounds) {
						phase = getNextPhase( PHASE_MOVE );
					} 
					//We end if out of bounds here, so set current phase to END, and check if its modified 
					else if(options.triggerOnTouchLeave && !inBounds ) {
						phase = getNextPhase( PHASE_END );
					}
						
					if(phase==PHASE_CANCEL || phase==PHASE_END)	{
						triggerHandler(event, phase);
					}				
				}
			}
			else {
				phase = PHASE_CANCEL;
				triggerHandler(event, phase);
			}

			if (ret === false) {
				phase = PHASE_CANCEL;
				triggerHandler(event, phase);
			}
		}
function touchMove ( jqEvent ) { //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. var event = jqEvent . originalEvent ? jqEvent . originalEvent : jqEvent ; //If we are ending, cancelling, or within the threshold of 2 fingers being released, don't track anything.. if ( phase === PHASE_END || phase === PHASE_CANCEL || inMultiFingerRelease ( ) ) return ; var ret , touches = event . touches , evt = touches ? touches [ 0 ] : event ; //Update the  finger data  var currentFinger = updateFingerData ( evt ) ; endTime = getTimeStamp ( ) ; if ( touches ) { fingerCount = touches . length ; } if ( options . hold ) clearTimeout ( holdTimeout ) ; phase = PHASE_MOVE ; //If we have 2 fingers get Touches distance as well if ( fingerCount == 2 ) { //Keep track of the initial pinch distance, so we can calculate the diff later //We do this here as well as the start event, in case they start with 1 finger, and the press 2 fingers if ( startTouchesDistance == 0 ) { //Create second finger if this is the first time... createFingerData ( 1 , touches [ 1 ] ) ; startTouchesDistance = endTouchesDistance = calculateTouchesDistance ( fingerData [ 0 ] . start , fingerData [ 1 ] . start ) ; } else { //Else just update the second finger updateFingerData ( touches [ 1 ] ) ; endTouchesDistance = calculateTouchesDistance ( fingerData [ 0 ] . end , fingerData [ 1 ] . end ) ; pinchDirection = calculatePinchDirection ( fingerData [ 0 ] . end , fingerData [ 1 ] . end ) ; } pinchZoom = calculatePinchZoom ( startTouchesDistance , endTouchesDistance ) ; pinchDistance = Math . abs ( startTouchesDistance - endTouchesDistance ) ; } if ( ( fingerCount === options . fingers || options . fingers === ALL_FINGERS ) || ! touches || hasPinches ( ) ) { direction = calculateDirection ( currentFinger . start , currentFinger . end ) ; //Check if we need to prevent default event (page scroll / pinch zoom) or not validateDefaultEvent ( jqEvent , direction ) ; //Distance and duration are all off the main finger distance = calculateDistance ( currentFinger . start , currentFinger . end ) ; duration = calculateDuration ( ) ; //Cache the maximum distance we made in this direction setMaxDistance ( direction , distance ) ; if ( options . swipeStatus || options . pinchStatus ) { ret = triggerHandler ( event , phase ) ; } //If we trigger end events when threshold are met, or trigger events when touch leaves element if ( ! options . triggerOnTouchEnd || options . triggerOnTouchLeave ) { var inBounds = true ; //If checking if we leave the element, run the bounds check (we can use touchleave as its not supported on webkit) if ( options . triggerOnTouchLeave ) { var bounds = getbounds ( this ) ; inBounds = isInBounds ( currentFinger . end , bounds ) ; } //Trigger end handles as we swipe if thresholds met or if we have left the element if the user has asked to check these.. if ( ! options . triggerOnTouchEnd && inBounds ) { phase = getNextPhase ( PHASE_MOVE ) ; } //We end if out of bounds here, so set current phase to END, and check if its modified  else if ( options . triggerOnTouchLeave && ! inBounds ) { phase = getNextPhase ( PHASE_END ) ; } if ( phase == PHASE_CANCEL || phase == PHASE_END ) { triggerHandler ( event , phase ) ; } } } else { phase = PHASE_CANCEL ; triggerHandler ( event , phase ) ; } if ( ret === false ) { phase = PHASE_CANCEL ; triggerHandler ( event , phase ) ; } }
Event handler for a touch move event.
If we change fingers during move, then cancel the event
@inner
@param {object} jqEvent The normalised jQuery event object.
Event handler for a touch move event . If we change fingers during move then cancel the event