Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 25, 2019 23:08
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/14468721d46f8fa965e0a2fe50819c41 to your computer and use it in GitHub Desktop.
Save parzibyte/14468721d46f8fa965e0a2fe50819c41 to your computer and use it in GitHub Desktop.
const cargarIconos = () => {
const linkIconos = document.createElement("link");
linkIconos.rel = "stylesheet";
linkIconos.href = "https://cdn.jsdelivr.net/npm/devicons@1.8.0/css/devicons.min.css";
document.head.insertBefore(linkIconos, document.head.childNodes[document.head.childNodes.length - 1].nextSibling);
};
const $seccionHabilidades = document.querySelector("#habilidades");
const observadorIconos = new IntersectionObserver(elementos => {
elementos.forEach(elemento => {
if (elemento.intersectionRatio > 0) {
cargarIconos();
observadorIconos.unobserve($seccionHabilidades);
}
});
});
observadorIconos.observe($seccionHabilidades);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment