Created
October 17, 2015 20:56
-
-
Save prashnts/9d9151183a99e13427c8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$.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