Skip to main content

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 check
  • animateElement(element, keyframes, options?) โ€” runs element.animate(); returns the Animation, or null if unsupported

See the API reference for full signatures.