Skip to content

Commit

Permalink
fix(scrollView): if bouncing past boundaries, do not stick.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ajoslin committed Feb 3, 2014
1 parent 04c8336 commit 59c10d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/views/scrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2003,15 +2003,15 @@ 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;
}
}

if (scrollOutsideY !== 0) {
if (scrollOutsideY * self.__decelerationVelocityY <= 0) {
if (scrollOutsideY * self.__decelerationVelocityY <= self.__minDecelerationScrollTop) {
self.__decelerationVelocityY += scrollOutsideY * penetrationDeceleration;
} else {
self.__decelerationVelocityY = scrollOutsideY * penetrationAcceleration;
Expand Down

0 comments on commit 59c10d4

Please sign in to comment.