brito101 / Fade

Class for applying the "fade" effect in DOM sections.

Home Page:https://www.rodrigobrito.dev.br/blog/js-e05-efeito-fade-com-javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fade

Example of use

  • Selecting DOM elements with the "fadeInScroll" class (can be any tag) and importing the class (import Fade from...) or in the same file:
  • Selecionando elementos do DOM com a classe "fadeInScrool" (pode ser qualquer tag) e importando a classe (import Fade from...) ou no mesmo arquivo:
const fadeInScroll = document.querySelectorAll(".fadeInScroll");
const fade = new Fade(fadeInScroll);
fade.init();
  • Adding to browser window "scroll" event with debounce:
  • Adicionando ao evento de "scroll" da janela do navegador com debounce:
window.addEventListener("scroll", () => {
    let timer;
    if (timer) clearTimeout(timer);
    timer = setTimeout(() => {
      fade.checkFades();
      timer = null;
    }, 200);
  });

About

Class for applying the "fade" effect in DOM sections.

https://www.rodrigobrito.dev.br/blog/js-e05-efeito-fade-com-javascript

License:MIT License


Languages

Language:JavaScript 100.0%