Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukapaunovic/412261dde45dd955161ec747935a2380 to your computer and use it in GitHub Desktop.
Save lukapaunovic/412261dde45dd955161ec747935a2380 to your computer and use it in GitHub Desktop.
jQuery.fn.isInViewport = function() {
var elementTop = jQuery(this).offset().top;
var elementBottom = elementTop + jQuery(this).outerHeight();
var viewportTop = jQuery(window).scrollTop();
var viewportBottom = viewportTop + jQuery(window).height();
return elementBottom > viewportTop && elementTop < viewportBottom;
};
window.lazyprocess = 'yes';
jQuery(window).on('resize scroll', function() {
if (jQuery('.et_pb_section_6').isInViewport()) {
if (window.lazyprocess == 'yes') {
window.lazyprocess = 'no';
jQuery('div.et_pb_section.et_pb_section_7').css('background-image', 'linear-gradient(272deg,rgba(0,25,93,0.17) -2%,rgba(0,25,93,0.95) 82%),url(https://infocus.org/wp-content/uploads/2020/03/giffocus.gif)');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment