Created
March 22, 2013 09:00
-
-
Save FibreFoX/5219896 to your computer and use it in GitHub Desktop.
if you have jQuery and want to detect if something is partly 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 isPartlyInViewPort($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 isAboveViewPort = entryVisibleBottom < windowScrollTop; | |
var isBelowViewPort = windowVisibleBottom < entryTop; | |
return !(isAboveViewPort || isBelowViewPort); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment