Skip to content

Instantly share code, notes, and snippets.

@Demwunz
Created March 30, 2012 14:21
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 Demwunz/2251871 to your computer and use it in GitHub Desktop.
Save Demwunz/2251871 to your computer and use it in GitHub Desktop.
jQuery : inview psuedo-selector
//this is straight from http://forrst.com/posts/jQuery_inview_selector-V2Q
$.extend($.expr[':'], {
inview: function(el) {
var e = $(el),
w = $(window),
wt = w.scrollTop(),
wb = wt + w.height(),
et = e.offset().top,
eb = et + e.height();
return eb >= wt && et <= wb;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment