# Motion and reduced motion
Motion in RemedyUI has three rules:
- **Motion explains, it does not decorate.** Things move to show where they came from and
where they went.
- **The person can turn it off.** When the system asks for reduced motion, animations jump
to their end and spinners hold still. This holds for every widget, the engine's and the
app's.
- **Motion never costs the UI thread what it does not have to.** Animations run on the
window's frame clock with no timers, a window with nothing moving asks for no frames, and
scrolling, flings and overscroll run on the compositor thread at the display's rate even
while app code is busy.
This page covers the reduced-motion setting, the motion tokens, animating elements,
transitions for content that comes and goes, and painters that animate.
## Reduced motion
[`Ui::reduced_motion`](crate::Ui::reduced_motion) says whether motion should be reduced. The
runner sets it from the system's setting and changes it when the setting changes. It is
tracked: a binding that reads it runs again when it changes.
Everything that moves through the engine follows it on its own: [`El::animate`](crate::El::animate),
[`show`](crate::show) and list transitions, the spinner and indeterminate progress, the
[`viz`](crate::viz) meters, carousels and the terminal's cursor. Painters that animate read
[`PaintCx::reduced_motion`](crate::PaintCx::reduced_motion) and draw a still frame.
```
use remedy_ui::host::SystemSettings;
use remedy_ui::testing::TestApp;
use remedy_ui::widgets as w;
let mut settings = SystemSettings::default();
settings.reduced_motion = true;
app.host().change_settings(settings);
app.frames(1);
assert!(ui.reduced_motion());
assert!(ui.reader_view().iter().any(|n| n.name.as_deref() == Some("Motion is reduced")));
```
Tests can set it directly with [`Ui::set_reduced_motion`](crate::Ui::set_reduced_motion), or
through the host's settings as above.
## Motion tokens
How long things take is part of the theme ([`MotionTokens`](crate::style::MotionTokens)):
`quick` for hover and press feedback, `standard` for most transitions, `emphasized` for large
moves and page transitions. [`Ui::motion`](crate::Ui::motion) turns a
[`Pace`](crate::motion::Pace) into a [`Motion`](crate::motion::Motion): a spring of the
token's duration with no bounce. Use it instead of fixed durations, so the app moves like the
rest of the platform.
```
use remedy_ui::themes::ThemeChoice;
let theme = ThemeChoice::default().resolve(None, false);
let m = theme.motion;
assert!(m.quick < m.standard && m.standard < m.emphasized);
```
## Animating an element
[`El::animate`](crate::El::animate) moves one property of an element to a value: its
opacity, background, foreground, border, border width, radius or padding, or where and how
large it is drawn ([`Target::Translate`](crate::motion::Target::Translate) and
[`Target::Scale`](crate::motion::Target::Scale), which move it without laying anything out
again). A new target for the same property starts from where the value is, with the speed it
has, so an interrupted move turns smoothly instead of jumping. Under reduced motion the move
is instant.
- [`El::animate_then`](crate::El::animate_then) calls back once the value has arrived.
- [`El::animate_style`](crate::El::animate_style) animates every animatable property a style
patch sets.
- [`El::set_animated`](crate::El::set_animated) jumps a property to its value.
- [`El::flip`](crate::El::flip) glides an element through a layout change about to happen
(a reorder, an insert above it).
```
use remedy_ui::motion::{Pace, Target};
use remedy_ui::testing::TestApp;
use remedy_ui::widgets as w;
use std::cell::OnceCell;
use std::rc::Rc;
let slot = Rc::new(OnceCell::new());
let s = slot.clone();
toast.animate(Target::Opacity(0.0), ui.motion(Pace::Standard));
app.frames(1);
assert!(toast.is_animating(), "it moves on the frame clock, frame by frame");
app.frames(120); // two seconds of frames
assert!(!toast.is_animating(), "and settles; the window asks for no more frames");
```
The values come from the `motion` module ([`motion`](crate::motion)): springs
([`Spring::smooth`](crate::motion::Spring::smooth), [`Spring::bouncy`](crate::motion::Spring::bouncy)),
tweens along an [`Easing`](crate::motion::Easing), and [`Animation`](crate::motion::Animation)
for a value an app animates itself. Springs are solved in closed form, so they are exact at
60, 120 or 240 Hz.
## Content that comes and goes
Content that appears and leaves plays a [`Transition`](crate::motion::Transition): a fade, a
slide, or any set of targets it starts from.
- [`show`](crate::show) plays `enter` when its content appears and `exit` when it
goes; leaving content stays, inert, until its exit ends. See
[`crate::guide::control_flow`].
- [`widgets::for_each_with`](crate::widgets::for_each_with) plays enter and exit transitions
on list rows and glides the rows that stay to their new places. See
[`crate::guide::lists`].
## Painters that animate
A painter whose content changes every frame (a waveform, a spinner, a 3D preview) samples
[`PaintCx::time`](crate::PaintCx::time), the frame's predicted presentation time, and calls
[`PaintCx::request_next_frame`](crate::PaintCx::request_next_frame) while it moves. It is
drawn again on the next frame, at the display's rate, and the window goes idle as soon as it
stops asking. Under reduced motion it draws a still frame and does not ask.
```
use remedy_ui::core::{CornerRadii, Rect};
use remedy_ui::paint::Brush;
use remedy_ui::testing::TestApp;
use remedy_ui::widgets as w;
use std::cell::Cell;
use std::rc::Rc;
let drawn = Rc::new(Cell::new(0u32));
let d = drawn.clone();