Blocks can animate in as they scroll into view, like Elementor's Entrance Animation: an effect, a delay, a duration, an optional stagger across the block's pieces, and separate settings for parts of a block (a photo rising on its own while the circle behind it zooms).
Code: src/lib/motion.ts (field, helpers), src/lib/motion-runtime.ts
(runtime), src/components/motion.css (keyframes), src/components/admin/MotionEditor.tsx
(the panel). Tests: src/lib/motion.test.ts, src/lib/motion-runtime.test.ts.
For whoever edits the page
Select a block in the page builder. Under its fields is a Motion panel:
| Setting | What it does |
|---|---|
| Entrance effect | Built-in (default) keeps the block's usual animation. Any other choice replaces it; None turns animation off for that block. |
| Delay (ms) | Wait before animating. 1000 ms = 1 second. |
| Duration (ms) | How long the animation takes. Default 700. |
| Stagger (ms) | Animate the block's pieces (heading, each card or tile) one after another, this far apart, instead of the whole block at once. |
| Parts | Only on blocks that have them (About: Photo, Text. Image: Image, Caption). Each part gets its own effect, delay and duration, on top of the block's. |
Effects: fade, fade-up, fade-down, zoom-in, slide-left (comes in
from the left), slide-right (comes in from the right), none.
What visitors see:
- Each animation plays once, the first time the element scrolls into view.
- Nothing on screen when the page loads animates. The first view paints straight away, so a hero or a block at the top of the page never fades in on load. Motion is for content further down.
- Visitors whose device asks for reduced motion see everything in place, with no movement.
- If JavaScript is off or fails, everything is visible. Nothing is ever hidden in the page HTML.
The same field is in THINQ Connect: get_block_types lists motion in
every block's schema, so Claude can set it with update_page.
The field
Optional on every block, core and custom alike:
{
"type": "services",
"motion": {
"effect": "fade-up",
"delay": 0,
"duration": 700,
"stagger": 80
}
}
{
"type": "about",
"motion": {
"parts": {
"photo": { "effect": "fade-up", "delay": 300, "duration": 900 },
"text": { "effect": "slide-right", "delay": 150 }
}
}
}
Every key is optional. Times are whole milliseconds (delay 0–5000,
duration 100–5000, stagger 0–1000). parts only accepts the keys the block
declares, and unknown keys are dropped on save. If effect is unset, the block
keeps its built-in animation and its markup is unchanged. parts apply either
way.
You don't declare motion in a block's schema. withMotion adds it to every
registered block in src/features/index.ts. A block that already has its own
motion field keeps that field and doesn't get this one.
Building blocks that animate well
Pieces (for stagger). In stagger mode, a block's pieces are every
<Reveal> inside it plus any element with data-motion-item. Core blocks
already wrap their heading and each card in Reveal, so stagger works on them
as they are. In a custom block, mark each repeated item:
{block.items.map((item) => (
<li key={item.id} data-motion-item>…</li>
))}
Pieces that come into view together stagger in page order. A grid row counts 0, 1, 2, and the next row starts again from 0, so a long list never builds up a long wait. A block with no pieces animates as a whole.
Parts. Declare them on the BlockDefinition and mark the elements. Here is
the cut-out-over-circle case from a client feature pack:
// definition
{
type: "portraitHero",
label: "Portrait hero",
category: "Custom",
schema: portraitHeroSchema,
component: PortraitHero,
defaultValue: { type: "portraitHero", photo: "" },
motionParts: [
{ key: "backdrop", label: "Circle" },
{ key: "photo", label: "Photo cut-out" },
],
}
// component
import { motionPartProps } from "@/lib/motion";
<div className="relative">
<div {...motionPartProps(block, "backdrop")}>
<div className="aspect-square rounded-full bg-[var(--accent)]" />
</div>
<div {...motionPartProps(block, "photo")} className="absolute inset-0">
<img src={block.photo} alt="" />
</div>
</div>
The site builder then sets Circle to zoom-in and Photo cut-out to fade-up
with a 300 ms delay, all from /admin. motionPartProps returns {} when a
part has no effect, so it is safe to spread on every render. Pass the
element's own inline style as the third argument and it is merged in. Part
keys are camelCase.
Put motion on a wrapper, not on an element with its own transform. The
animations use transform (and opacity), so they compose with Tailwind's
translate-* / scale-* / rotate-* utilities, which use separate
properties. An element whose own CSS sets transform would jump at the end of
the animation. Wrap it, as the backdrop example above does.
Layout. Only opacity and transform change, and a waiting element stays
at full size (just transparent), so nothing on the page moves. A block with a
custom effect is wrapped in one plain <div>. If a site's CSS targets
section + section, that block no longer matches.
Porting Elementor animations
Elementor elements carry elementor-invisible and
data-settings='{"_animation":"fadeInUp","_animation_delay":300}'. Map them to
motion (or to a part), and drop the Elementor classes:
| Elementor | effect |
|---|---|
fadeIn |
fade |
fadeInUp |
fade-up |
fadeInDown |
fade-down |
zoomIn |
zoom-in |
fadeInLeft / slideInLeft |
slide-left |
fadeInRight / slideInRight |
slide-right |
| anything else | the closest of the above; the set is deliberately small |
_animation_delay is already in ms, so it becomes delay unchanged.
animation_duration slow / normal / fast ≈ 2000 / 1250 / 800.
How it works
- The server renders
data-motion="<effect>"and CSS custom properties (--mp-motion-name,--mp-motion-delay,--mp-motion-duration) on each target, anddata-motion-blockon a block wrapper. None of this hides anything. MotionRuntimemounts the runtime once per page.BlockRendererandRevealrender it next to their content, so motion and its stylesheet arrive even on a site that overrideslayout.tsxorglobals.css.- The runtime does nothing if the visitor prefers reduced motion or the
browser has no IntersectionObserver. Otherwise it measures each target once.
Targets on screen or above stay as they are. Targets below the fold get
data-motion-state="armed"(opacity 0), and the first time one enters the viewport it getsdata-motion-state="in", which plays the keyframes once. Inside a block with a custom effect, built-in reveals are skipped, or used as the stagger pieces. - A MutationObserver re-runs the scan for content added later (client navigation), so every route behaves the same.
The only CSS rule that hides anything is [data-motion-state="armed"]. The
tests enforce it, along with the reduced-motion and no-JS behaviour.
Not covered
- Hero's load-in. Core's Hero animates its title on page load with framer-motion. That's a load animation, not a scroll entrance, and the Motion panel doesn't change it.
- Looping, hover or scroll-linked (parallax) motion. Out of scope; build those in a block component.
This text is maintained in thinq-site-core at docs/motion.md (commit e72488e) and published here unchanged.