Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 8, 2019 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/248fbcb7120260a5528457d7e22a17da to your computer and use it in GitHub Desktop.
Save parzibyte/248fbcb7120260a5528457d7e22a17da to your computer and use it in GitHub Desktop.
if ("undefined" !== typeof IntersectionObserver) {
var observador = new IntersectionObserver(function (entradas) {
for (var i = 0; i < entradas.length; entradas++) {
var entrada = entradas[i];
if (entrada.intersectionRatio > 0) {
var imagen = entrada.target;
imagen.src = imagen.dataset.src;
observador.unobserve(imagen);
}
}
});
} else {
for (var j = 0; j < $imagenes.length; j++) {
$imagenes[j].src = $imagenes[j].dataset.src;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment