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: Holographic Card (06.25): the card takes keyboard focus, the arrow keys tilt it and move its glare as the pointer does, Escape or leaving it lets it settle, and How it works says so
matin77ceed83d11c
diff --git a/animations/06-3d-advanced/holographic-card/README.md b/animations/06-3d-advanced/holographic-card/README.mdindex 346532e3..7e822958 100644--- a/animations/06-3d-advanced/holographic-card/README.md+++ b/animations/06-3d-advanced/holographic-card/README.md@@ -74,6 +74,8 @@ The pointer is measured against the card's own place, its untransformed box, not**Show me** moves the same numbers along a figure of eight for 3.2 seconds (`x = 0.42 sin 2πe`, `y = 0.34 sin 4πe`, with `e` the eased progress), lit as it goes, and ends with the card flat. A press, key or wheel turn in the stage, or the visitor's own pointer moving over it, stops the run, and the card follows the visitor from where it was.+The card also takes keyboard focus, and the keys stand in for the pointer. Keyboard focus lights the card where it aims (its middle at rest), each press of an arrow key moves the aim 6% of the way across the card (a key held down repeats), and Escape or moving focus away lets it settle, as the pointer leaving does.+## Key parameters| Parameter | Default | Effect ||-----------|---------|--------|diff --git a/animations/06-3d-advanced/holographic-card/index.html b/animations/06-3d-advanced/holographic-card/index.htmlindex d70f4e4a..33848749 100644--- a/animations/06-3d-advanced/holographic-card/index.html+++ b/animations/06-3d-advanced/holographic-card/index.html@@ -29,6 +29,8 @@/* Four layers in one 5:7 box (picture, foil, glare, text panels), moved only by transform and opacity; flat but in Shows the layers */.card{position:relative;height:min(84%,380px);aspect-ratio:5/7;border-radius:12px;touch-action:none;will-change:transform;box-shadow:0 0 0 1px rgba(var(--hc-light),.1),0 24px 50px -14px rgba(var(--hc-shade),.8)}+ /* Keyboard focus: the ring goes around the card, on the dark stage (drawn inward, the card's own layers would cover it) */+ .hb-page .stage .card:focus-visible{outline-offset:4px}.ly{position:absolute;inset:0;border-radius:inherit;overflow:hidden;overflow:clip}.art svg{display:block;width:100%;height:100%}/* The foil: rainbow streaks twice the card's size, slid by the script; color dodge brightens the picture under each streak. Glitter@@ -81,7 +83,7 @@<div><h2 id="hb-watch-title">Hover it</h2><p>Move your pointer over the card, drag a finger across it, or press Show me.</p></div></div><div class="stage" id="stage">- <div class="card" id="card" data-foil="smooth" role="img" aria-label="A holographic trading card named Aurora Prism: a glowing crystal over dark mountains under a night sky. As the card tilts toward the pointer, rainbow foil slides across it and a glare follows the pointer.">+ <div class="card" id="card" data-foil="smooth" role="img" tabindex="0" aria-label="A holographic trading card named Aurora Prism: a glowing crystal over dark mountains under a night sky. As the card tilts toward the pointer, rainbow foil slides across it and a glare follows the pointer. Press the arrow keys to tilt it."><div class="ly art"><svg viewBox="0 0 100 140" aria-hidden="true"><defs><linearGradient id="hc-frame" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#efeaff"/><stop offset=".3" stop-color="#a191ee"/><stop offset=".55" stop-color="#4a3aa8"/><stop offset=".8" stop-color="#b8aaf5"/><stop offset="1" stop-color="#ece6ff"/></linearGradient>@@ -281,6 +283,17 @@ stage.addEventListener('pointermove',e=>{if(e.isTrusted&&(run||holdTimer)){stopH['pointerleave','pointercancel'].forEach(t=>stage.addEventListener(t,rest));stage.addEventListener('pointerup',e=>{if(e.pointerType!=='mouse')rest();});reduce.addEventListener('change',()=>{stopHold();run=null;sx=sy=sh=ax=ay=ah=0;sp=split;draw();});+// The keyboard is a pretend pointer through the same aim: focus by keyboard ends a run and lights the card where it aims (the+// middle at rest), each arrow key moves the aim 6% of the card (held, it repeats), and Escape or leaving the card lets it settle+const STEP={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};+let keys=false;+card.addEventListener('focus',()=>{if(card.matches(':focus-visible')){stopHold();run=null;keys=true;ah=1;wake();}});+card.addEventListener('keydown',e=>{+ const d=!e.altKey&&!e.ctrlKey&&!e.metaKey&&STEP[e.key];+ if(d){e.preventDefault();keys=true;ax=clamp(ax+.06*d[0]);ay=clamp(ay+.06*d[1]);ah=1;wake();}+ else if(e.key==='Escape'&&keys){keys=false;rest();}+});+card.addEventListener('blur',()=>{if(keys){keys=false;rest();}});function choices(id,pick){const buttons=document.querySelectorAll('#'+id+' button');