From 59c10d4f92676910d6260adae81fa8bf89ffca14 Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Mon, 3 Feb 2014 12:06:33 -0500 Subject: [PATCH] fix(scrollView): if bouncing past boundaries, do not stick. Closes #482 Zynga Scroller slowly lowers the acceleration of scroll as soon as you pass the boundaries. Once the acceleration reaches zero, zynga will 'flip' the acceleration in the other direction and scroll back to within the boundaries (bounce effect). The problem is, sometimes as it slowly lowers the acceleration it will get *near zero*, but not reach zero. When acceleration gets close enough to zero, zynga stops the scrolling because it deems it 'too slow'. Now, the scrolling acceleration will 'flip' and go back towards being in boundaries (bounce) when the scrolling is below a certain minimum, not just when it is below zero. --- js/views/scrollView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/views/scrollView.js b/js/views/scrollView.js index 037ccf354d..5e03e3a8c0 100644 --- a/js/views/scrollView.js +++ b/js/views/scrollView.js @@ -2003,7 +2003,7 @@ 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 <= 0) { + if (scrollOutsideX * self.__decelerationVelocityX <= self.__minDecelerationScrollLeft) { self.__decelerationVelocityX += scrollOutsideX * penetrationDeceleration; } else { self.__decelerationVelocityX = scrollOutsideX * penetrationAcceleration; @@ -2011,7 +2011,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ } if (scrollOutsideY !== 0) { - if (scrollOutsideY * self.__decelerationVelocityY <= 0) { + if (scrollOutsideY * self.__decelerationVelocityY <= self.__minDecelerationScrollTop) { self.__decelerationVelocityY += scrollOutsideY * penetrationDeceleration; } else { self.__decelerationVelocityY = scrollOutsideY * penetrationAcceleration;