Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to detect a section is visible in 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 medium.com #
 
PREVIOUS NEXT
Tagged: #detect #section #visible #jquery
ADD COMMENT
Topic
Name
4+4 =