From eed6b19b519864b7b6a4cc4ef194be5423dde710 Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Tue, 11 Feb 2014 14:38:02 -0500 Subject: [PATCH] fix(scrollView): start scroll again if it stops beyond boundaries Addresses #482 --- js/views/scrollView.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/js/views/scrollView.js b/js/views/scrollView.js index eb9d21b4095..0dc551253c0 100644 --- a/js/views/scrollView.js +++ b/js/views/scrollView.js @@ -2024,17 +2024,23 @@ ionic.views.Scroll = ionic.views.View.inherit({ // Slow down until slow enough, then flip back to snap position if (scrollOutsideX !== 0) { - if (scrollOutsideX * self.__decelerationVelocityX <= self.__minDecelerationScrollLeft) { + var isHeadingOutwardsX = scrollOutsideX * self.__decelerationVelocityX <= self.__minDecelerationScrollLeft; + if (isHeadingOutwardsX) { self.__decelerationVelocityX += scrollOutsideX * penetrationDeceleration; - } else { + } + //If we're not heading outwards, or if the above statement got us below minDeceleration, go back towards bounds + if (!isHeadingOutwardsX || self.__decelerationVelocityX <= self.__minDecelerationScrollLeft) { self.__decelerationVelocityX = scrollOutsideX * penetrationAcceleration; } } if (scrollOutsideY !== 0) { - if (scrollOutsideY * self.__decelerationVelocityY <= self.__minDecelerationScrollTop) { + var isHeadingOutwardsY = scrollOutsideY * self.__decelerationVelocityY <= self.__minDecelerationScrollTop; + if (isHeadingOutwardsY) { self.__decelerationVelocityY += scrollOutsideY * penetrationDeceleration; - } else { + } + //If we're not heading outwards, or if the above statement got us below minDeceleration, go back towards bounds + if (!isHeadingOutwardsY || self.__decelerationVelocityY <= self.__minDecelerationScrollTop) { self.__decelerationVelocityY = scrollOutsideY * penetrationAcceleration; } }