@joinamply/motion
v0.2.1
Published
Attribute-driven scroll animations for Webflow. Waits on the Amply library manager for GSAP; ships from jsDelivr as one script tag.
Readme
Amply Motion
Attribute-driven scroll animations for Webflow. [anim-group] on a wrapper, [anim="type"]
on each element — no timeline to wire, no Interactions panel.
Sunset when Webflow shipped ix3; back because ix3 didn't work out. The difference this time is delivery: it ships from a CDN as one script tag instead of a 300-line pasted embed, so a bug fix is a version bump rather than an edit on every client site.
Internal — strip on duplication. Like
framework-app/andinput-enhancer/, this directory does not ship to clients. Delete it when the starter is duplicated. Client sites consume the published package from jsDelivr; they never need the source.
Install on a page
Two embeds in Project Core, then the toggles:
| | Where | What |
|---|---|---|
| 1 | 🎨 Styles | webflow/styles-embed.html — the pre-hide CSS |
| 2 | ⚡ Codes | webflow/codes-embed.html — the script tag |
| 3 | toggles | GSAP → Main + ScrollTrigger, plus SplitText for text-fill |
The CSS stays on the page and never moves to the CDN. It is render-blocking-critical: it is what hides an element before GSAP can reach it. Served over the network it would flash the final content, or — if the request failed — hide copy permanently. The JS is allowed to be late; the CSS is not.
Animation types
| | |
|---|---|
| Reveals | slide-up slide-up-growing slide-down slide-left slide-right grow-in grow-out fade-in fade-out |
| Scrubbed | parallax-up parallax-down parallax-left parallax-right · text-fill |
| Other | counter |
<div anim-group anim-stagger="0.1">
<h2 anim="slide-up">Headline</h2>
<p anim="slide-up" anim-delay="0.1">Body copy</p>
<a anim="fade-in" anim-order="3">Call to action</a>
</div>Attributes
| Attribute | On | Default | Does |
|---|---|---|---|
| anim | element | — | the animation type. Empty (anim="") means none |
| anim-group | wrapper | — | children stagger in on one timeline |
| anim-duration | element | 0.8 | seconds |
| anim-delay | element | 0 | seconds |
| anim-ease | element | power3.out | any GSAP ease |
| anim-distance | element | 40 (100 parallax) | px travelled |
| anim-stagger | group | 0.12 | seconds between children |
| anim-order | element | DOM order | explicit sequence; equal values start together. Empty means unset |
| anim-once | group | true | "false" replays on scroll-back |
| anim-start | either | top 80% | ScrollTrigger start |
| anim-end | element | varies | ScrollTrigger end (scrubbed types) |
| anim-scrub | element | 2 | parallax catch-up, seconds |
anim-once goes on the wrapper, not the children — the group's timeline owns the toggle.
Empty values are allowed, and mean "none". A Webflow component prop bound to an attribute
is always written, so an unset Animation prop ships anim="" and an unset order prop ships
anim-order="". Motion skips an empty anim (it isn't pre-hidden, animated or warned about)
and ignores an empty anim-order, so a component can carry an Animation prop that is usually
left blank. This needs 0.2.1 and the 0.2.1 pre-hide CSS, which excludes [anim=''].
An element can carry anim and anim-group: it reveals in its parent group (or on its
own), and its children stagger on its timeline.
Counters read their target from their own text, then count to it: counter-duration,
counter-separator, counter-increment, on the number or its group.
text-fill dims to --anim-fill-dim (default 0.18) and brightens per character.
Custom animation types
A project can teach Motion a new anim value so its own effect takes part in the same
choreography as the built-ins. Register from an ⚡ Codes embed:
<script>
window.AmplyMotion = window.AmplyMotion || [];
window.AmplyMotion.push((motion) => {
// declarative — for a property Motion cannot infer a rest value for
motion.register('blur-in', {
from: { opacity: 0, filter: 'blur(12px)' },
to: { opacity: 1, filter: 'blur(0px)' },
});
// custom JS — return a timeline; Motion drops it into the group at this element's slot
motion.register('odometer', (el, gsap) => {
const tl = gsap.timeline();
tl.to(el, { opacity: 1, duration: 0.3 })
.from(el.querySelectorAll('.digit'), { yPercent: 120, stagger: 0.08 }, 0);
return tl;
});
});
</script>window.AmplyMotion follows the same shape as window.Webflow — an array you push onto
before Motion loads, which it drains and replaces with the live API. So registration works
regardless of which script the browser evaluates first.
Why this exists at all: the one thing hand-written GSAP cannot do is reach into a
[anim-group]'s timeline. If your effect needs to land at a stagger slot alongside the
reveals around it, register it. If it runs on its own, leave it as hand-written GSAP in the
component — a registry is not a reason to move every animation into anim.
Rules for a returned timeline
Measured against GSAP 3.15, and every one of these fails silently — which is why Motion checks for them and warns:
| What you return | Result |
|---|---|
| unpaused timeline, no scrollTrigger | ✅ works |
| gsap.timeline({ paused: true }) | ❌ parent ignores it; duration stays 0 |
| …un-paused after being added | ❌ still ignored — the un-pause does not rescue it |
| a timeline with its own scrollTrigger | ❌ ignored, no error, and it runs detached from the group |
Creating it unpaused is safe: GSAP does not render between creation and the add, so it
cannot start early.
Two things you still own
The pre-hide CSS. Registration happens in JavaScript, far too late to hide anything. Opacity is already covered by the catch-all, but anything else needs a rule in the 🎨 Styles embed:
@media (prefers-reduced-motion: no-preference) {
html:not(.anim-fallback) [anim='blur-in'] { filter: blur(12px); }
}
.wf-design-mode [anim='blur-in'] { filter: none !important; }Ending visible. The catch-all sets opacity: 0 on any [anim] value including yours,
so a custom timeline must bring the element back to opacity: 1 or it stays invisible.
Guard rails
- built-in names cannot be redefined — the vocabulary means the same thing on every site
- an unknown
animvalue warns and falls back to a fade, so a typo is no longer silent - registering after Motion has initialised warns rather than doing nothing quietly
How GSAP gets here
It isn't bundled. GSAP arrives through the Amply library manager, gated by the boolean
props on Project Core, exactly like every other library on the site. Motion waits for
it with onLibrariesLoaded and reads the DOM to decide what to ask for — no flags to
remember, because [anim="text-fill"] on the page is the request for SplitText.
Three manager behaviours shape src/gate.ts, all verified against the shipped
embed on 2026-09-12:
- Late subscribers resolve — it checks
loadedLibrariesbefore attaching listeners, so we don't have to race its boot. - A disabled toggle never resolves — no
loadLibrarycall, no event, callback dropped forever. This is why Motion carries its own timeout: without it, one unchecked box means a page of permanently invisible text. - Plugins register in their own
Webflow.push— ours can be queued first, sowindow.ScrollTriggermay exist unregistered. Motion callsregisterPlugindefensively; it's idempotent.
Failure behaviour
Motion never leaves a page blank. Every path that can't animate reveals everything at rest
by putting .anim-fallback on <html>, and says why:
| Situation | What happens |
|---|---|
| prefers-reduced-motion: reduce | revealed at rest, silently — that's the point |
| No [anim] on the page | nothing runs; the manager is never even asked |
| Main or ScrollTrigger off | revealed after 4s + warning naming only the toggle that's actually missing |
| No Project Core on the page | revealed + warning telling you to add the component |
| webflow.js never drains the ready queue | revealed after 5s by the module-scope failsafe |
| SplitText off | everything else still animates. text-fill uses the built-in splitter and logs an informational note |
That last row matters: SplitText is the one optional dependency, so a forgotten checkbox
degrades one effect instead of disabling every animation on the page. The hard requirement is
gsap + scrolltrigger only.
The failsafe is armed at module scope, deliberately outside Webflow.push — a failsafe that
lives inside the callback can't save you from the callback never running, which is exactly
what happens if webflow.js is missing or blocked.
All six paths are covered by the harness (test/), one ?mode= each.
Development
npm install
npm run build # → dist/motion.js (IIFE, minified, sourcemapped)
npm run typecheck
npx serve . -l 4321 # harness → http://localhost:4321/test/IIFE rather than ESM: plugins come from the manager, so there is nothing left to code-split, and a plain script drops the module-ordering subtleties.
Publishing
The published bundle is public. jsDelivr cannot serve private npm packages, so there is no private-CDN path. The source directory stays internal and is stripped on duplication; the compiled bundle is world-readable once published. That is normal for this kind of library (Finsweet ship theirs the same way) but it is a deliberate choice, not an accident.
First time only — both steps are on npmjs.com and need the Amply account:
- Create the
@joinamplyorg (npmjs.com → Add organization). Free for public packages. npm login
Then, every release:
npm version patch # or minor / major
npm publish # prepublishOnly runs typecheck + build firstnpm publish --dry-run prints the exact tarball without sending anything — 6 files, ~20 kB.
Give jsDelivr a minute, then confirm the URL actually serves before pointing a site at it:
curl -sI https://cdn.jsdelivr.net/npm/@joinamply/[email protected]/dist/motion.js | head -1Then bump the pinned version in webflow/codes-embed.html and on any site that should
follow.
Pin exact versions everywhere — including the starter. An exact version is immutable on
jsDelivr and cached permanently; a @0.1 range has to be re-resolved and that resolution is
cached too, so a freshly published fix can take a long time to reach pages on the range and
you cannot tell which build a visitor actually ran. Bumping one line deliberately is worth
more than automatic upgrades you can't observe.
Releases
0.2.1
- An empty
anim=""means no animation: it is skipped, not faded in as an unknown type, and no longer warns. The pre-hide CSS excludes it (:not([anim=''])). On each site, update the 🎨 Stylesanimembed first, then the ⚡ Codes pin. The new CSS is safe under 0.2.0 (an empty element shows, then fades in as before); the 0.2.1 script under the old CSS is not, because the CSS keeps hiding what the script now skips, so those elements never appear. - An empty
anim-order=""counts as absent, so a group with one no longer starts every child at once. - An element with both
animandanim-groupnow animates (in its parent group, or on its own) instead of staying pre-hidden. - A page whose only
animvalues are empty doesn't boot at all, so it no longer asks the library manager for GSAP or warns about its toggles.
Reported from a component-built Webflow page in amply-clients/project-starter-webflow#1;
tracked in #11.
The attribute prefix
Kept as anim / anim-* — it's the existing API and reads well in the Designer. Collision
risk with another library is real but theoretical. If it ever bites, P in
src/config.ts is the single place the prefix is spelled; changing it to
am renames the whole surface.
