CSS animation, with a single renderer for transitions, sequences, and timelines.
Animate a change to these properties using native CSS transitions where
possible. Springs use native CSS linear(...) easing, which requires a browser
with support for that timing function. Incompatible curves within a compound
property use keyframes instead.
Native springs follow CSS transition reversal rules. Use a timeline when spring interruptions need to preserve incoming velocity.
Animator.div
(Animator.transition (Animator.ms 200)
[ Animator.opacity
(if model.visible then
1
else
0
)
]
)
[]
[ Html.text "Hello!" ]A CSS property and its target value and transition curve.
Rotation in turns around the Z axis.
Rotation in turns around the given axis.
Translation in pixels.
Translation in pixels.
Translation in pixels.
Scale all three axes.
A color property.
A property measured in pixels.
A property rendered as a rounded integer.
A unitless numeric property.
Attributes use Animator.Transition.standard by default.
Apply a curve to all properties in a step, including nested sequences.
A duration. Start with a short duration and adjust for the size and distance of the movement.
A duration in milliseconds.
These are ordinary keyframe sequences; inspect their definitions to make your own.
The duration covers a complete out-and-back bounce. Distance is in pixels: positive moves down, negative moves up.
import Animator as Anim
import Html
Anim.div
(Anim.keyframes
[ Anim.loop
[ Anim.set [ Anim.opacity 1 ]
, Anim.wait (Anim.ms 200)
, Anim.step (Anim.ms 200) [ Anim.opacity 0 ]
]
]
)
[]
[ Html.text "Hello!" ]A step or nested sequence of steps.
Immediately set properties.
Hold the current properties for a duration.
Move to these properties, preserving properties omitted from the step.
Repeat indefinitely.
Repeat a sequence. Zero skips it; a negative count repeats indefinitely.
Group steps into a sequence that runs once.
Animate on a timeline, allowing multiple elements to synchronize and handling interruptions from their sampled positions. Uses CSS keyframe animations.
Omitted properties return to their defaults: translation and rotation to 0,
scale and opacity to 1. In contrast, step keeps omitted properties as they are.
Animate to a state's properties, then run its resting steps. The steps are interrupted when the next timeline transition begins.
Generated keyframes, transitions, inline properties, and an identity hash.
Equivalent to onTimelineWith followed by toCss.
An animation ready to render as HTML or CSS.