Created
May 19, 2017 19:49
-
-
Save joaomosantos/c6139f098167433ce59b779f5c9c8016 to your computer and use it in GitHub Desktop.
Elemento visível ao window
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 isOnScreen(el) { | |
var win = $(window); | |
var winTop = win.scrollTop(); | |
var winBottom = winTop + win.height(); | |
var elTop = el.offset().top; | |
var elBottom = elTop + el.height(); | |
return winTop <= elBottom && winBottom >= elTop; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment