Behaviors
What a behavior is, how a node's motion list adds up, poses and their 15 channels, curves and springs, stagger, drive, and defining a behavior as data.
A behavior does one job: arrive, leave, loop, count, follow a path. It is a pure function of time, so any second can be asked for on its own and the same scene plays the same way everywhere. The kit ships 20. A scene can define more as data.
The motion list#
Every node takes motion: a list of behaviors, each written { "do": name, ...options }.
{ "el": "box", "surface": "card",
"motion": [
{ "do": "enter", "from": "drop", "curve": "bouncy" },
{ "do": "loop", "kind": "float", "amount": 1.5, "period": 3 }
] }A node can carry any number of behaviors. Their poses add up: offsets and rotations are summed, scale and opacity multiply. So an entrance, a float and a beat can run on one node without knowing about each other.
enterarrives from a pose and settles at rest. The node does not exist before it starts.exitleaves to a pose and the node is gone. With noatit finishes exactly as the scene ends.tomoves to a new pose and stays. Severaltobehaviors chain: each starts from where the last one ended.{}as the pose returns to rest.- Some behaviors apply to one element only:
camerato a box,count,typeandscrambleto a text,drawto a shape or an icon. Using one elsewhere is a problem.
to moves: out to a tilt at 2.2 seconds, back to rest at 3.4.All behaviors#
| Behavior | Works on | Options | What it does |
|---|---|---|---|
| during | any element | at, until | Show this node and its children only inside a time window. Independently composed entrances and exits can shorten it. |
| enter | any element | from, at, delay, curve | Arrives from a pose and settles at rest. The element doesn't exist before it starts. |
| exit | any element | to, at, delay, curve | Leaves to a pose and is gone. With no `at` it finishes exactly as the scene ends. |
| to | any element | pose, at, delay, curve | Moves to a new pose and stays there. Several chain: each starts from where the last one ended. {} as the pose returns to rest. |
| loop | any element | kind, amount, period, at, until | Keeps moving while it's on screen: float (bobs), sway (rocks), pulse, breathe, spin, wiggle (nervous), drift (wanders), tilt (3D wobble, needs a parent with perspective), blink. |
| beat | any element | at, amount | A quick pulse at each time in the list: for landing on a word or a music beat. |
| shake | any element | at, delay, amount, duration | A short decaying shake: an impact, an error, a hit. |
| camera | box | moves | Treats a box as a camera view: each move zooms and brings a focus point to the middle, then holds until the next. Put the box inside a parent with clip: true. focus is [x, y] fractions of the box or "#id" of an element inside it; zoom 1 with no focus pulls back to the whole view. |
| count | text | from, to, at, delay, curve, decimals, prefix, suffix | Rolls the text's number from one value to another. |
| type | text | at, delay, cps, cursor, then | Types the text out, a character at a time. |
| draw | shape, icon | at, delay, curve | Draws a shape's stroke from nothing (a tick, an arrow, an underline, a ring filling to its progress). |
| drive | any element | pose, at, until | Sets pose channels from expressions, every frame. This is the open one: anything you can write as arithmetic over time (t = scene seconds, lt = seconds since this element started), cues, signals and the loop's index becomes motion. Add it on top of enter and exit. |
| keys | any element | pose, at, delay, duration, repeat, yoyo | Keyframes. Each channel is a list of stops [time, value] or [time, value, curve]; the curve shapes the move into that stop. Times are seconds from when it starts, or 0–1 if you give "duration". repeat plays it again (-1 = forever), yoyo plays every other pass backwards. |
| along | any element | points, at, delay, curve, turn | Travels through a list of points (pixel offsets from where it sits, the first usually [0, 0]) on a smooth curve, and stays at the last one. |
| scramble | text | at, delay, duration | The text resolves out of random letters, left to right: a decode effect. |
| stagger | any element | each, from, cols, origin, at, delay, motion | Starts each child a little after the one before, and can give every child the same motion. On a text with split, the children are its words or letters. |
| orbit | any element | radius, period, phase, squash, at, delay, until | Circles its resting place. phase 0–1 is where on the circle it starts; a negative period turns the other way. It swings out from the centre as it starts. |
| bob | any element | amount, period, phase, at, delay, until | Rises and falls in a wave. Give each item in a row a phase of index*0.1 and the wave travels along the row. |
| popShake | any element | amount, bounce, at, delay, until | Pops in, then shakes once it has landed: an arrival that demands a look. A bundle of enter and shake. |
| inOut | any element | from, to, hold, at, delay, until | Arrives, holds, and leaves again after "hold" seconds: a bundle of enter and exit for things that are only on screen for a moment. |
Most behaviors take at (seconds or a cue name) and delay (seconds added to it). Left out, a behavior starts when its node does. See Scenes for how a node's start is worked out.
Poses#
A pose is an offset from where a node rests in the layout. It has 15 channels.
| Channels | Unit | At rest | Notes |
|---|---|---|---|
x, y, z | pixels | 0 | z needs a parent box with perspective. |
scale, scaleX, scaleY | multiplier | 1 | Around the node's origin. |
rotate, rotateX, rotateY | degrees | 0 | rotateX and rotateY need a parent box with perspective. |
opacity | multiplier | 1 | |
blur | pixels | 0 | |
clipT, clipR, clipB, clipL | percent | 0 | How much is hidden from that side. This is how wipes are made. |
Wherever a pose is expected (enter's from, exit's to, to's pose) you can write an object of channels or one of 20 names:
fade rise drop slide-left slide-right pop shrink stamp zoom-out blur
wipe-up wipe-down wipe-right wipe-left flip swing spin fly fly-past fallrise is { "y": 70, "opacity": 0 }. pop is { "scale": 0.55, "opacity": 0 }. flip, swing, fly and fly-past move in depth. Without a parent that has perspective they look flat, and the check says so in a note. A scene or a design system can redefine a name under poses.
Curves and springs#
A curve shapes a move from start to finish. There are ten names:
| Name | Definition |
|---|---|
linear | ease linear, 0.5 s |
smooth | ease inOut, 0.6 s |
snap | ease outExpo, 0.5 s |
rush | ease inExpo, 0.6 s |
anticipate | ease inOutBack, 0.7 s |
gentle | spring, bounce 0, 0.8 s |
punchy | spring, bounce 0.25, 0.4 s |
bouncy | spring, bounce 0.45, 0.7 s |
elastic | spring, bounce 0.7, 0.9 s |
heavy | spring, bounce 0.12, 1.1 s |
Or write your own:
[
{ "spring": { "bounce": 0.3, "duration": 0.5 } },
{ "spring": { "stiffness": 180, "damping": 14, "mass": 1 } },
{ "ease": "outExpo", "duration": 1.2 },
{ "bezier": [0.2, 0.8, 0.2, 1], "duration": 0.6 }
]bounceruns from 0 to 0.95. 0 has no overshoot, 0.3 is lively, 0.6 and above wobbles.- Eases:
linear,in,out,inOut,inQuart,outQuart,inExpo,outExpo,inOutExpo,inBack,outBack,inOutBack,outCirc. - Springs are solved exactly, not stepped. A frame in the middle of a spring costs the same as any other.
- A scene or a design system can redefine a name under
curves. That is how"punchy"means a different spring for a different brand.
stagger#
stagger goes on a parent. It starts each child a little after the one before, and can give every child the same motion.
{ "do": "stagger", "each": 0.06, "from": "center",
"motion": [{ "do": "enter", "from": "pop", "curve": "bouncy" }] }eachis the seconds between children.fromis the order:start,end,center,edges,random.- On a text with
split, the children are its words, letters or lines. - With
cols, the children are treated as a grid that wide. They start by distance fromorigin, so the motion ripples out from a point. - The offset shifts each child's start. Anything inside the child counts from there.
drive#
drive sets pose channels from expressions on every frame. It is the open behavior: anything that can be written as arithmetic over time becomes motion. Its expressions read t, lt, cues, signals, and index inside $each.
{ "do": "drive", "pose": {
"x": "=cos(t*2+index)*120",
"y": "=sin(t*2+index)*120",
"scale": "=1+0.2*wave(t)" } }Add it on top of enter and exit. until stops it at a time. See Expressions for what an expression can read. When several nodes must move together, give them one signal to read.
keys is the alternative when you know the stops and not the formula: each channel is a list of [time, value] or [time, value, curve].
Defining a behavior as data#
A scene's behaviors list adds behaviors. There are two forms. The first is a pose whose channels are expressions of time and the behavior's options:
swing, defined in the scene and used on five boxes. Each gets a different phase from its index.The second form is a bundle: other behaviors under one name. "$option" fills in an option. Two of the built-in behaviors are bundles written this way:
{ "name": "popShake",
"options": { "amount": { "type": "number", "default": 14 }, "bounce": { "type": "number", "default": 0.5 } },
"uses": [
{ "do": "enter", "from": "pop", "curve": { "spring": { "bounce": "$bounce", "duration": 0.5 } } },
{ "do": "shake", "delay": 0.45, "amount": "$amount" }
] }A data behavior takes at, delay and until like the others. Its expressions read its options, t, lt, cues and signals. Pass anything that differs per item, such as index, in as an option. Four of the 20 shipped behaviors are data: orbit, bob, popShake and inOut.
A design system can carry behaviors too, so a brand's own motion travels with its colours. See Design systems.