Created
March 19, 2013 20:26
-
-
Save FibreFoX/5199783 to your computer and use it in GitHub Desktop.
if you have jQuery and want to detect if something is totally shown, just use this here
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 isTotallyInViewPort($entry){ | |
var windowScrollTop = $(window).scrollTop(); | |
var windowHeight = $(window).height(); | |
var windowVisibleBottom = windowScrollTop + windowHeight; | |
var entryTop = $entry.offset().top; | |
var entryOuterHeight = $entry.outerHeight(); | |
var entryVisibleBottom = entryTop + entryOuterHeight; | |
var isInView = windowScrollTop < ( entryTop ) < (windowVisibleBottom); | |
if(!isInView) return false; | |
var isCompleteInView = ( entryVisibleBottom ) < (windowVisibleBottom); | |
return isCompleteInView; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment