Snap guide — grid hop
Variant: Grid
A box dragged diagonally across a 20px dot grid: a dashed outline glides with the pointer while the box hops a cell at a time, and the diagonal comes out as a staircase. The drag runs at a constant 36px/s — the one place linear is honest, because it makes the hop schedule pure rounding: x hops at a tenth, three tenths, a half of the way and so on, y at a quarter and three quarters, each the moment the pointer crosses a cell’s midpoint. Every hop is the family’s 78ms snap, never a teleport; a jump the eye cannot follow reads as a redraw, and one that eases longer drags behind the hand. Without the ghost the hops look like the object’s own idea, so it is shown for exactly as long as the drag lasts; the box reaches the last cell at the final midpoint and the ghost catches up with it there, so on release the two are one. Reach for it in grid-snapped editors, seat maps, dashboard tiles and calendar drags — anywhere position is quantized but the pointer is not.
The source
A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Snap guide — grid hop</title>
<style>
:root {
/* Neutrals — fixed, never remixed. */
--ivory: #faf9f5;
--paper: #ffffff;
--oat: #e3dacc;
--slate: #141413;
/* Knobs — the remix API. A knob exists iff declared here and used below. */
--hue: 38.8;
--lift: 0;
--chroma: 1;
--round: 1;
--speed: 1;
/* Accents — derived from the knobs with the family's offsets baked in,
so one hue roll moves them together. Defaults reproduce the original hex. */
--clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
--clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
--olive: oklch(
calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3)
);
--rust: oklch(
calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3)
);
/* Clock — 5s. The drag itself is 3s at a constant 36px/s, so every
hop lands at the moment the pointer crosses a cell's midpoint and
the crossing times can be read straight off the keyframes. */
--cycle: 5s;
--t: calc(var(--cycle) / var(--speed));
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
/* The hop — the family's 78ms snap, once per cell. */
--ease-accent: cubic-bezier(0.32, 0.72, 0, 1);
--_muted: color-mix(in srgb, var(--slate) 52%, transparent);
--_bar: color-mix(in srgb, var(--oat) 80%, transparent);
--_dot: color-mix(in srgb, var(--slate) 22%, transparent);
--_ghost: color-mix(in srgb, var(--slate) 38%, transparent);
--_clear: color-mix(in srgb, var(--slate) 0%, transparent);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
min-height: 100vh;
display: grid;
place-items: center;
background: var(--ivory);
font-family:
system-ui,
-apple-system,
'Segoe UI',
Roboto,
sans-serif;
color: var(--slate);
}
.rig {
display: grid;
gap: 12px;
justify-items: center;
animation: rig var(--t) linear infinite;
}
.cap,
.foot {
font-size: 11px;
letter-spacing: 0.03em;
color: var(--_muted);
}
/* Dots sit on exact multiples of 20px, so every resting corner of the
object lands on one. */
.stage {
position: relative;
width: 260px;
height: 150px;
background: var(--paper);
border: 1px solid var(--oat);
border-radius: calc(10px * var(--round));
overflow: hidden;
}
/* The layer starts 10px in so the first row and column are whole
dots at 20px rather than halves under the border. */
.stage::before {
content: '';
position: absolute;
inset: 10px 0 0 10px;
background-image: radial-gradient(circle at 1px 1px, var(--_dot) 1px, var(--_clear) 1.6px);
background-size: 20px 20px;
background-position: 9px 9px;
}
.obj {
position: absolute;
left: 60px;
top: 40px;
width: 40px;
height: 40px;
padding: 9px 8px;
display: grid;
align-content: center;
gap: 5px;
background: var(--paper);
border: 1.5px solid var(--slate);
border-radius: calc(4px * var(--round));
animation: hop var(--t) infinite;
}
.obj i {
display: block;
height: 4px;
border-radius: 999px;
background: var(--_bar);
}
.obj i + i {
width: 60%;
}
.hand {
position: absolute;
inset: 0;
animation: hand var(--t) infinite;
}
/* The continuous position the grid is rounding. Without it the hops
look like the object's own idea. */
.ghost {
position: absolute;
left: 60px;
top: 40px;
width: 40px;
height: 40px;
border: 1px dashed var(--_ghost);
border-radius: calc(4px * var(--round));
opacity: 0;
animation: ghost var(--t) linear infinite;
}
.ptr {
position: absolute;
left: 79px;
top: 59px;
width: 14px;
height: 18px;
opacity: 0;
animation: ptr var(--t) linear infinite;
}
.arrow {
display: block;
width: 100%;
height: 100%;
fill: var(--slate);
stroke: var(--paper);
stroke-width: 1.4;
stroke-linejoin: round;
}
.tip {
position: absolute;
left: -9px;
top: -9px;
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--clay-d);
opacity: 0;
transform: scale(0.5);
animation: grip var(--t) infinite;
}
/* Constant speed, (0,0) to (100,40) between 10% and 70%. A pointer
being dragged at a steady rate is the one place linear is honest:
it makes the hop schedule legible as pure rounding. */
@keyframes hand {
0%,
10% {
transform: translate(0, 0);
animation-timing-function: linear;
}
70%,
72% {
transform: translate(100px, 40px);
animation-timing-function: var(--ease-out);
}
82%,
95% {
transform: translate(116px, 58px);
}
95.1%,
100% {
transform: translate(0, 0);
}
}
/* round(pointer / 20) × 20, one hop per midpoint crossed: x at 0.1,
0.3, 0.5, 0.7, 0.9 of the drag and y at 0.25 and 0.75, so the path
comes out as a staircase. Each hop is a 78ms tween, never a
teleport — a jump the eye cannot follow reads as a redraw. */
@keyframes hop {
0%,
16% {
transform: translate(0, 0);
animation-timing-function: var(--ease-accent);
}
17.56%,
25% {
transform: translate(20px, 0);
animation-timing-function: var(--ease-accent);
}
26.56%,
28% {
transform: translate(20px, 20px);
animation-timing-function: var(--ease-accent);
}
29.56%,
40% {
transform: translate(40px, 20px);
animation-timing-function: var(--ease-accent);
}
41.56%,
52% {
transform: translate(60px, 20px);
animation-timing-function: var(--ease-accent);
}
53.56%,
55% {
transform: translate(80px, 20px);
animation-timing-function: var(--ease-accent);
}
56.56%,
64% {
transform: translate(80px, 40px);
animation-timing-function: var(--ease-accent);
}
65.56%,
95% {
transform: translate(100px, 40px);
}
95.1%,
100% {
transform: translate(0, 0);
}
}
/* The ghost lives only while the drag does. The box reaches the last
cell at the final midpoint crossing; the ghost catches up with it
there at 70%, and on release the two are one. */
@keyframes ghost {
0%,
10% {
opacity: 0;
}
12%,
69% {
opacity: 1;
}
71%,
100% {
opacity: 0;
}
}
@keyframes ptr {
0% {
opacity: 0;
}
5%,
72% {
opacity: 1;
}
82%,
100% {
opacity: 0;
}
}
@keyframes grip {
0%,
8.5% {
opacity: 0;
transform: scale(0.5);
animation-timing-function: var(--ease-out);
}
9%,
71.5% {
opacity: 0.4;
transform: scale(1);
animation-timing-function: var(--ease-out);
}
72.5%,
100% {
opacity: 0;
transform: scale(0.5);
}
}
@keyframes rig {
0% {
opacity: 0;
}
3%,
89% {
opacity: 1;
}
94%,
100% {
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
/* No travel. The object sits on its cell and the grid it is bound
to breathes, so the constraint is still the subject. */
.rig,
.obj,
.hand {
animation: none;
}
.hand {
opacity: 0;
}
.stage::before {
animation: dots-rest calc(var(--t) * 1.2) ease-in-out infinite;
}
@keyframes dots-rest {
0%,
100% {
opacity: 0.45;
}
50% {
opacity: 1;
}
}
}
</style>
</head>
<body>
<div
class="rig"
role="img"
aria-label="A box is dragged diagonally across a dot grid. A dashed outline follows the pointer smoothly while the box itself hops one twenty-pixel cell at a time, in a staircase, landing under the pointer on release."
>
<p class="cap">glide · round · hop</p>
<div class="stage">
<div class="obj"><i></i><i></i></div>
<div class="hand">
<div class="ghost"></div>
<span class="ptr">
<span class="tip"></span>
<svg class="arrow" viewBox="0 0 14 18">
<path d="M1 1 L1 14.8 L4.5 11.6 L6.7 16.6 L9.3 15.4 L7.1 10.5 L11.8 10.3 Z" />
</svg>
</span>
</div>
</div>
<p class="foot">the pointer glides · the object hops by 20</p>
</div>
</body>
</html>
The variant family
Same idea, one axis moved. Compare them side by side before you commit.