/*lazy-load*/ var lazy_options = { rootMargin: "80% 0px", // 画面内に入る直前にイベントが起こるように,画面領域にマージンを設ける } var lazyImages = document.querySelectorAll(".lazy-load"); var imagesArray = Array.prototype.slice.call(lazyImages, 0); imagesArray.forEach(function (target) { var io = new IntersectionObserver(function (entries, observer) { entries.forEach(function (entry) { if (entry.isIntersecting) { var img = entry.target; var src = img.getAttribute('data-lazy'); img.setAttribute('src', src); observer.disconnect(); } }); }, lazy_options); io.observe(target); });