Created
January 17, 2014 01:40
-
-
Save AshKyd/8467030 to your computer and use it in GitHub Desktop.
Is the document scrolling right now? Prevent jank by pausing stuff while the user's trying to navigate the document.
This file contains 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
var isScrolling = false; | |
$(document).ready(function(){ | |
var scrollTimeout = false; | |
var scrollTimeoutFn = function(){ | |
isScrolling=false; | |
scrollTimeout = false; | |
} | |
jQuery(window).bind('scroll', function(){ | |
isScrolling = true; | |
if(scrollTimeout){ | |
window.clearTimeout(scrollTimeout); | |
} | |
scrollTimeout = window.setTimeout(scrollTimeoutFn,300); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment