fix(scroll): do not click when scroll decelerating

Closes #1438, #2223, #2665
This commit is contained in:
Adam Bradley
2015-02-09 14:04:57 -06:00
parent 9416d7d7fa
commit e8a70f3701

View File

@@ -793,7 +793,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
self.touchEnd = function(e) {
if (!self.__isDown) return;
self.doTouchEnd(e.timeStamp);
self.doTouchEnd(e, e.timeStamp);
self.__isDown = false;
self.__hasStarted = false;
self.__isSelectable = true;
@@ -865,7 +865,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
return;
}
self.doTouchEnd(e.timeStamp);
self.doTouchEnd(e, e.timeStamp);
mousedown = false;
};
@@ -1630,6 +1630,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
doTouchStart: function(touches, timeStamp) {
var self = this;
// remember if the deceleration was just stopped
self.__decStopped = !!(self.__isDecelerating || self.__isAnimating);
self.hintResize();
if (timeStamp instanceof Date) {
@@ -1747,6 +1750,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
// Are we already is dragging mode?
if (self.__isDragging) {
self.__decStopped = false;
// Compute move distance
var moveX = currentTouchLeft - self.__lastTouchLeft;
@@ -1912,7 +1916,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
/**
* Touch end handler for scrolling support
*/
doTouchEnd: function(timeStamp) {
doTouchEnd: function(e, timeStamp) {
if (timeStamp instanceof Date) {
timeStamp = timeStamp.valueOf();
}
@@ -1982,6 +1986,13 @@ ionic.views.Scroll = ionic.views.View.inherit({
} else if ((timeStamp - self.__lastTouchMove) > 100) {
self.__scrollingComplete();
}
} else if (self.__decStopped) {
// the deceleration was stopped
// user flicked the scroll fast, and stop dragging, then did a touchstart to stop the srolling
// tell the touchend event code to do nothing, we don't want to actually send a click
e.isTapHandled = true;
self.__decStopped = false;
}
// If this was a slower move it is per default non decelerated, but this