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: Magnifier Lens review: See inside captions measure the lens box so they stay clear of it under reduced motion, the help line, README Touch note and prompt say a finger drags the lens without scrolling the page, README names only Drift
matin405eaffce443
diff --git a/animations/04-micro-interactions/magnifier-lens/README.md b/animations/04-micro-interactions/magnifier-lens/README.mdindex 4e95830d..91f89440 100644--- a/animations/04-micro-interactions/magnifier-lens/README.md+++ b/animations/04-micro-interactions/magnifier-lens/README.md@@ -32,8 +32,8 @@ The copy is drawn at its full bigger size, not scaled up with a transform: a lay- **Use a bigger image.** Stretching the same small image only enlarges its pixels and the detail blurs; load a version two to four times larger (with `srcset`, or lazily when the pointer first arrives) and use it as the lens's copy or as its background.- **Size it, then move it.** Give the copy its final size in layout and move it only with transforms; scaling it up with a transform after the browser has drawn it as a layer blurs it.- **Background-image variant.** A lens can also be a single element whose background is the large image, moved with `background-position`; that repaints the lens on every move, which is fine for small lenses.-- **Touch and keyboard.** Show the lens above the finger, flip it below near the top edge, and give keyboard users focus, arrow keys and Escape.-- **Libraries.** Drift, Zoomist and many shop themes package the same idea; in a React app, react-medium-image-zoom or a small custom hook does it.+- **Touch and keyboard.** Show the lens above the finger and flip it below near the top edge; put `touch-action: none` on the picture only, so a drag moves the lens and the page still scrolls around it. Give keyboard users focus, arrow keys and Escape.+- **Libraries.** Drift and many shop themes package the same idea; in a React app, a small custom hook around the same two transforms does it.- **Reduced motion.** Let the lens appear and go at once instead of growing.## See alsodiff --git a/animations/04-micro-interactions/magnifier-lens/index.html b/animations/04-micro-interactions/magnifier-lens/index.htmlindex a9aa82a7..cd3dda2a 100644--- a/animations/04-micro-interactions/magnifier-lens/index.html+++ b/animations/04-micro-interactions/magnifier-lens/index.html@@ -76,7 +76,7 @@<section class="hb-step hb-watch" aria-labelledby="hb-watch-title"><div class="hb-step-head"><span class="hb-num" aria-hidden="true">1</span>- <div><h2 id="hb-watch-title">Hover it</h2><p>Point at the watch or touch it, or press Show me.</p></div>+ <div><h2 id="hb-watch-title">Hover it</h2><p>Point at the watch, drag a finger across it (or Tab to it and use the arrow keys), or press Show me.</p></div></div><div class="seg hb-modes" role="group" aria-label="What the box shows" data-hb-modes><button type="button" data-hb-mode="normal" class="on" aria-pressed="true">Normal</button>@@ -183,7 +183,7 @@<div><h2 id="hb-prompt-title">Copy the prompt</h2><p>Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.</p></div></div><div class="hb-card">- <p class="hb-prompt">Add a magnifier lens to [the product photo or detailed picture people want to inspect]. While the pointer is over the picture, show a lens there holding an enlarged copy, placed so the spot under the pointer sits in the middle of the lens. Fill the lens from a larger, sharper version of the picture, never the same small one stretched, and move the lens and the copy with transforms only. On touch screens, show it while a finger is down, just above the finger; from the keyboard, show it on focus and move it with the arrow keys. If the visitor has reduced motion turned on, let it appear without growing. Match the settings listed below.</p>+ <p class="hb-prompt">Add a magnifier lens to [the product photo or detailed picture people want to inspect]. While the pointer is over the picture, show a lens there holding an enlarged copy, placed so the spot under the pointer sits in the middle of the lens. Fill the lens from a larger, sharper version of the picture, never the same small one stretched, and move the lens and the copy with transforms only. On touch screens, show it while a finger is down, just above the finger, and let a drag move it without scrolling the page; from the keyboard, show it on focus and move it with the arrow keys. If the visitor has reduced motion turned on, let it appear without growing. Match the settings listed below.</p><div class="hb-chips-box" hidden><p class="hb-chips-title">Your settings</p><ul class="hb-chips"></ul>@@ -326,7 +326,7 @@// leaves the other two clear (the top left, unless the lens is close to it); all are measured before any moves, so the page lays// out oncefunction placeCaps(){- const s=stage.getBoundingClientRect(),g=real.lens.firstElementChild.getBoundingClientRect(),c=real.whole.getBoundingClientRect();+ const s=stage.getBoundingClientRect(),g=real.lens.getBoundingClientRect(),c=real.whole.getBoundingClientRect();const size=caps.map(el=>[el.offsetWidth,el.offsetHeight]),mid=(g.left+g.right)/2-s.left;const fit=(i,x,y)=>[Math.max(6,Math.min(s.width-size[i][0]-6,x)),Math.max(6,Math.min(s.height-size[i][1]-6,y))];const hit=(a,i,b,j)=>a[0]<b[0]+size[j][0]&&b[0]<a[0]+size[i][0]&&a[1]<b[1]+size[j][1]&&b[1]<a[1]+size[i][1];diff --git a/skills/animation-handbook/references/04-micro-interactions.md b/skills/animation-handbook/references/04-micro-interactions.mdindex 708f3406..d9848baf 100644--- a/skills/animation-handbook/references/04-micro-interactions.md+++ b/skills/animation-handbook/references/04-micro-interactions.md@@ -885,7 +885,7 @@ A lens follows your pointer and shows the picture up close. Best for product pho**Prompt**-Add a magnifier lens to [the product photo or detailed picture people want to inspect]. While the pointer is over the picture, show a lens there holding an enlarged copy, placed so the spot under the pointer sits in the middle of the lens. Fill the lens from a larger, sharper version of the picture, never the same small one stretched, and move the lens and the copy with transforms only. On touch screens, show it while a finger is down, just above the finger; from the keyboard, show it on focus and move it with the arrow keys. If the visitor has reduced motion turned on, let it appear without growing. Match the settings listed below.+Add a magnifier lens to [the product photo or detailed picture people want to inspect]. While the pointer is over the picture, show a lens there holding an enlarged copy, placed so the spot under the pointer sits in the middle of the lens. Fill the lens from a larger, sharper version of the picture, never the same small one stretched, and move the lens and the copy with transforms only. On touch screens, show it while a finger is down, just above the finger, and let a drag move it without scrolling the page; from the keyboard, show it on focus and move it with the arrow keys. If the visitor has reduced motion turned on, let it appear without growing. Match the settings listed below.**Settings** (the choice in bold is where the demo starts; each line ends with what the setting does, with the demo's values):