176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
fix: switch labels say what they show
matin61c68fca546c
diff --git a/animations/04-micro-interactions/drag-to-reorder/README.md b/animations/04-micro-interactions/drag-to-reorder/README.mdindex 0978be73..e0a91edf 100644--- a/animations/04-micro-interactions/drag-to-reorder/README.md+++ b/animations/04-micro-interactions/drag-to-reorder/README.md@@ -47,7 +47,7 @@ Pointer Events cover mouse, pen and touch with one code path, and `setPointerCap|-----------|---------|--------|| Slide speed | Normal | How fast the passed items slide aside and the dropped one settles: slow is 420ms, normal 220ms and fast 120ms || How much it lifts | Subtle | Subtle grows the held item by 2% with a soft shadow; strong grows it by 6%, tilts it a little and deepens the shadow |-| Drag by the handle only | off | Only the grip starts a drag; when off, the whole row does, after a short press on touch screens |+| Drags by the handle only | off | Only the grip starts a drag; when off, the whole row does, after a short press on touch screens |## Production notes- **Save the order once, on drop.** Move the items with transforms while the drag lasts and rewrite the list (and send it to the server) only when the item is dropped; rebuilding the list on every pointer move makes it flicker and loses the pointer capture.diff --git a/animations/04-micro-interactions/drag-to-reorder/index.html b/animations/04-micro-interactions/drag-to-reorder/index.htmlindex 1c3db5cd..ec1ad1bf 100644--- a/animations/04-micro-interactions/drag-to-reorder/index.html+++ b/animations/04-micro-interactions/drag-to-reorder/index.html@@ -35,7 +35,7 @@.strong .lifted .card{transform:scale(1.06) rotate(-1.5deg)}.strong .card::after{box-shadow:0 18px 34px rgba(0,0,0,.65)}.grip{flex:none;display:flex;align-items:center;justify-content:center;width:44px;height:44px;margin-left:3px;border:1px solid transparent;border-radius:8px;background:none;color:var(--ui-muted);cursor:inherit;touch-action:none}.grip svg{width:20px;height:20px;fill:currentColor}- /* Drag by the handle only: the grip looks like the thing to hold, and only it starts a drag */+ /* Drags by the handle only: the grip looks like the thing to hold, and only it starts a drag */.by-grip .row{cursor:default}.by-grip .grip{border-color:rgba(255,255,255,.18);background:rgba(255,255,255,.06);color:var(--ui-text);cursor:grab}.tag{flex:none;width:10px;height:10px;border-radius:50%}.label{min-width:0;font-size:14px;color:var(--ui-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@@ -105,7 +105,7 @@<p class="hb-hint">Strong makes the task you hold grow, tilt and cast a deeper shadow.</p></div><div class="hb-setting">- <label class="hb-switch-row"><span>Drag by the handle only</span><input class="hb-switch" type="checkbox" role="switch" id="grip-tog" autocomplete="off"></label>+ <label class="hb-switch-row"><span>Drags by the handle only</span><input class="hb-switch" type="checkbox" role="switch" id="grip-tog" autocomplete="off"></label><p class="hb-hint">Only the grip starts a drag, so a finger on the rest of a row still scrolls the page.</p></div></div>diff --git a/animations/04-micro-interactions/spotlight-hover/README.md b/animations/04-micro-interactions/spotlight-hover/README.mdindex da19f36e..626c7343 100644--- a/animations/04-micro-interactions/spotlight-hover/README.md+++ b/animations/04-micro-interactions/spotlight-hover/README.md@@ -35,7 +35,7 @@ A mouse lights the grid while it moves over it, and the light fades out (an `opa|-----------|---------|--------|| Glow size | Medium | How far the light reaches: small, medium and large are 0.7, 1.15 and 1.7 times the grid's shorter side across || Color | Purple | The color of the light and of the lit edges; white looks the most natural on gray cards |-| Light the edges | On | The card edges near the pointer glow brightly; off, only the faces brighten |+| Lights the edges | On | The card edges near the pointer glow brightly; off, only the faces brighten || Lag | Short | How far the light trails a moving pointer: none follows it exactly, short closes 30% of the gap per 60 Hz frame and long 10% |## Production notesdiff --git a/animations/04-micro-interactions/spotlight-hover/index.html b/animations/04-micro-interactions/spotlight-hover/index.htmlindex 1248a934..4bfa2a1e 100644--- a/animations/04-micro-interactions/spotlight-hover/index.html+++ b/animations/04-micro-interactions/spotlight-hover/index.html@@ -111,7 +111,7 @@<p class="hb-hint">The color of the light and of the lit edges.</p></div><div class="hb-setting">- <label class="hb-switch-row"><span>Light the edges</span><input class="hb-switch" type="checkbox" role="switch" id="edge-tog" checked autocomplete="off"></label>+ <label class="hb-switch-row"><span>Lights the edges</span><input class="hb-switch" type="checkbox" role="switch" id="edge-tog" checked autocomplete="off"></label><p class="hb-hint">The card edges near the pointer glow brightly.</p></div></div>diff --git a/animations/06-3d-advanced/depth-map-photo/README.md b/animations/06-3d-advanced/depth-map-photo/README.mdindex d5792c08..b6f75a8a 100644--- a/animations/06-3d-advanced/depth-map-photo/README.md+++ b/animations/06-3d-advanced/depth-map-photo/README.md@@ -32,7 +32,7 @@ float t = 1., tp = 1., h = texture2D(uDep, uv + uOff * (1. - uFocus)).r - 1.;for (int i = 0; i < 24; i++) { if (h >= 0.) break; tp = t; t -= 1. / 24.; h = texture2D(uDep, uv + uOff * (t - uFocus)).r - t; }for (int i = 0; i < 5; i++) { float m = (t + tp) * .5; if (texture2D(uDep, uv + uOff * (m - uFocus)).r >= m) t = m; else tp = m; }vec2 p = uv + uOff * (t - uFocus);-gl_FragColor = vec4(texture2D(uImg, p).rgb, 1.); // Show the depth map mixes in the map's gray here+gl_FragColor = vec4(texture2D(uImg, p).rgb, 1.); // the Shows the depth map switch mixes in the map's gray here```Where a near shape moves aside, it uncovers a strip the photo never had, and the search fills it by stretching the pixels at the shape's edge. Because the near shapes were grown in the depth map, those edge pixels are background, so the strip fills with background instead of a smear of the tree.@@ -51,7 +51,7 @@ Pointer Events make a mouse, a pen and a finger aim the view alike; a mouse that| Parameter | Default | Effect ||-----------|---------|--------|| Depth strength | Medium | How far the nearest part slides against the farthest when the pointer reaches the edge of the picture: subtle is 2%, medium 3.5% and strong 5% of the picture's width; up and down move about a third as far, which keeps the stretched strips small |-| Show the depth map | off | Shows the gray depth map in place of the picture, moving the same way: white is near and black is far |+| Shows the depth map | off | Draws the gray depth map in place of the picture, moving the same way: white is near and black is far |## Production notes- **Getting a depth map**: depth-estimation models (MiDaS, Depth Anything) make one from any photo, phones save one with portrait-mode photos, and an image editor can paint one by hand, one gray shape per layer. Save it as a grayscale image the same size as the photo.diff --git a/animations/06-3d-advanced/depth-map-photo/index.html b/animations/06-3d-advanced/depth-map-photo/index.htmlindex c38e4c3c..223b454a 100644--- a/animations/06-3d-advanced/depth-map-photo/index.html+++ b/animations/06-3d-advanced/depth-map-photo/index.html@@ -72,7 +72,7 @@<p class="hb-hint">How far the near parts slide against the far ones.</p></div><div class="hb-setting">- <label class="hb-switch-row"><span>Show the depth map</span><input class="hb-switch" type="checkbox" role="switch" id="map-tog" autocomplete="off"></label>+ <label class="hb-switch-row"><span>Shows the depth map</span><input class="hb-switch" type="checkbox" role="switch" id="map-tog" autocomplete="off"></label><p class="hb-hint">The gray picture behind the effect: white is near, black is far.</p></div></div>