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: 2D Physics: the Show me press on arrival ignores balls that are fading out

matin60a10d7fa38f
diff --git a/animations/06-3d-advanced/physics-2d/index.html b/animations/06-3d-advanced/physics-2d/index.html
index c9242f49..f6580e2b 100644
--- a/animations/06-3d-advanced/physics-2d/index.html
+++ b/animations/06-3d-advanced/physics-2d/index.html
@@ -284,7 +284,7 @@ cvs.addEventListener('keydown',e=>{if((e.key==='Enter'||e.key===' ')&&!e.repeat)
function later(fn,ms){const id=setTimeout(()=>{runTimers=runTimers.filter(t=>t!==id);fn();},ms*(slowTog.checked?3:1));runTimers.push(id);}
function stopRun(){runTimers.forEach(clearTimeout);runTimers=[];}
document.getElementById('btn-demo').addEventListener('click',e=>{
- if(!e.isTrusted&&balls.length)return; // the press on arrival leaves alone a box the visitor has already filled
+ if(!e.isTrusted&&balls.some(b=>b.to>0))return; // the press on arrival leaves alone a box the visitor has already filled
stopRun();balls=[];rings=[];held=null;awake=false;showHint();draw();
[[.3,.18],[.62,.12],[.46,.22],[.72,.16],[.4,.1]].forEach(([x,y],i)=>later(()=>drop(W*x,H*y),300*i));
later(()=>{balls.forEach(b=>{b.to=0;});showHint();kick();},2900);