Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let images = document.querySelectorAll(".imageObserve");
- let observer = new IntersectionObserver((images) => {
- images.forEach((image) => {
- if (image.isIntersecting) {
- image.target.src = image.target.dataset.src;
- }
- })
- }, {
- root: null,
- rootMargin: "0px",
- threshold: 0.5
- });
- images.forEach((image) => {
- observer.observe(image);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement