Revision: 64095
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 3, 2013 22:50 by jbernus
Initial Code
var checkViewport = function(el){ var minTop = jQuery(document).scrollTop(), minLeft = jQuery(document).scrollLeft(), maxTop = minTop + jQuery(window).height(), maxLeft = minLeft + jQuery(window).width(), $myElement = el, elementOffset = $myElement.offset(), elementHeight = $myElement.height(), elementWidth = $myElement.width(); if ( (elementOffset.top > minTop && elementOffset.top + elementHeight < maxTop) && (elementOffset.left > minLeft && elementOffset.left + elementWidth < maxLeft) ) { console.log('entire element is visible'); } else { console.log('entire element is not visible'); } }
Initial URL
Initial Description
Copied from somewhere, probably stackoverflow.
Initial Title
Check if element is in the wieport
Initial Tags
Initial Language
JavaScript