Check If an Element is in Viewport

$.fn.isInViewport = function () {
    var elementTop = $(this).offset().top;
    var elementBottom = elementTop + $(this).outerHeight();
    var viewportTop = $(window).scrollTop();
    var viewportBottom = viewportTop + $(window).height();
    return elementBottom & gt; viewportTop & amp;& amp; elementTop & lt; viewportBottom;
};

$(window).on('scroll', function () {
    if ($('.element-name').isInViewport()) {
        // Do Something
    } else {
        // Do Something
    }
});
Jhon dow

Showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer gregor then turned

5 Comments

  1. Shown says Nov 27, 2019 at 9:00am

    Hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer gregor then

    • Shown says Nov 27, 2019 at 9:00am

      Hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer gregor then

      • Shown says Nov 27, 2019 at 9:00am

        Hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer gregor then

  2. Shown says Nov 27, 2019 at 9:00am

    Hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer gregor then

Add your comment