Skip to content

Instantly share code, notes, and snippets.

@dana-ross
Last active August 29, 2015 14:08
Show Gist options
  • Save dana-ross/61796b455d8c5b50fc47 to your computer and use it in GitHub Desktop.
Save dana-ross/61796b455d8c5b50fc47 to your computer and use it in GitHub Desktop.
((function ($) {
$.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;
});
};
})(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment