Skip to content

Instantly share code, notes, and snippets.

@aubricus
Created July 15, 2013 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aubricus/6002683 to your computer and use it in GitHub Desktop.
Save aubricus/6002683 to your computer and use it in GitHub Desktop.
Check for scrollable element using jQuery.
/**
* Test to get correct scrollable element
* @return {string}
* @see http://www.zachstronaut.com/posts/2009/01/18/jquery-smooth-scroll-bugs.html (updated to use $.scrollTop())
* @requires jquery 1.7+
*/
getScrollable = function(){
var result = 'html, body',
initScrollTop;
$('html, body').each(function(){
var $this = $(this);
initScrollTop = $this.scrollTop();
$this.scrollTop(initScrollTop +1);
if($this.scrollTop() === initScrollTop + 1){
result = this.nodeName.toLowerCase();
$this.scrollTop(initScrollTop);
return result;
}
});
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment