skip the tree
system / motion / basics32 rebuilds

Basics

The Basics examples of the Motion library, rebuilt in Composite: the same trigger, in steps, with the system's own parts.

the category

motion/_rebuilds
rebuilds
32
from motion+
2
easing
steps() only

motion / basics / animatepresence modes

after a motion.dev example
one item leaves, the next comes
margin_rebuilds/​basics/​animate-presence-modes.tsx
Motion
AnimatePresence mode
here
play(), 3 frames
a frame
80 ms, 2 steps
modes
sync · wait · pop

Three lanes, one a mode: the old item cuts out in one step; the new one steps in at once, one step later, or after the space is freed.

motion / basics / color interpolation

after a motion.dev example
ink to bone
margin_rebuilds/​basics/​color-interpolation.tsx
Motion
mixes in linear RGB
here
the grey ladder
a step
one token, 80 ms
colours
9, ink to bone

A colour change walks the grey ladder, one token a step, beside the browser's own blend.

motion / basics / drag: lock direction

after a motion.dev example
drag it one way
margin_rebuilds/​basics/​drag-lock-direction.tsx
Motion
dragDirectionLock
here
the first cell picks the axis
a move
one 8 px cell
keys
arrows

The drag moves in whole 8 px cells and keeps to the axis of its first cell. The arrow keys move it too.

motion / basics / aspect ratio

after a motion.dev example
the box cuts to a new ratio
margin_rebuilds/​basics/​aspect-ratio.tsx
Motion
a layout animation
here
one cut
ratios
1:1 · 4:3 · 16:9
original
Aspect ratio

The box cuts to its new ratio in one step; nothing scales between.

motion / basics / animateactivity: slideshow

after a motion+ example
count on a slide, go on, come back
margin_rebuilds/​basics/​animate-activity.tsx
Motion
AnimateActivity
here
React's Activity
a change
one cut
hidden
keeps its count

Slides cut one to the next; a hidden slide keeps its count.

motion / basics / usepresencedata

after a motion.dev example
the leaving item knows the way
margin_rebuilds/​basics/​use-presence-data.tsx
Motion
usePresenceData
here
play(), 2 frames
a frame
80 ms, 2 steps
the jump
one 8 px cell

The leaving item jumps one cell toward the side the next comes from, then is gone; the next steps in from the other side.

motion / basics / html content

after a motion.dev example
a value written into the text
margin_rebuilds/​basics/​html-content.tsx
Motion
a MotionValue as text
here
play(), 10 frames
a frame
80 ms, 2 steps
the text
0 to 100
original
HTML content

The value counts up in the text in whole steps, one number a frame.

motion / basics / keyframe wildcards

after a motion.dev example
click again mid-move
margin_rebuilds/​basics/​keyframes-wildcards.tsx
Motion
a null keyframe
here
from the cell it is on
a cell
40 ms, 1 step
a new click
stops the last

A move to a new cell starts from the cell the part is on, so a new click cuts the last move short.

motion / basics / drag with spring follow

after a motion+ example
drag the lead
margin_rebuilds/​basics/​multifollow-pointer-with-spring.tsx
Motion
useSpring
here
three followers
each
one step behind
springs
none

No springs: each follower takes the cell the one before it left, one step later.

motion / basics / reorder animation

after a motion.dev example
the rows cut to a new order
margin_rebuilds/​basics/​reorder-items.tsx
Motion
the layout prop
here
one cut, then a Glitch
rows
4

The rows cut to their new order in one step, and each moved name glitches.

motion / basics / element scroll-linked animation

after a motion.dev example
scroll the box
margin_rebuilds/​basics/​scroll-container.tsx
Motion
useScroll, a container
here
scroll(), motion
the meter
8 cells

The scroll of a box fills a meter, one cell a step of the scroll.

motion / basics / track element within viewport

after a motion.dev example
scroll the part through the box
margin_rebuilds/​basics/​scroll-track-element-in-viewport.tsx
Motion
useScroll, a target
here
scroll() with a target
the meter
8 cells
from
enter to leave

A meter shows where a part is in the view, in eight cells.

motion / basics / animate state

after a motion.dev example
new values from the buttons
margin_rebuilds/​basics/​state-updates.tsx
Motion
animate from state
here
play(), 4 frames
a frame
40 ms, 1 step
values
place and turn

New values from the controls; the part cuts to them in at most four frames.

motion / basics / spinning 3d cube

after a motion.dev example
a cube, three turns
margin_rebuilds/​basics/​use-animation-frame.tsx
Motion
useAnimationFrame
here
play(), 8 frames a turn
a frame
80 ms, 2 steps
turns
3, then it stops

A box-drawn cube turns in eight frames, three turns, then stops.

motion / basics / usetime

after a motion.dev example
one cell a step, one pass
margin_rebuilds/​basics/​use-time.tsx
Motion
useTime
here
play(), a cell a step
a frame
40 ms, 1 step
a pass
24 cells, then it stops
original
useTime

A mark moves one cell a step along a track, for one pass, then stops.

motion / basics / exit animation

after a motion.dev example
remove it, add it back
margin_rebuilds/​basics/​exit-animation.tsx
Motion
AnimatePresence exit
here
a Glitch, then a cut
the Glitch
240 ms
back
in one step

The part glitches once, then is gone in one cut.

motion / basics / drag

after a motion.dev example
drag it, or use the arrow keys
margin_rebuilds/​basics/​drag.tsx
Motion
the drag prop
here
pointer events
a move
one 8 px cell
keys
arrows; shift, 4 cells
momentum
none
original
Drag

The drag moves in whole 8 px cells; the arrow keys move it one cell.

motion / basics / drag: constraints

after a motion.dev example
drag it to the edges
margin_rebuilds/​basics/​drag-constraints.tsx
Motion
dragConstraints
here
the box's edges
a move
one 8 px cell
keys
arrows

The drag moves in whole cells and stops at the edges of its box.

motion / basics / enter animation

after a motion.dev example
a part added to the page
margin_rebuilds/​basics/​enter-animation.tsx
Motion
animate on mount
here
play(), 4 frames
a frame
80 ms, 2 steps
reduced
the last frame

The part writes its frame, then its fill, one frame a step.

motion / basics / gestures

after a motion.dev example
hover it, press it
margin_rebuilds/​basics/​gestures.tsx
Motion
whileHover, whileTap
here
the State set
hover
the Well fill
press
the Held fill
original
Gestures

Hover is one grey step, a press is the Held fill: each a cut.

motion / basics / keyframes

after a motion.dev example
square, turned, small, square
margin_rebuilds/​basics/​keyframes.tsx
Motion
keyframes
here
play(), 4 frames
a frame
80 ms, 2 steps
frames
square, turned, small
original
Keyframes

The part holds each keyframe for two steps: square, turned, small, square.

motion / basics / layout animation

after a motion.dev example
the part cuts to its new place
margin_rebuilds/​basics/​layout-animation.tsx
Motion
the layout prop
here
one cut
places
start, end

The part cuts to its new place in one step.

motion / basics / motion along a path

after a motion.dev example
point to point along the path
margin_rebuilds/​basics/​motion-path.tsx
Motion
offsetDistance
here
play(), 8 points
a point
80 ms, 2 steps

A mark jumps along the path from point to point, one point a step.

motion / basics / path drawing

after a motion.dev example
the line draws itself
margin_rebuilds/​basics/​path-drawing.tsx
Motion
pathLength
here
play(), 6 frames
a frame
80 ms, 2 steps
original
Path drawing

The line draws in six frames, one part of its length a frame.

motion / basics / path morphing

after a motion.dev example
one shape cuts to the next
margin_rebuilds/​basics/​path-morphing.tsx
Motion
an interpolated path
here
a cut through one glitch
a frame
80 ms, 2 steps
shapes
square, diamond, bar

One shape cuts to the next through one glitched frame.

motion / basics / scroll-linked animations

after a motion.dev example
scroll the box
margin_rebuilds/​basics/​scroll-linked.tsx
Motion
useScroll
here
scroll(), motion
the line
16 cells
a cell
1/16 of the scroll

The scroll fills a progress line, one cell a step of the scroll.

motion / basics / scroll-triggered animations

after a motion.dev example
scroll the list
margin_rebuilds/​basics/​scroll-triggered.tsx
Motion
whileInView
here
inView(), motion
in
after one step
out
at once

Each row steps in as it comes into view, and out as it leaves.

motion / basics / shared layout animation

after a motion.dev example
the mark cuts to the chosen item
margin_rebuilds/​basics/​shared-layout-animation.tsx
Motion
layoutId
here
one cut
the mark
a 2 px bone rule

The selection mark cuts to the chosen item in one step.

motion / basics / transition options

after a motion.dev example
pick the options, then play
margin_rebuilds/​basics/​transition.tsx
Motion
transition options
here
frames, a frame, a delay
frames
2 · 4 · 8
a frame
40 · 80 · 120 ms

The options of one cut: how many frames, how long a frame, and the delay.

motion / basics / value transform & path drawing

after a motion.dev example
drag the handle
margin_rebuilds/​basics/​use-transform.tsx
Motion
useTransform
here
a cell sets the length
cells
10

The drag cell sets how much of the path is drawn, one part a cell.

motion / basics / variants

after a motion.dev example
open the menu
margin_rebuilds/​basics/​variants.tsx
Motion
variants, staggerChildren
here
a cut, then a step an item
items
4
original
Variants

The menu opens in one cut; its items step in one step apart.

motion / basics / rotate

after a motion.dev example
one turn, 45 degrees a frame
margin_rebuilds/​basics/​rotate.tsx
Motion
animate rotate
here
play(), 8 frames
a frame
80 ms, 45 degrees
turns
1, then it stops
original
Rotate

The square turns 45 degrees a frame, one turn, then stops.