Skip to content

Instantly share code, notes, and snippets.

@FibreFoX
Created March 19, 2013 20:26
Show Gist options
  • Save FibreFoX/5199783 to your computer and use it in GitHub Desktop.
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
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