@rtorcato/browser-common / webanimations
webanimations
Functions
isWebAnimationsAvailable()
isWebAnimationsAvailable():
boolean
Defined in: webanimations/index.ts:10
Checks if the Web Animations API (Element.animate) is available.
Example
import { isWebAnimationsAvailable } from '@rtorcato/browser-common/webanimations'
if (isWebAnimationsAvailable()) fadeIn(el)
Returns
boolean
True if available, false otherwise.
animateElement()
animateElement(
element,keyframes,options?):Animation|null
Defined in: webanimations/index.ts:27
Animates an element imperatively via the Web Animations API.
Example
import { animateElement } from '@rtorcato/browser-common/webanimations'
const anim = animateElement(el, [{ opacity: 0 }, { opacity: 1 }], 300)
await anim?.finished
Parameters
element
Element
The element to animate.
keyframes
Keyframe[] | PropertyIndexedKeyframes | null
The keyframes (array or property-indexed object).
options?
number | KeyframeAnimationOptions
Timing options (duration number or KeyframeAnimationOptions).
Returns
Animation | null
The running Animation, or null if the API is unavailable.