If in view

Check if an element is in view using only JQuery.
A sort of poor man’s Waypoints.

Demo with sections.

$(window).on('load scroll', function() {
  $('.element').each(function() {
    if ( $(this).offset().top <= ($(window).scrollTop() + $(window).height()/2)) {
     // in view (in the upper half of the screen)
    } else {
     // not in view
    }
  });
});

Leave a Reply

Your email address will not be published. Required fields are marked *

40 − = 31

This site uses Akismet to reduce spam. Learn how your comment data is processed.