vue封装Animate.css动画库的使用方式

  /**

  *

  * @param {*} element 传入的H5元素对象

  * @param {*} animation 动画名称

  * @param {*} prefix 可以不用传,默认参数即可

  * @returns

  */

  export const animateCSS = (element, animation, prefix = 'animate__') => {

  new Promise((resolve, reject) => {

  const animationName = `${prefix}${animation}`

  element.classList.add(`${prefix}animated`, animationName)

  function handleAnimationEnd(event) {

  event.stopPropagation()

  element.classList.remove(`${prefix}animated`, animationName)

  resolve('Animation ended')

  }

  element.addEventListener('animationend', handleAnimationEnd, {once: true})

  })

  }