sendou.ink/app/utils/flip.ts
Kalle fd48bced91
Migrate Prettier/Eslint/Stylelint setup to Biome (#1772)
* Initial

* CSS lint

* Test CI

* Add 1v1, 2v2, and 3v3 Tags (#1771)

* Initial

* CSS lint

* Test CI

* Rename step

---------

Co-authored-by: xi <104683822+ximk@users.noreply.github.com>
2024-06-24 13:07:17 +03:00

20 lines
808 B
TypeScript

// https://github.com/aholachek/react-flip-toolkit/issues/95#issuecomment-546101332
/**
* Thin wrapper around Element.animate() that returns a Promise
* @param el Element to animate
* @param keyframes The keyframes to use when animating
* @param options Either the duration of the animation or an options argument detailing how the animation should be performed
* @returns A promise that will resolve after the animation completes or is cancelled
*/
export function animate(
el: HTMLElement,
keyframes: Keyframe[] | PropertyIndexedKeyframes,
options?: number | KeyframeAnimationOptions,
): Promise<void> {
return new Promise((resolve) => {
const anim = el.animate(keyframes, options);
anim.addEventListener("finish", () => resolve());
anim.addEventListener("cancel", () => resolve());
});
}