ThemeStore Store Docs FAQ
Documentation

Animations

The animations field: what drives a value, which properties it can move, and every parameter with its default.

On this page

Most movement in a theme comes from formulas: a value that depends on page_position follows the finger without anything being animated. The animations field is for the rest: movement driven by the clock, by the element appearing, or by a sensor.

It is a JSON array held in a string, and it exists on elements and on page backgrounds:

json
"animations": "[{\"trigger\":\"time\",\"property\":\"translateY\",\"pattern\":\"sine\",\"amplitude\":6,\"speed\":0.5}]"

Each entry produces a number that is added on top of the property's formula. An element with "translateY": "20" and the entry above floats between 14 and 26. Several entries for the same property add up.

Triggers#

The trigger decides what the value follows. This is the field that matters most, because it also decides what the animation costs.

triggerValue followsCosts
timeThe clock, through pattern.A continuous redraw for as long as the element is on screen.
appearA spring from from to to, started when the element appears.Redraws only until the spring settles.
scrollpage_scroll_fraction, mapped from from to to.Nothing extra, the value is already being watched.
tilt_x, tilt_yDevice tilt in degrees, -90 mapped to from and 90 to to.The rotation sensor, all day.
compassCompass heading, mapped from from to to.The magnetometer, all day.
parallax_x, parallax_ySmoothed tilt for depth, -1 mapped to from and 1 to to. It drifts back to the middle.The gyroscope, but frames only while the phone moves.
unlockThe unlock transition: from while the lock screen shows, to at rest. It follows a spring and may overshoot.Frames for about half a second after each unlock, nothing otherwise.

scroll is free and the others are not. A page full of time animations is a page that never lets the display idle.

Properties#

translateX, translateY, scale, rotation, opacity on an element; dimAlpha on a page background. Anything else is ignored.

Parameters#

FieldDefaultApplies toMeaning
trigger"time"See above.
property"translateY"See above.
pattern"sine"timesine, cosine, rotate, shake.
amplitude8timePeak deflection. For rotate it is ignored, since a rotation is a full turn per 1/speed seconds.
speed1timeCycles per second. shake runs at three times this.
phase0timeOffset within the cycle, 0-1. Give two elements different phases and they stop moving in lockstep.
from0everything but timeValue at the start of the range.
to0everything but timeValue at the end.
stiffness800appearSpring stiffness. Clamped to 1 to 10 000.
damping0.7appearDamping ratio. Below 1 overshoots, 1 arrives without overshoot, above 1 crawls in. Clamped to 0.05 to 5.
delay"0"appearA formula, evaluated per element, in milliseconds.

The clamps on stiffness and damping are not style advice. A stiffness near zero or a damping of zero produces a spring that never settles, and a theme document is data that arrives from elsewhere; the ceiling is what stops one from pinning the frame loop.

Staggering a list#

delay is the reason it is a formula rather than a number. Inside a repeater each card knows its own item_index, so one entry staggers the whole list:

json
"animations": "[{\"trigger\":\"appear\",\"property\":\"translateY\",\"from\":24,\"to\":0,\"delay\":\"$item_index * 60$\"}]"

Keep the total short. Twenty cards at 60 ms each is a list that takes more than a second to assemble, and a list that assembles slowly feels slower than one that was simply there.

When an element "appears"#

An appear animation starts when the element goes from hidden to visible: a hidden formula turning false, or a page being opened. The very first state an element is ever seen in does not count as appearing, so opening the launcher onto a page does not replay every spring on it.

Animation versus formula#

Use an entry here when the movement has its own source: a pulse, an arrival, a tilt. Use a formula when the movement follows something the reader is doing. A parallax built on page_position costs nothing and tracks the finger exactly; the same effect built as a time animation costs a redraw every frame and drifts out of step with the swipe.

Documentation for launcher 0.1.0-alpha Android 12 and later last updated