Skip to content

Instantly share code, notes, and snippets.

@leobalter
Created March 26, 2012 14:53
Show Gist options
  • Save leobalter/2205654 to your computer and use it in GitHub Desktop.
Save leobalter/2205654 to your computer and use it in GitHub Desktop.
jQuery Inview
$.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