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