If in view

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

$(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
    }
  });
});

Demo with sections.

Leave a Reply

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

63 + = 65

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