Skip to content

Instantly share code, notes, and snippets.

@avhm
Created November 17, 2010 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save avhm/703244 to your computer and use it in GitHub Desktop.
Save avhm/703244 to your computer and use it in GitHub Desktop.
jquery onscreen / offscreen selector
$.expr[':'].onscreen = function(obj){
var $win = $(window), pos = $(obj).position();
return $.contains(document.documentElement, obj) && pos.top < $win.height() && pos.left < $win.width();
};
$.expr[':'].offscreen = function(obj){
return !$(obj).is(':onscreen');
};
@avhm
Copy link
Author

avhm commented Nov 17, 2010

Awesomeness provided by Lennym!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment