00Overview 01Magnetic 02Spotlight 033D tilt 04Scroll reveal 05Playground 06Docs View the stay

Ocho Rios · Jamaica — a motion study

A slower kind of luxury.

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.

4.9 guest rating Oceanfront 12 min to Dunn's River
Scroll to explore
The Caribbean sea seen from the Carib212 balcony in Ocho Rios
18.41° N · 77.09° W
Carib212 · 1BR

"The view does most of the talking."

Guest note · March

The kit

Ten interactions,
one small file.

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.

01

Native first

Transform and opacity only. IntersectionObserver replaces scroll polling; one rAF frame per pointer move.

02

Accessible by default

Full keyboard paths, visible focus, inert closed menus, and prefers-reduced-motion honoured everywhere.

03

Touch-aware

Magnetic pull, spotlight, tilt and the custom cursor never bind without a fine pointer.

The effects · part one

Touch, light
and depth.

Four pointer-driven effects and one scroll behaviour. Hover states are duplicated for :focus-visible, so keyboard users see the same feedback.

Magnetic button The control leans toward the pointer, then springs home. Strength is a per-element data attribute.

pointer: fine
data-magnetic="0.16"
data-magnetic="0.34"
data-magnetic="0.62"

Move the pointer close — release and it eases back with the global --ease-out token.

Cursor spotlight A soft radial light follows the pointer across a section or card. One gradient layer, no repaint of the content.

pointer: fine
A

Sea view

Wake to the horizon from the living room and the balcony.

B

Work-ready

Fast Wi-Fi, a proper desk, and shade for the laptop.

C

Walkable

Mahogany Beach, cafés and the craft market within minutes.

One CSS custom property pair drives the light: --spot-x / --spot-y

3D tilt card Rotation is clamped to the card's own angle budget, with a soft-light glare that tracks the pointer.

pointer: fine
Living area with sea view at Carib212 from $185 / night

The Ocean Suite

King bed, sea-facing balcony, blackout curtains.

King bedroom with ocean light from $165 / night

Garden Room

Quiet, cool, and a short walk from the pool.

Private patio at Carib212 from $195 / night

The Terrace

Outdoor dining, sunset light, room for six.

Angle budget: data-tilt="9" · hover scale: data-tilt-scale="1.03"

Scroll reveal Each element enters once, then the observer lets go. Variants: up, fade, left, right, scale.

IntersectionObserver
1 / 3

Fade up

The default. 26 px of travel, scaled by the global intensity setting.

2 / 3

From the side

Direction is a variant, timing is a custom property.

3 / 3

Scale in

Delays stagger at 120 ms so the group reads as a sequence.

Revealed elements are never re-hidden on scroll.

Sticky navigation The bar is always there; only its surface changes at the threshold. The page above demonstrates it — scroll a little.

passive scroll · rAF
Carib212 Scroll me

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.

At the top is-stuck

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

Feedback, menus
and wayfinding.

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.

Hover feedback Every interactive surface answers on hover and focus. Movement is 2–4 px, never a layout shift.

CSS only

Chips

Hover and tab through — the fill, lift and arrow all share one duration token.

Custom cursor Optional and remembered. A dot tracks instantly, a ring trails behind and grows over anything interactive.

opt-in · desktop
Custom cursor Hidden on touch and when reduced motion is requested.
Dark mode Paired palettes; contrast checked separately.

The preference is stored in localStorage. Form fields always keep the native cursor.

Smooth scrolling Anchor links glide to their target, offset by the sticky bar's live height. Focus moves too, for screen readers.

native scrollTo

No offset fudge: the nav height is measured at click time.

Back to top Appears after 560 px, leaves the tab order while hidden, and returns focus to the page heading.

fixed · 50 px

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

Tune the tempo.

Duration, intensity and easing are tokens, not magic numbers. Move a slider and the whole page follows — including the magnetic buttons and tilt cards.

1.00×
1.00
ease-out
Motion enabled Off behaves like prefers-reduced-motion.

Adjust intensity, then hover this button. Changes apply live.

Documentation

Drop in,
opt in.

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.

1 · Install

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.

2 · Opt in

Add a data attribute. Options are element attributes; defaults are sensible.

AttributeOptions
data-magneticstrength · data-magnetic-max
data-spotlight--spot-color · data-spotlight-size
data-tiltmax degrees · data-tilt-scale
data-revealup · fade · left · right · scale
data-sticky-navscroll threshold in px
data-dropdowndata-dropdown-hover
data-cursor-toggleany button
data-back-to-topshow-after threshold
data-theme-toggleany button

3 · Configure

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

4 · Guardrails

What the kit does without being asked.

  • Skips pointer effects on coarse pointers and when reduced motion is set.
  • Uses transform and opacity; no width, height or top animation.
  • Batches pointer moves into one requestAnimationFrame.
  • Unobserves revealed elements; one listener per feature, aborted on destroy.
  • Returns focus after menus close and anchors jump.
  • Keeps content visible when JavaScript is unavailable.

5 · Files & tests

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

6 · Production notes

Worth knowing before you ship.

  • The hidden state is scoped to html.has-js, so no-JS visitors see everything.
  • Drop demo.css; it is not part of the library.
  • Set --spot-color and --cursor-color to match your palette.
  • Call motion.refresh() after injecting new markup.
  • Respect the browser's own smooth-scroll preference via the tokens; do not force it.