Animations reference¶
Animation types live in the inkflow.animations namespace. Each takes the shared
Cue params (element, trigger), the TimedCue
timing params (duration, easing, delay), the Animation
iterations param, and any of its own. element is the target's id; trigger is a
Trigger that decides the cue's step.
direction fields use the Direction
enum and easing the Easing type.
from inkflow import animations, Direction, Trigger
Slide(
"01.svg",
animations=[
animations.FadeIn("headline"),
animations.SlideIn(
"box", Trigger.WITH_PREVIOUS, direction=Direction.LEFT, duration=0.6
),
],
)
Every built-in subclasses one of the semantic bases Enter,
Exit, or Emphasis, which
fix its AnimationKind. The kind lets several cues target one
element and compose into a single lifecycle: an element can enter, be emphasized, and
exit at different steps, and re-enter after an exit. Enters reveal, exits hide, and
emphasis fires momentarily without changing visibility.
Custom animations subclass a semantic base and write a matching
@keyframes anim-<slug> rule (the kebab-cased type name) in a styles.css next to
deck.py. No JavaScript is involved: the step engine reads the keyframes and drives
them. Any extra field is substituted wherever it appears as var(--anim-<field>).
from dataclasses import dataclass
from inkflow import animations
@dataclass
class Glow(animations.Emphasis):
intensity: float = 1.0 # → var(--anim-intensity) in @keyframes anim-glow
The animations namespace also holds PlayVideo,
a non-animating cue that starts a Video on a step,
and Frame, which moves the slide's camera
to frame an element (see Camera).
Built-in animation types for the deck DSL.
The base Animation (element + trigger from Cue, plus duration/easing/
delay) lives here alongside the three semantic bases Enter, Exit, and
Emphasis, which fix the animation's AnimationKind. Concrete types are thin
subclasses of those bases, adding only their own fields. This namespace also holds
PlayVideo, the non-animating video cue, and Frame, the camera cue, which share the
same step timeline.
How a type maps to CSS:
- The step engine drives each cue via the Web Animations API, reading the
@keyframes anim-<slug>rule whose slug is the kebab-cased class name (Animation.slug()):FadeIn→anim-fade-in,SlideIn→anim-slide-in,Highlight→anim-highlight. Defining a new type is "add a subclass here + write a matching@keyframesrule," nothing else. - Every field becomes part of the cue's serialized params. Timing fields
(
duration/easing/delay) drive theelement.animate()options; the rest are substituted into the keyframes wherever they appear as avar(--anim-<field>)token (e.g.var(--anim-distance)), leaving other custom properties likevar(--accent)for the browser to resolve. kinddecides how several cues on one element compose: enters reveal, exits hide, emphasis fires momentarily without changing visibility.
Cue
dataclass
¶
Base for anything on a slide's step timeline.
Carries just the target element and the trigger that decides its step.
TimedCue
dataclass
¶
Bases: Cue
Base for cues that play over time: Animation and Frame.
Adds the shared keyword-only timing params on top of Cue.
duration
class-attribute
instance-attribute
¶
Duration in seconds.
easing
class-attribute
instance-attribute
¶
Easing curve — an Easing preset (e.g. Easing.EASE_IN_OUT) or a
custom curve via Easing.cubic_bezier(...).
delay
class-attribute
instance-attribute
¶
Seconds to wait before the cue starts playing.
Animation
dataclass
¶
Bases: TimedCue, Slugged
Base for every animation type.
Concrete types subclass one of Enter / Exit / Emphasis (which fix the
AnimationKind), adding their own fields. element/trigger come from Cue;
duration, easing, and delay are the shared keyword-only timing params
from TimedCue.
Custom animations. Subclass a semantic base in deck.py — no changes to
inkflow are needed. Write a matching @keyframes rule named after the kebab-cased
type (MyGlow → @keyframes anim-my-glow) in a styles.css next to
deck.py (loaded automatically). Any extra field is substituted into the
keyframes wherever it appears as var(--anim-<field>).
from inkflow import animations
@dataclass
class MyGlow(animations.Emphasis):
intensity: float = 1.0 # → var(--anim-intensity) in @keyframes anim-my-glow
kind
class-attribute
¶
The animation's lifecycle role. Overridden by the semantic base classes; a bare
Animation subclass defaults to an enter.
iterations
class-attribute
instance-attribute
¶
How many times the animation repeats. Mostly useful for an emphasis like
Highlight (pulse iterations times); enters/exits normally leave it at 1.
Enter
dataclass
¶
Exit
dataclass
¶
Emphasis
dataclass
¶
PlayVideo
dataclass
¶
Bases: Cue
Start a video on a step instead of on load.
element is the zone key of a Video, e.g. "media" for
zones={"media": Video(...)}. At its step the clip plays; stepping back
resets it.
If the video also sets autoplay=True, the cue wins and autoplay is dropped.
Frame
dataclass
¶
Bases: TimedCue
Move the slide's camera to frame an element on a step.
element is the id of any SVG element with a bounding box, hidden ones
included. The view is grown to the slide's aspect ratio around the element, so
everything inside it stays visible. Framing FrameTarget.FULL_SLIDE (the
default) returns to the whole slide.
Slide(
"diagram.svg",
animations=[
animations.Frame("ingest", margin=40),
animations.Frame("storage"),
animations.Frame(),
],
)
A step-0 frame (Trigger.WITH_PREVIOUS as the first cue) plays when the slide
arrives. With duration=0 the slide arrives already framed instead.
element
class-attribute
instance-attribute
¶
Id of the element to frame, or FrameTarget.FULL_SLIDE.
margin
class-attribute
instance-attribute
¶
Space kept around the element, in SVG user units.
duration
class-attribute
instance-attribute
¶
Duration in seconds.
easing
class-attribute
instance-attribute
¶
Easing curve along the camera path.
Bounce
dataclass
¶
Bases: Enter
Element starts hidden just below its place and springs up into it on its step.
duration
class-attribute
instance-attribute
¶
Duration in seconds.
easing
class-attribute
instance-attribute
¶
Easing curve — defaults to a spring that overshoots past the resting position and settles back, which is what gives the bounce its character.
distance
class-attribute
instance-attribute
¶
How far below its resting place the element starts, in SVG user units.
SlideIn
dataclass
¶
ScaleIn
dataclass
¶
SlideOut
dataclass
¶
ScaleOut
dataclass
¶
Cue (base)¶
Base for anything on a slide's step timeline.
Carries just the target element and the trigger that decides its step.
TimedCue (base)¶
Bases: Cue
Base for cues that play over time: Animation and Frame.
Adds the shared keyword-only timing params on top of Cue.
duration
class-attribute
instance-attribute
¶
Duration in seconds.
easing
class-attribute
instance-attribute
¶
Easing curve — an Easing preset (e.g. Easing.EASE_IN_OUT) or a
custom curve via Easing.cubic_bezier(...).
delay
class-attribute
instance-attribute
¶
Seconds to wait before the cue starts playing.
Animation (base)¶
Bases: TimedCue, Slugged
Base for every animation type.
Concrete types subclass one of Enter / Exit / Emphasis (which fix the
AnimationKind), adding their own fields. element/trigger come from Cue;
duration, easing, and delay are the shared keyword-only timing params
from TimedCue.
Custom animations. Subclass a semantic base in deck.py — no changes to
inkflow are needed. Write a matching @keyframes rule named after the kebab-cased
type (MyGlow → @keyframes anim-my-glow) in a styles.css next to
deck.py (loaded automatically). Any extra field is substituted into the
keyframes wherever it appears as var(--anim-<field>).
from inkflow import animations
@dataclass
class MyGlow(animations.Emphasis):
intensity: float = 1.0 # → var(--anim-intensity) in @keyframes anim-my-glow
kind
class-attribute
¶
The animation's lifecycle role. Overridden by the semantic base classes; a bare
Animation subclass defaults to an enter.
iterations
class-attribute
instance-attribute
¶
How many times the animation repeats. Mostly useful for an emphasis like
Highlight (pulse iterations times); enters/exits normally leave it at 1.