Created
June 2, 2016 14:57
-
-
Save alexeykomov/5181836ee013465bd85f825dac9a7a5e to your computer and use it in GitHub Desktop.
Snap to bounds
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.snapToBounds = function() { | |
const transition = rflect.browser.css.getSelectorCasedProperty('transform') + | |
' ' + 500 + 'ms ease-out'; | |
this.setTransitionAll(transition); | |
// Different out of bounds cases: | |
// 1. If content is lower than frame upper border | |
if (this.contentOffsetY > 0) { | |
this.contentOffsetY = 0; | |
rflect.browser.css.setTransform(this.getScrollBarContainer(), | |
`translate3d(0, ${(this.getScrollBarLineHeight() / 2)}px, 0)`); | |
} | |
else { | |
// 2. If content is higher that frame lower border. | |
this.contentOffsetY = this.getLowestContentPosition(); | |
rflect.browser.css.setTransform(this.getScrollBarContainer(), | |
`translate3d(0, ${this.frameElementSize.height - | |
this.getScrollBarLineHeight() / 2}px, 0)`); | |
} | |
rflect.browser.css.setTransform(this.element, | |
`translate3d(0, ${this.contentOffsetY}px, 0)`); | |
rflect.browser.css.setTransform(this.getScrollBarLine(), | |
`scaleY(${this.getScrollBarLineHeight()})`); | |
this.isDecelerating_ = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment