SkenraAnimation

← prev index next →

Animates an element's properties over time — the way to make a node move, scale, rotate, or recolor, following the Web Animations model.

Remarks

This is the driver of the SkenraAnimatable animation family: it owns the timing — how long the change takes, how many times it repeats, whether it reverses — and plays a set of keyframes that describe the property values along the way. It is placed on the element whose properties it animates, so the same timing grammar works for a node's transform, a material's color, a light's intensity, or any other animatable.

Key attributes. duration is how long one cycle lasts; iterations is how many times it repeats (Infinity loops forever); direction (alternate bounces back and forth) and easing shape the motion; begin schedules the start, either at a fixed time or synced to another animation's end (begin="other.end") for sequencing. The keyframes it plays give the property values: a keyframe at offset 0 is the start, at 1 the end, and a lone keyframe at offset 1 makes a "to" animation that interpolates from the element's own current value.

Related. Its keyframes are sk-keyframe children. Several animations on the same element compose — run them together for a parallel effect (sk-group-effect) or chain them with begin for a sequence (sk-sequence-effect). A finished animation is automatically replaced when a newer one covers the same properties, so rapid-fire animations do not accumulate.

Constructor

This constructor follows the Web Animations API Animation(effect, timeline) signature — positional, not the Skenra constructor(config?) convention — on purpose: <sk-animation> is the platform Animation interface, and matching the spec exactly is what lets WAAPI consumers and conformance tests use it interchangeably with a native Animation.

constructor(effect?: SkenraAnimationEffect | null, timeline?: SkenraAnimationTimeline | null)

Properties

Other Properties

PropertyTypeDefaultDescriptionDeclared by
currentTime number | null Gets the current time of the animation in milliseconds. SkenraAnimation
startTime number | null Gets the start time of the animation (alias for beginTime per Web Animations spec). SkenraAnimation
playbackRate number 1.0 Gets the playback rate of this animation per Web Animations spec §4.4.4. SkenraAnimation
timeline SkenraAnimationTimeline | null Gets the timeline associated with this animation per Web Animations spec §6.4.4. SkenraAnimation
effect SkenraAnimationEffect | null Gets the animation effect. SkenraAnimation
playStateread-only AnimationPlayState Gets the current play state of the animation per Web Animations spec. SkenraAnimation
pendingread-only boolean Gets whether the animation has a pending play or pause task per Web Animations spec §4.4.11. SkenraAnimation
overallProgressread-only number | null Gets the overall progress of the animation per Web Animations Level 2. SkenraAnimation
replaceStateread-only ReplaceState "active" Gets the replace state of this animation per Web Animations spec §5.5. SkenraAnimation
readyread-only Promise<Animation> Gets the ready promise per Web Animations spec §6.4.6. SkenraAnimation
finishedread-only Promise<Animation> Gets the finished promise per Web Animations spec §6.4.7. SkenraAnimation
onfinish ((this: Animation, ev: AnimationPlaybackEvent) => any) | null Gets the onfinish callback property. SkenraAnimation
onbegin ((this: Animation, ev: Event) => any) | null Gets the onbegin callback property. SkenraAnimation
onremove ((this: Animation, ev: Event) => any) | null Gets the onremove callback property. SkenraAnimation
animationDuration number | undefined Gets/sets the animation duration in milliseconds. SkenraAnimation
animationDelay number | undefined Gets/sets the animation delay in milliseconds. SkenraAnimation
animationEndDelay number | undefined Gets/sets the animation end delay in milliseconds. SkenraAnimation
animationIterations number | undefined Gets/sets the animation iterations count. SkenraAnimation
animationDirection string | undefined Gets/sets the animation direction. SkenraAnimation
animationFill string | undefined Gets/sets the animation fill mode. SkenraAnimation
animationEasing string | undefined Gets/sets the animation easing function. SkenraAnimation
animationComposite string | undefined Gets/sets the composite operation. SkenraAnimation
animationAutoplay boolean true Gets/sets the autoplay setting. SkenraAnimation
animationBegin string | undefined Gets/sets the SMIL-inspired begin trigger. SkenraAnimation
animationEnd string | undefined Gets/sets the SMIL-inspired end trigger. SkenraAnimation

Methods

MethodDescriptionDeclared by
play(): void Plays the animation per Web Animations spec. SkenraAnimation
pause(): void Pauses the animation. SkenraAnimation
cancel(): void Cancels the animation per Web Animations spec. SkenraAnimation
finish(): void Finishes the animation immediately per Web Animations spec §4.4.12. SkenraAnimation
reverse(): void Reverses the animation's playback direction per Web Animations spec §4.4.13. SkenraAnimation
persist(): void Prevents automatic removal of this animation per Web Animations spec §5.5. SkenraAnimation
commitStyles(): void Writes the current animated values to the target's base properties. SkenraAnimation
updatePlaybackRate(rate: number): void Updates the playback rate seamlessly per Web Animations spec §4.4.14. SkenraAnimation

Example

// Create effect and animation separately (composition pattern)
const effect = new SkenraKeyframeEffect(target, [
    { offset: 0, x: 0 },
    { offset: 1, x: 100 }
], { duration: 1000 });

const animation = new SkenraAnimation(effect);
animation.play();