Skip to content

Instantly share code, notes, and snippets.



Last active Sep 14, 2018
What would you like to do?
Scroll page via jQuery without invoking callback twice
//we use a promise so that callback is not invoked twice
$('html, body').animate({
scrollTop: top
}, 1000).promise().then(function() {
if (callback) {
//use setTimeout to make sure callback is invoked after all scroll event handlers in stack have executed
setTimeout(callback, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.