Skip to content

Commit

Permalink
fix(scroll): do not click when scroll decelerating
Browse files Browse the repository at this point in the history
Closes #1438, #2223, #2665
  • Loading branch information
adamdbradley committed Feb 9, 2015
1 parent 9416d7d commit e8a70f3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions js/views/scrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -865,7 +865,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
return;
}

self.doTouchEnd(e.timeStamp);
self.doTouchEnd(e, e.timeStamp);

mousedown = false;
};
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e8a70f3

Please sign in to comment.