Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to determin if element is in viewport with jquery

$.fn.isInViewport = function() {
    var elementTop = $(this).offset().top;
    var elementBottom = elementTop + $(this).outerHeight();

    var viewportTop = $(window).scrollTop();
    var viewportBottom = viewportTop + $(window).height();

    return elementBottom > viewportTop && elementTop < viewportBottom;
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #determin #element #viewport #jquery
ADD COMMENT
Topic
Name
6+8 =