Created
January 25, 2019 23:16
-
-
Save parzibyte/2d2fdec352cde0fa1d6832b9f30a63b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const observadorImagenes = new IntersectionObserver(function (entradas) { | |
for (let i = 0; i < entradas.length; entradas++) { | |
const entrada = entradas[i]; | |
if (entrada.intersectionRatio > 0) { | |
const imagenes = entrada.target.querySelectorAll("img"); | |
imagenes.forEach(imagen => { | |
imagen.src = imagen.dataset.src; | |
}); | |
observadorImagenes.unobserve(entrada.target); | |
} | |
} | |
}, opciones); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment