From 9c77089a5e41970d1f940abff4d9600db62019f3 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Thu, 22 May 2014 17:53:24 -0500 Subject: [PATCH] feat(scrollView): better deceleration for scroll view on iOS --- js/angular/controller/scrollController.js | 10 +++++++++- js/views/scrollView.js | 8 +++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/js/angular/controller/scrollController.js b/js/angular/controller/scrollController.js index 16975a5b5cb..7e58677326c 100644 --- a/js/angular/controller/scrollController.js +++ b/js/angular/controller/scrollController.js @@ -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 { + } }); } diff --git a/js/views/scrollView.js b/js/views/scrollView.js index efce14b0176..6efce93ebe2 100644 --- a/js/views/scrollView.js +++ b/js/views/scrollView.js @@ -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;