SHARE
TWEET

Untitled

a guest Feb 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.addEventListener("DOMContentLoaded", function() {
  2.     var lazyImages = document.querySelectorAll('img[lazy-images');
  3.     function handlerLazyLoadImages() {
  4.         Array.prototype.forEach.call(lazyImages, function(img) {
  5.             if ((img.getBoundingClientRect().top <= window.innerHeight && img.getBoundingClientRect().bottom >= 0) && getComputedStyle(img).display != 'none') {
  6.                 img.setAttribute('src', img.getAttribute('lazy-images'));
  7.                 img.removeAttribute('lazy-images');
  8.             }
  9.         });
  10.         lazyImages = document.querySelectorAll('img[lazy-images');
  11.     }
  12.     handlerLazyLoadImages();
  13.     document.addEventListener('scroll', handlerLazyLoadImages);
  14.     window.addEventListener("resize", handlerLazyLoadImages);
  15.     window.addEventListener("orientationchange", handlerLazyLoadImages);
  16. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top