MendiTopala

Untitled

Aug 4th, 2021
689
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const ANIMATEDCLASSNAME = "animated";
  2. const ELEMENTS = document.querySelectorAll(".btn_ripple");
  3. const ELEMENTS_SPAN = [];
  4. ELEMENTS.forEach((element, index) => {
  5.   let addAnimation = false;
  6.   if (element.classList[1] == "FLASH") {
  7.     element.addEventListener("animationend", e => {
  8.       element.classList.remove(ANIMATEDCLASSNAME);
  9.     });
  10.     addAnimation = true;
  11.   }
  12.   if (!ELEMENTS_SPAN[index])
  13.     ELEMENTS_SPAN[index] = element.querySelector("span");
  14.  
  15.   element.addEventListener("mouseover", e => {
  16.     ELEMENTS_SPAN[index].style.left = e.pageX - element.offsetLeft + "px";
  17.     ELEMENTS_SPAN[index].style.top = e.pageY - element.offsetTop + "px";
  18.     if (addAnimation) element.classList.add(ANIMATEDCLASSNAME);
  19.   });
  20.   element.addEventListener("mouseout", e => {
  21.     ELEMENTS_SPAN[index].style.left = e.pageX - element.offsetLeft + "px";
  22.     ELEMENTS_SPAN[index].style.top = e.pageY - element.offsetTop + "px";
  23.   });
  24. });
  25.  
RAW Paste Data