819527061@qq.com
2023-07-25 f0b2b04b1b43d4891c1808ad060b9959f9a1209c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const animateCSS = (element, animation, prefix = 'animate__') =>
// We create a Promise and return it
new Promise((resolve, reject) => {
  const animationName = `${prefix}${animation}`;
  const node = document.querySelector(element);
  node.classList.add(`${prefix}animated`, animationName);
 
  // When the animation ends, we clean the classes and resolve the Promise
  function handleAnimationEnd(event) {
    event.stopPropagation();
    node.classList.remove(`${prefix}animated`, animationName);
    resolve('Animation ended');
  }
 
  node.addEventListener('animationend', handleAnimationEnd, {once: true});
});
 
export default animateCSS