1function isOnScreen(elem) {
2 // if the element doesn't exist, abort
3 if( elem.length == 0 ) {
4 return;
5 }
6 var $window = jQuery(window)
7 var viewport_top = $window.scrollTop()
8 var viewport_height = $window.height()
9 var viewport_bottom = viewport_top + viewport_height
10 var $elem = jQuery(elem)
11 var top = $elem.offset().top
12 var height = $elem.height()
13 var bottom = top + height
14
15 return (top >= viewport_top && top < viewport_bottom) ||
16 (bottom > viewport_top && bottom <= viewport_bottom) ||
17 (height > viewport_height && top <= viewport_top && bottom >= viewport_bottom)
18}
19
20jQuery( document ).ready( function() {
21 window.addEventListener('scroll', function(e) {
22 if( isOnScreen( jQuery( '.shipping-logos' ) ) ) { /* Pass element id/class you want to check */
23 alert( 'The specified container is in view.' );
24 }
25 });
26});