mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-28 21:34:41 -05:00
* 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>
20 lines
808 B
TypeScript
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());
|
|
});
|
|
}
|