Native first
Transform and opacity only. IntersectionObserver replaces scroll polling; one rAF frame per pointer move.
Ocho Rios · Jamaica — a motion study
Ten small interactions, built with the browser's own APIs. Quiet enough for a sea-view apartment, responsive enough for a phone in the sun.
Scroll to explore
"The view does most of the talking."
Guest note · MarchThe kit
Native CSS transitions, requestAnimationFrame, IntersectionObserver and pointer events. No animation library, no build step, no dependencies. Every effect is opt-in through a data attribute and every one can be switched off in one place.
Transform and opacity only. IntersectionObserver replaces scroll polling; one rAF frame per pointer move.
Full keyboard paths, visible focus, inert closed menus, and prefers-reduced-motion honoured everywhere.
Magnetic pull, spotlight, tilt and the custom cursor never bind without a fine pointer.
The effects · part one
Four pointer-driven effects and one scroll behaviour. Hover states are duplicated for :focus-visible, so keyboard users see the same feedback.
Move the pointer close — release and it eases back with the global --ease-out token.
Wake to the horizon from the living room and the balcony.
Fast Wi-Fi, a proper desk, and shade for the laptop.
Mahogany Beach, cafés and the craft market within minutes.
One CSS custom property pair drives the light: --spot-x / --spot-y
from $185 / night
King bed, sea-facing balcony, blackout curtains.
from $165 / night
Quiet, cool, and a short walk from the pool.
from $195 / night
Outdoor dining, sunset light, room for six.
Angle budget: data-tilt="9" · hover scale: data-tilt-scale="1.03"
The default. 26 px of travel, scaled by the global intensity setting.
Direction is a variant, timing is a custom property.
Delays stagger at 120 ms so the group reads as a sequence.
07:10 — Coffee on the balcony. The light is doing the thing it does.
08:40 — A short walk to Mahogany Beach before the heat.
10:15 — Back to the desk. Sea view, fast Wi-Fi, no meetings.
12:30 — Lunch in town; the craft market is two streets over.
15:00 — Dunn's River Falls, twelve minutes away.
18:20 — Sundown from the terrace. The bar is now opaque.
20:00 — Dinner, then nothing in particular.
The real navigation above uses the same data-sticky-nav hook: a transparent bar over the hero, then a blurred sand surface, a hairline and a long soft shadow. Height and padding transition together, so nothing jumps.
Scroll inside the small frame to watch the state flip.
The effects · part two
The quieter half: hover confirmation, a dropdown that behaves like a menu, an optional cursor, anchor scrolling with the nav offset baked in, and a way back.
Take the tour
Hover and tab through — the fill, lift and arrow all share one duration token.
The preference is stored in localStorage. Form fields always keep the native cursor.
No offset fudge: the nav height is measured at click time.
The floating control sits below the navigation and above the content, with a 44 px+ hit area and a visible focus ring. It is the button in the bottom-right corner of this page.
Playground
Duration, intensity and easing are tokens, not magic numbers. Move a slider and the whole page follows — including the magnetic buttons and tilt cards.
Adjust intensity, then hover this button. Changes apply live.
Documentation
Two files. No package manager. The library is a single ES module, and every effect is driven by markup, so the site keeps working if a script fails to load.
Copy motion/ into your project and reference both files.
<!-- in <head> -->
<link rel="stylesheet" href="motion/motion.css">
<!-- before </body> -->
<script type="module" src="motion/motion.js"></script>
Serve over HTTP. ES modules do not load from file://; the site's existing server is fine.
Add a data attribute. Options are element attributes; defaults are sensible.
| Attribute | Options |
|---|---|
data-magnetic | strength · data-magnetic-max |
data-spotlight | --spot-color · data-spotlight-size |
data-tilt | max degrees · data-tilt-scale |
data-reveal | up · fade · left · right · scale |
data-sticky-nav | scroll threshold in px |
data-dropdown | data-dropdown-hover |
data-cursor-toggle | any button |
data-back-to-top | show-after threshold |
data-theme-toggle | any button |
Tokens live on :root; runtime settings go through one function.
// global tokens
:root {
--dur: 260ms;
--dur-slow: 620ms;
--ease-out: cubic-bezier(.22,1,.36,1);
}
// runtime
import { motion, configureMotion } from './motion.js';
configureMotion({ intensity: 0.8, duration: 1.2, easing: 'spring' });
motion.replayReveals();
motion.setCursorEnabled(true);
motion.destroy(); // before a client-side route swap
What the kit does without being asked.
The demo is also the test fixture. Playwright covers the behaviour in a real browser.
motion/
motion.css # tokens + primitives
motion.js # ES module, auto-boots
demo.css # this page only
index.html # showcase + docs
README.md # integration notes
# from the repo root
npx playwright test tests/motion.spec.js
Worth knowing before you ship.
html.has-js, so no-JS visitors see everything.demo.css; it is not part of the library.--spot-color and --cursor-color to match your palette.motion.refresh() after injecting new markup.