dataease-dm/frontend/src/components/canvas/utils/runAnimation.js

19 lines
637 B
JavaScript
Raw Normal View History

2021-03-25 19:16:32 +08:00
export default async function runAnimation($el, animations = []) {
2021-06-24 13:54:58 +08:00
const play = (animation) => new Promise(resolve => {
$el.classList.add(animation.value, 'animated')
const removeAnimation = () => {
$el.removeEventListener('animationend', removeAnimation)
$el.removeEventListener('animationcancel', removeAnimation)
$el.classList.remove(animation.value, 'animated')
resolve()
2021-03-25 19:16:32 +08:00
}
2021-06-24 13:54:58 +08:00
$el.addEventListener('animationend', removeAnimation)
$el.addEventListener('animationcancel', removeAnimation)
})
for (let i = 0, len = animations.length; i < len; i++) {
await play(animations[i])
}
2021-03-25 19:16:32 +08:00
}