Skip to content

Instantly share code, notes, and snippets.

@prashnts
Created October 17, 2015 20:56
Show Gist options
  • Save prashnts/9d9151183a99e13427c8 to your computer and use it in GitHub Desktop.
Save prashnts/9d9151183a99e13427c8 to your computer and use it in GitHub Desktop.
$.scrollWindowTo = function(pos, duration, cb) {
if (duration == null) {
duration = 0;
}
if (pos === $(window).scrollTop()) {
$(window).trigger('scroll');
if (typeof cb === "function") {
cb();
}
return;
}
return $('html, body').animate({
scrollTop: pos
}, duration, function() {
return typeof cb === "function" ? cb() : void 0;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment