Skip to content

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.

fix: Ink Spread Reveal review: Compare's circles take the ragged blots' radii, no dashed outline in the One drop note, a resize during a play redraws, reduced-motion Replay in a view matches its note

matin8f10c2ab20ff
diff --git a/animations/02-entrance-and-exit/ink-spread-reveal/index.html b/animations/02-entrance-and-exit/ink-spread-reveal/index.html
index 516f0679..c60641b8 100644
--- a/animations/02-entrance-and-exit/ink-spread-reveal/index.html
+++ b/animations/02-entrance-and-exit/ink-spread-reveal/index.html
@@ -241,13 +241,16 @@
const shown=()=>mode==='compare'?[twin,main]:[main];
// Draws a scene for its size: the paper, the ink edge, the picture seen through the blots, and See inside's outlines. Every blot
// gets the radius that, with the others, covers the whole scene at full size: each spot of the scene belongs to its nearest
- // drop, and that drop's blot reaches the farthest of its spots even where its outline dips in.
+ // drop, and that drop's blot reaches the farthest of its spots even where its outline dips in (the copy gets the same radii).
function build(sc){
const W=sc.el.clientWidth||1,H=sc.el.clientHeight||1,id=sc.twin?'twin':'main',rand=rng(7);
- const [wob,dots0]=sc.twin?[0,0]:EDGES[edge],dots=phone.matches?Math.ceil(dots0/2):dots0;
+ const [wob0,dots0]=EDGES[edge],dotsN=phone.matches?Math.ceil(dots0/2):dots0,[wob,dots]=sc.twin?[0,0]:[wob0,dotsN];
const c=DROPS[drops].map(([x,y])=>[x*W,y*H]),far=c.map(()=>1);
for(let i=0;i<=12;i++)for(let j=0;j<=8;j++){const x=i/12*W,y=j/8*H,d=c.map(p=>Math.hypot(p[0]-x,p[1]-y)),n=d.indexOf(Math.min(...d));far[n]=Math.max(far[n],d[n])}
- sc.blots=c.map((p,i)=>{const b=unitBlot(rand,wob,dots);return {x:p[0],y:p[1],R:far[i]*1.06/b.min,b}});
+ // The copy's circles take their radius from the ragged outlines the page draws (the same seeded sequence), so both halves of
+ // Compare uncover the same amount at every moment and differ only in their edges
+ const sizes=rng(7);
+ sc.blots=c.map((p,i)=>{const b=unitBlot(rand,wob,dots),ref=unitBlot(sizes,wob0,dotsN);return {x:p[0],y:p[1],R:far[i]*1.06/ref.min,b}});
sc.W=W;sc.H=H;
const g=(cls,i,d)=>`<g transform="translate(${sc.blots[i].x.toFixed(1)} ${sc.blots[i].y.toFixed(1)})"><g class="grow" data-i="${i}"><path class="${cls}" d="${d}"/></g></g>`;
const each=fn=>sc.blots.map(fn).join('');
@@ -301,7 +304,11 @@
// fades it back to paper and plays again; See inside and Compare go back to their resting moment.
function play(){
stopTimers();layout();view='play';
- if(reduce.matches){blots(total(),true);fade(0,1,600,end);return}
+ // under reduced motion the picture fades in: the whole picture in Normal, the posed one in a view (its note says part of the way)
+ if(reduce.matches){
+ if(mode!=='normal'){blots('pose',true);view='pose';fade(0,1,600,()=>{});return}
+ blots(total(),true);fade(0,1,600,end);return;
+ }
blots(0,false);
Promise.all(anims.map(a=>a.finished)).then(end,()=>{});
}
@@ -319,17 +326,17 @@
// See inside and Compare their resting moment
function rest(){
stopTimers();layout();
- if(mode==='normal'){blots(view==='paper'?0:total(),true);if(loopTog.checked&&!reduce.matches&&view!=='paper')end();return}
+ if(mode==='normal'){if(view==='play')view='full';blots(view==='paper'?0:total(),true);if(loopTog.checked&&!reduce.matches&&view!=='paper')end();return}
view='pose';blots('pose',true);
}
document.addEventListener('hb:mode',e=>{
mode=e.detail.mode;stage.setAttribute('aria-label',LABELS[mode]);notes();
// A play under way goes on from where it is, drawn for the new size of its scene
- if(view==='play'&&anims[0]&&!reduce.matches){const t=anims[0].currentTime;layout();blots(t,false);Promise.all(anims.map(a=>a.finished)).then(end,()=>{})}
+ if(view==='play'&&anims[0]&&!reduce.matches)resumed();
else rest();
});
// The notes follow the settings: with Smooth edges both halves of Compare grow round blots (the same ones with the ink edge
- // off), and with the ink edge off See inside has no ring to name; the markup's words hold for the defaults
+ // off), with the ink edge off See inside has no ring to name, and with One drop no dashed outline; the markup's words hold for the defaults
const said={inside:document.querySelector('[data-hb-for="inside"]').textContent,compare:document.querySelector('[data-hb-for="compare"]').textContent};
function notes(){
const rim=rimTog.checked,still=reduce.matches;
@@ -338,12 +345,19 @@
:'Edge is set to Smooth and the ink edge is off, so Clean circles and Ink blots match. Pick Ragged or Splashy in Try it to see the difference.')
:still?'Shown still, part of the way: on the left, Clean circles have grown round and neat; on the right, Ink blots have spread with ragged edges.'
:said.compare;
- document.querySelector('[data-hb-for="inside"]').textContent=still?'Shown still, part of the way: the picture waits faintly under the paper, and each numbered blot will grow to its dashed outline.'
+ // With One drop the blot's full outline lies outside the box, so there is no dashed line to name
+ const one=drops==='one',ring=rim?', with the dark ink edge as a ring just ahead':'';
+ document.querySelector('[data-hb-for="inside"]').textContent=still
+ ?(one?'Shown still, part of the way: the picture waits faintly under the paper, and the numbered blot will grow past the edges of the box.'
+ :'Shown still, part of the way: the picture waits faintly under the paper, and each numbered blot will grow to its dashed outline.')
+ :one?`Inside, the picture waits faintly under the paper. The numbered blot is a window in the paper that grows past the edges of the box${ring}.`
:rim?said.inside:'Inside, the picture waits faintly under the paper. Each numbered blot is a window in the paper that grows to its dashed outline.';
}
// Loop on plays at once; Loop off during the fade back to paper shows the whole picture again
loopTog.addEventListener('change',()=>{if(loopTog.checked)play();else if(view==='fade'){view='full';rest()}});
- new ResizeObserver(()=>{if(view!=='play')rest()}).observe(stage);
+ // A resize during a play redraws at the new size and goes on from where the play is, as a press of a view does
+ function resumed(){const t=anims[0].currentTime;layout();blots(t,false);Promise.all(anims.map(a=>a.finished)).then(end,()=>{})}
+ new ResizeObserver(()=>{if(view==='play'&&anims[0]&&!reduce.matches)resumed();else rest()}).observe(stage);
document.getElementById('btn-play').addEventListener('click',play);
function choices(id,pick){
const buttons=document.querySelectorAll('#'+id+' button');