Skip to content

Instantly share code, notes, and snippets.

@danheberden
Created January 13, 2011 16:32
Show Gist options
  • Save danheberden/778141 to your computer and use it in GitHub Desktop.
Save danheberden/778141 to your computer and use it in GitHub Desktop.
Find what the hell to scroll
var $docEl = $( document.documentElement ),
$body = $( document.body ),
// if docEl has a scrollTop, well, that kinda answers our question
$scrollable = $docEl.scrollTop() ? $docEL :
$body.scrollTop( $body.scrollTop() + 1 ).scrollTop() ? $body : $docEl;
// its like we can already tell!
if ( windowST ) {
$scrollable = $docEl;
}else {
// if adding one to body doesn't help us out, we're in docEl land
if ( !$scrollable.scrollTop( bodyST + 1 ).scrollTop() ) {
$scrollable = $docEl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment