Skip to content

Instantly share code, notes, and snippets.

@daihuaye
Last active August 29, 2015 14:08
Show Gist options
  • Save daihuaye/0c402027403535eab7a5 to your computer and use it in GitHub Desktop.
Save daihuaye/0c402027403535eab7a5 to your computer and use it in GitHub Desktop.
Get height to the document top after scroll and set set to top
var getScrollTop = function() {
if(_isMobile) {
return _mobileOffset;
} else {
return window.pageYOffset || documentElement.scrollTop || body.scrollTop || 0;
}
};
var setScrollTop = function(top, force) {
_forceRender = (force === true);
if(_isMobile) {
_mobileOffset = Math.min(Math.max(top, 0), _maxKeyFrame);
} else {
window.scrollTo(0, top);
}
return _instance;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment