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: Hover State Animation (04.01): Space on a focused card no longer scrolls the page, as on the button it stands for

matin999e604cf827
diff --git a/animations/04-micro-interactions/hover-state/index.html b/animations/04-micro-interactions/hover-state/index.html
index ac936abe..d8d61ee2 100644
--- a/animations/04-micro-interactions/hover-state/index.html
+++ b/animations/04-micro-interactions/hover-state/index.html
@@ -193,6 +193,8 @@
document.addEventListener('hb:input',()=>{if(running())stopRun()});
stage.addEventListener('pointermove',e=>{if(e.isTrusted&&running())stopRun()});
stage.addEventListener('focusin',e=>{if(e.isTrusted&&running())stopRun()});
+ // A card stands for a button, and Space on a button does not scroll the page: on a card it does nothing, as a click does.
+ cards.forEach(c=>c.addEventListener('keydown',e=>{if(e.key===' ')e.preventDefault()}));
function choices(id,pick){
const buttons=document.querySelectorAll('#'+id+' button');