feat(scrollView): better deceleration for scroll view on iOS

This commit is contained in:
Max Lynch
2014-05-22 17:53:24 -05:00
parent e9f7592310
commit 9c77089a5e
2 changed files with 14 additions and 4 deletions

View File

@@ -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 {
}
});
}

View File

@@ -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. */
@@ -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);
//
@@ -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;