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

Browser supportโ€‹

APIChromeEdgeFirefoxSafariiOS SafariBaseline
Element.animateโœ… 36+โœ… 79+โœ… 48+โœ… 13.1+โœ… 13.4+Widely available

โœ… supported ยท โ— partial ยท โŒ not supported ยท [n] see note. Generated from MDN browser-compat-data and web-features. caniuse: Element.animate

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.