Created
March 8, 2015 00:20
-
-
Save msrafi/0f2037112a5d311d9577 to your computer and use it in GitHub Desktop.
Javascript: isVisible
This file contains hidden or 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 isVisible(el) { | |
// get offset | |
var y = getOffset(el, 'offsetTop'); | |
// convert to screen coordinate | |
y = y - window.scrollY; | |
var height = el.clientHeight; | |
var windowHeight = window.innerHeight; | |
return (y + height > 0 && y < windowHeight); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment