mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(scrollView): better deceleration for scroll view on iOS
This commit is contained in:
10
js/angular/controller/scrollController.js
vendored
10
js/angular/controller/scrollController.js
vendored
@@ -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 {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user