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: Before/After Slider review: the knob keeps a 48x48 grab area at both ends of Top and bottom, and the README says what Line only leaves to grab
matin1ff1f36a3e23
diff --git a/animations/04-micro-interactions/before-after-slider/README.md b/animations/04-micro-interactions/before-after-slider/README.mdindex 9ee70145..61fc2b1e 100644--- a/animations/04-micro-interactions/before-after-slider/README.md+++ b/animations/04-micro-interactions/before-after-slider/README.md@@ -35,7 +35,7 @@ A press that does not move glides the line to it, eased by the time that passes.| Parameter | Default | Effect ||-----------|---------|--------|| Split | Left and right | Which way the line runs: left and right shows After to the left of an upright line, dragged anywhere on the pictures; top and bottom shows After below a level line, dragged by its handle only |-| Handle | Knob | What there is to grab: knob is a round button with two arrows, bar a narrow bar along the line, line only the bare line (still grabbed across a strip about as wide as a fingertip) |+| Handle | Knob | What there is to grab: knob is a round button with two arrows, bar a narrow bar along the line, line only the bare line, with nothing showing where to grab (the knob's fingertip-sized grab area stays, unseen, on the middle of the line) || Shows labels | on | Before and After name each side from a corner, and each fades out when the line comes within a few pixels of it |## Production notesdiff --git a/animations/04-micro-interactions/before-after-slider/index.html b/animations/04-micro-interactions/before-after-slider/index.htmlindex 6fc9e940..0e4f1457 100644--- a/animations/04-micro-interactions/before-after-slider/index.html+++ b/animations/04-micro-interactions/before-after-slider/index.html@@ -28,7 +28,7 @@@property --v{syntax:"<number>";inherits:false;initial-value:.5}.stage{position:relative;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);background:#0b0b0d;-webkit-user-select:none;user-select:none}.defs{position:absolute;width:0;height:0;overflow:hidden}- .ba{position:relative;min-width:0;overflow:hidden;touch-action:pan-y;cursor:ew-resize}+ .ba{position:relative;min-width:0;overflow:hidden;touch-action:pan-y;cursor:ew-resize;container-type:size}.vert .ba{cursor:pointer}.layer,.win,.pic,.rail{position:absolute;inset:0}.pic svg{display:block;width:100%;height:100%}@@ -46,6 +46,7 @@/* The handle: a slider the keyboard can move too, at least 48px to touch whatever its look */.handle{position:absolute;left:0;top:50%;width:48px;height:48px;margin:-24px 0 0 -24px;display:grid;place-items:center;border-radius:24px;pointer-events:auto;cursor:grab;touch-action:none}.vert .handle{left:50%;top:0}+ .vert .handle{translate:0 clamp(calc(24px - (1 - var(--v)) * 100cqh), 0px, calc(var(--v) * 100cqh - 24px))}.h-bar .handle{height:68px;margin-top:-34px}.vert.h-bar .handle{width:68px;height:48px;margin:-24px 0 0 -34px}.grip{display:grid;place-items:center;width:44px;height:44px;border-radius:50%;background:#fff;color:#16161a;box-shadow:0 2px 10px rgba(0,0,0,.4)}@@ -351,7 +352,7 @@twin.removeAttribute('id');stage.insertBefore(twin,ba);findMovers();}// The parts that move with the line: the window, the picture in it, and the line with its handle (the copy's too)- function findMovers(){movers=[...stage.querySelectorAll('.win,.win .pic,.rail')]}+ function findMovers(){movers=[...stage.querySelectorAll('.win,.win .pic,.rail,.handle')]}// The mode switch draws the mode at once. The views hold the line at 70% when it rests in the middle; Normal gets it back.document.addEventListener('hb:mode',e=>{mode=e.detail.mode;pic.setAttribute('aria-label',LABELS[mode]);diff --git a/skills/animation-handbook/references/04-micro-interactions.md b/skills/animation-handbook/references/04-micro-interactions.mdindex d4e4259d..c7d4d50b 100644--- a/skills/animation-handbook/references/04-micro-interactions.md+++ b/skills/animation-handbook/references/04-micro-interactions.md@@ -870,5 +870,5 @@ Add a before-and-after slider to [the two pictures you want to compare]. Stack t**Settings** (the choice in bold is where the demo starts; each line ends with what the setting does, with the demo's values):- Split: **Left and right** · Top and bottom. Which way the line runs: left and right shows After to the left of an upright line, dragged anywhere on the pictures; top and bottom shows After below a level line, dragged by its handle only.-- Handle: **Knob** · Bar · Line only. What there is to grab: knob is a round button with two arrows, bar a narrow bar along the line, line only the bare line (still grabbed across a strip about as wide as a fingertip).+- Handle: **Knob** · Bar · Line only. What there is to grab: knob is a round button with two arrows, bar a narrow bar along the line, line only the bare line, with nothing showing where to grab (the knob's fingertip-sized grab area stays, unseen, on the middle of the line).- Shows labels: **on** · off. Before and After name each side from a corner, and each fades out when the line comes within a few pixels of it.