diff --git a/lib/ftscroller.js b/lib/ftscroller.js index dfa7a68..8c51450 100644 --- a/lib/ftscroller.js +++ b/lib/ftscroller.js @@ -381,7 +381,9 @@ var FTScroller, CubicBezier; 'segmentdidchange': [], 'reachedstart': [], 'reachedend': [], - 'scrollinteractionend': [] + 'scrollinteractionend': [], + 'onBounce': [], + 'beforeBounce': [] }; // MutationObserver instance, when supported and if DOM change sniffing is enabled @@ -1141,6 +1143,7 @@ var FTScroller, CubicBezier; // Amend the positions and bezier curve if necessary if (bounceDistance) { + var bounceDistanceOrig = bounceDistance; // If the fling moves the scroller beyond the normal scroll bounds, and // the bounce is snapping the scroll back after the fling: @@ -1235,6 +1238,7 @@ var FTScroller, CubicBezier; bounceDistance = 0; bounceDuration = 0; } + _fireEvent('onBounce', { bounceDistance: bounceDistanceOrig, flingPosition: flingPosition, bounceTarget: bounceTarget, movementSpeed: movementSpeed }); } // If no fling or bounce is required, continue @@ -1790,6 +1794,7 @@ var FTScroller, CubicBezier; _setAxisPosition = function _setAxisPosition(axis, position, animationDuration, animationBezier, boundsCrossDelay) { var transitionCSSString, newPositionAtExtremity = null; + _fireEvent('beforeBounce', { flingDistance: position }); // Only update position if the axis node exists (DOM elements can go away if // the scroller instance is not destroyed correctly) if (!_scrollNodes[axis]) { @@ -2179,16 +2184,18 @@ var FTScroller, CubicBezier; _onTouchStart = function _onTouchStart(startEvent) { var i, l, touchEvent; - // If a touch is already active, ensure that the index - // is mapped to the correct finger, and return. - if (_inputIdentifier) { - for (i = 0, l = startEvent.touches.length; i < l; i = i + 1) { - if (startEvent.touches[i].identifier === _inputIdentifier) { - _inputIndex = i; - } - } - return; - } + startEvent.stopPropagation(); + + // If a touch is already active, ensure that the index + // is mapped to the correct finger, and return. + if (_inputIdentifier) { + for (i = 0, l = startEvent.touches.length; i < l; i = i + 1) { + if (startEvent.touches[i].identifier === _inputIdentifier) { + _inputIndex = i; + } + } + return; + } // Track the new touch's identifier, reset index, and pass // the coordinates to the scroll start function.