Created
June 18, 2014 15:39
-
-
Save jesgundy/0c6bd62d1f426f75fcac to your computer and use it in GitHub Desktop.
Check Visible - jQuery function to test presence of element on screen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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