mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
12 lines
471 B
JavaScript
12 lines
471 B
JavaScript
|
// Properly animates an element
|
||
|
export function animate(element, animation, duration, after) {
|
||
|
element.style.setProperty("--animate-duration", duration);
|
||
|
element.classList.add("animate__animated", animation);
|
||
|
element.addEventListener("animationend", () => {
|
||
|
element.style.removeProperty("--animate-duration");
|
||
|
element.classList.remove("animate__animated", animation);
|
||
|
if (after) {
|
||
|
after();
|
||
|
}
|
||
|
}, {once: true});
|
||
|
}
|