webanimations
Animate elements imperatively via the Web Animations API (Element.animate).
Import: @rtorcato/browser-common/webanimations
๐ MDN: Web Animations API ยท ๐ caniuse: web-animation
Exampleโ
import { isWebAnimationsAvailable, animateElement } from '@rtorcato/browser-common/webanimations'
if (isWebAnimationsAvailable()) {
const anim = animateElement(el, [{ opacity: 0 }, { opacity: 1 }], 300)
await anim?.finished
}
Exportsโ
isWebAnimationsAvailable()โ feature checkanimateElement(element, keyframes, options?)โ runselement.animate(); returns theAnimation, ornullif unsupported
See the API reference for full signatures.