Last active
December 8, 2016 07:15
-
-
Save alexeykomov/d27ebc94b1f302d03baf5ba7957d199b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rflect.ui.MomentumScroller.prototype.doMomentum = function() { | |
// Calculate the movement properties. Implement getEndVelocity using the | |
// start and end position / time. | |
var velocity = this.getEndVelocity(); | |
if (velocity != 0) { | |
var acceleration = this.getAcceleration(velocity); | |
var displacement = - (velocity * velocity) / (2 * acceleration); | |
var time = - velocity / acceleration; | |
var newY = this.contentOffsetY + displacement; | |
if (this.positionIsOutOfBounds(newY)) { | |
this.setUpTransitionStage1(); | |
} else { | |
// Set up the transition and execute the transform. Once you implement this | |
// you will need to figure out an appropriate time to clear the transition | |
// so that it doesn’t apply to subsequent scrolling. | |
let transition = | |
rflect.browser.css.getSelectorCasedProperty('transform') + ' ' + | |
time + 'ms cubic-bezier(0.33, 0.66, 0.66, 1)'; | |
rflect.browser.css.setTransition(this.element, transition); | |
rflect.browser.css.setTransition(this.getScrollBarContainer(), transition); | |
this.contentOffsetY = newY; | |
rflect.browser.css.setTransform(this.element, | |
`translate3d(0, ${newY}px, 0)`); | |
rflect.browser.css.setTransform(this.getScrollBarContainer(), | |
`translate3d(0, ${-(newY / this.getSizeRatio() - | |
this.getScrollBarLineHeight() / 2)}px, 0)`); | |
} | |
this.isDecelerating_ = true; | |
} else { | |
this.showScrollBarDelayed(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment