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: Expanding Search (04.37): a press on the field around the text box keeps the cursor in it
matin3c23969b5a35
diff --git a/animations/04-micro-interactions/expanding-search/README.md b/animations/04-micro-interactions/expanding-search/README.mdindex b1e644d3..fcccd750 100644--- a/animations/04-micro-interactions/expanding-search/README.md+++ b/animations/04-micro-interactions/expanding-search/README.md@@ -41,7 +41,7 @@ field.addEventListener('focusout', e => { // leaving it: the focus w});```-The icon stays on top of the field. As the field opens, the icon's background turns see-through and its glass turns and fades away while the close button's cross turns in under it, so one seems to become the other; the links under the field fade out. While the field is open the icon lets presses through and is `inert`, so Tab cannot land on something hidden, and the field shows its focus with an inset ring while anything inside it has the focus. Show me opens the field and types into it without moving the real focus, so it never opens a phone's keyboard. Under reduced motion the transitions are switched off and the field opens and closes at once.+The icon stays on top of the field. As the field opens, the icon's background turns see-through and its glass turns and fades away while the close button's cross turns in under it, so one seems to become the other; the links under the field fade out. While the field is open the icon lets presses through and is `inert`, so Tab cannot land on something hidden, and the field shows its focus with an inset ring while anything inside it has the focus. A press on the field around the text box (its glass or its edge) cancels the `mousedown` and puts the cursor back in the box, so it does not count as leaving. Show me opens the field and types into it without moving the real focus, so it never opens a phone's keyboard. Under reduced motion the transitions are switched off and the field opens and closes at once.## Key parameters| Parameter | Default | Effect |diff --git a/animations/04-micro-interactions/expanding-search/index.html b/animations/04-micro-interactions/expanding-search/index.htmlindex 9cc33de4..7967c9db 100644--- a/animations/04-micro-interactions/expanding-search/index.html+++ b/animations/04-micro-interactions/expanding-search/index.html@@ -209,6 +209,8 @@field.addEventListener('focusout',e=>{if(leaveTog.checked&&bar.classList.contains('open')&&!field.contains(e.relatedTarget))close(false);});+ // A press on the field around the text box (its glass or its edge) puts the cursor in the box instead of taking the focus away+ field.addEventListener('mousedown',e=>{if(e.target!==input&&!sclose.contains(e.target)){e.preventDefault();input.focus({preventScroll:true})}});// Show me: one run at a time. Every timer of the run goes through later(); stopRun() cancels the whole run.// later(fn, move, hold) waits move*(slow?3:1) + hold ms: Slow motion triples the movement, never the hold.