Skip to content

Instantly share code, notes, and snippets.

@FibreFoX
Created March 22, 2013 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FibreFoX/5219896 to your computer and use it in GitHub Desktop.
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
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