Skip to content

Instantly share code, notes, and snippets.

@jesgundy
Created June 18, 2014 15:39
Show Gist options
  • Save jesgundy/0c6bd62d1f426f75fcac to your computer and use it in GitHub Desktop.
Save jesgundy/0c6bd62d1f426f75fcac to your computer and use it in GitHub Desktop.
Check Visible - jQuery function to test presence of element on screen.
function checkvisible( elm ) {
var vph = $(window).height(), // Viewport Height
st = $(window).scrollTop(), // Scroll Top
y = $(elm).offset().top;
// test if element is on screen or has been scrolled past
return (y < (vph + st));
// test if element is on screen
// return (y > st) && (y < (vph + st));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment