Created
July 9, 2016 17:46
-
-
Save codyogden/0355d64674039a181686a3a6d6480fe2 to your computer and use it in GitHub Desktop.
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
/* jQuery plugin that tells if the element is in the viewport */ | |
$.fn.inVP = function(){ | |
var element = this.get(0); | |
var bounds = element.getBoundingClientRect(); | |
return bounds.top < window.innerHeight && bounds.bottom > 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment