UNPKG

438 BPlain TextView Raw
1import { ComponentNode } from './html';
2
3export const getAnimationDuration = ($el: Element) => parseFloat(window.getComputedStyle($el).animationDuration);
4
5export const setAnimation = (animationClass: string, duration?: number) => ({ dom }: ComponentNode) => {
6 dom.classList.add(animationClass);
7 return new Promise((resolve) => {
8 setTimeout(resolve, duration == null ? 0.95 * getAnimationDuration(dom) * 1e3 : duration);
9 });
10};