Skip to content

Commit

Permalink
feat(scrollView): better deceleration for scroll view on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mlynch committed May 22, 2014
1 parent e9f7592 commit 9c77089
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion js/angular/controller/scrollController.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ function($scope, scrollViewOptions, $timeout, $window, $$scrollValueCache, $loca

if (!angular.isDefined(scrollViewOptions.bouncing)) {
ionic.Platform.ready(function() {
scrollView.options.bouncing = !ionic.Platform.isAndroid();
scrollView.options.bouncing = true;

if(ionic.Platform.isAndroid()) {
// No bouncing by default on Android
scrollView.options.bouncing = false;
// Faster scroll decel
scrollView.options.deceleration = 0.95;
} else {
}
});
}

Expand Down
8 changes: 5 additions & 3 deletions js/views/scrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ ionic.views.Scroll = ionic.views.View.inherit({
/** Multiply or decrease scrolling speed **/
speedMultiplier: 1,

deceleration: 0.97,

/** Callback that is fired on the later of touch end or deceleration end,
provided that another scrolling action has not begun. Used to know
when to fade out a scrollbar. */
Expand Down Expand Up @@ -2143,8 +2145,8 @@ ionic.views.Scroll = ionic.views.View.inherit({
//

// Add deceleration to scroll position
var scrollLeft = self.__scrollLeft + self.__decelerationVelocityX;
var scrollTop = self.__scrollTop + self.__decelerationVelocityY;
var scrollLeft = self.__scrollLeft + self.__decelerationVelocityX;// * self.options.deceleration);
var scrollTop = self.__scrollTop + self.__decelerationVelocityY;// * self.options.deceleration);


//
Expand Down Expand Up @@ -2194,7 +2196,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
// This is the factor applied to every iteration of the animation
// to slow down the process. This should emulate natural behavior where
// objects slow down when the initiator of the movement is removed
var frictionFactor = 0.95;
var frictionFactor = self.options.deceleration;

self.__decelerationVelocityX *= frictionFactor;
self.__decelerationVelocityY *= frictionFactor;
Expand Down

0 comments on commit 9c77089

Please sign in to comment.