Kael’s animation system is built around explicit, data-driven descriptions of motion. You construct anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Augani/kael/llms.txt
Use this file to discover all available pages before exploring further.
Animation value, pick an Easing curve and a Repeat strategy, then attach it to any element via the AnimationExt trait. The framework samples each animation on every frame and calls your animator closure with a normalized delta in [0.0, 1.0], leaving the actual style changes entirely in your control.
Animation
Animation describes a single motion segment: its duration, easing, delay, and repeat behaviour.
rust
Animation::new
rust
Linear easing, no delay, play once).
rust
Builder methods
Each method consumesself and returns a new Animation, so you can chain them.
Sets the easing curve to one of the built-in
Easing variants.Sets a custom easing function. The closure receives a normalized progress value in
[0.0, 1.0] and must return a value in the same range. Internally this wraps the closure in Easing::Custom(Rc::new(f)).Adds a delay before the animation begins. During the delay,
AnimationSample::started is false and delta is 0.0.Sets the repeat strategy to any
Repeat variant.Shorthand for
.repeat(Repeat::Forever).rust
Easing
TheEasing enum selects the curve applied to the raw linear progress value before it is delivered to your animator.
rust
Returns the input unchanged (
delta). Equivalent to the CSS linear timing function.Applies a quadratic ease-in curve (
delta * delta). Motion starts slow and accelerates.Applies a quadratic ease-out curve (
1 - (1 - delta)²). Motion starts fast and decelerates.Applies a quadratic ease-in-out curve. Motion accelerates through the first half and decelerates through the second.
A cubic Bézier curve with CSS-style control points, solved numerically with 12 binary-search iterations. Pass
(0.25, 0.1, 0.25, 1.0) to reproduce the CSS ease curve.A damped spring model. Higher
stiffness produces a snappier motion; higher damping removes oscillation; mass controls inertia.An arbitrary easing callback. Use
.with_easing(|t| ...) on Animation to construct this variant without naming the type.Easing helper functions
Thekael::animation::easing module exposes free functions you can compose or pass directly to .with_easing:
rust
Repeat
Controls how many times an animation plays.rust
Default. The animation plays a single time.
AnimationSample::finished becomes true when delta reaches 1.0.The animation repeats for the given number of full cycles. After
duration * count has elapsed, finished is true and delta is 1.0.The animation loops indefinitely.
finished is always false. Useful for loading spinners, pulsing indicators, or ambient motion.AnimationSample
AnimationSample is the internal output of Animation::sample. You rarely construct one yourself, but understanding its fields helps when writing custom animators.
rust
AnimationExt trait
TheAnimationExt trait extends any element or component with methods that wrap it in an AnimationElement. Import it from the elements module to bring the methods into scope.
with_animation
rust
animator closure receives the element and the current eased delta (0.0 → 1.0) on each frame, and must return the styled element.
rust
with_animations
rust
animator receives the element, the index of the currently active animation, and its local delta.
with_animation_sequence
rust
with_animations that accepts an AnimationSequence directly, consuming it into its scheduled Vec<Animation>.
with_keyframes
rust
Styled element. The Keyframes value handles interpolation; you only supply timing via Animation.
rust
animation (compact form)
rust
with_keyframes. Prefer this in component render methods where brevity matters.
AnimationSequence
AnimationSequence schedules a series of Animation values back-to-back, automatically offsetting each one so it starts after the previous ends.
rust
rust
Appends an animation that starts after the current tail’s
scheduled_end. Any delay on the new animation is added on top.Shorthand for
.then(Animation::new(duration)).Subtracts
overlap from the delay of the most recently added animation, causing it to start before the previous one finishes.Consumes the sequence and returns the flat, scheduled
Vec<Animation>.Keyframes
Keyframes lets you declare CSS-style keyframe stops at normalized progress positions. Kael linearly interpolates between adjacent stops.
rust
Keyframes value with the free function keyframes():
rust
StyledKeyframe
A single keyframe stop that can hold optional values foropacity, scale_x, scale_y, and rotate_degrees. Only fields that are set participate in interpolation; unset fields on adjacent stops are passed through unchanged.
rust
| Method | Description |
|---|---|
.opacity(f32) | Sets the target opacity. |
.scale(f32) | Sets uniform X and Y scale. |
.scale_xy(f32, f32) | Sets independent X and Y scale. |
.rotate(f32) | Sets the target rotation in degrees. |
AnimationHandle
If you need to cancel an in-flight animation, use thewith_cancellable_animation variant (on AnimationExt) which returns both the AnimationElement and an AnimationHandle.
rust
Signals the animation to jump to its final state on the next frame.
Returns
true if .cancel() has been called.