Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. let images = document.querySelectorAll(".imageObserve");
  2.  
  3. let observer = new IntersectionObserver((images) => {
  4. images.forEach((image) => {
  5. if (image.isIntersecting) {
  6. image.target.src = image.target.dataset.src;
  7. }
  8. })
  9. }, {
  10. root: null,
  11. rootMargin: "0px",
  12. threshold: 0.5
  13. });
  14.  
  15. images.forEach((image) => {
  16. observer.observe(image);
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement