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: fall back to the default text when the field holds only spaces

matin2c50d58aa5d0
diff --git a/animations/05-text-typography/marquee-ticker/index.html b/animations/05-text-typography/marquee-ticker/index.html
index 2437e017..943e56a5 100644
--- a/animations/05-text-typography/marquee-ticker/index.html
+++ b/animations/05-text-typography/marquee-ticker/index.html
@@ -187,7 +187,7 @@
return row;
}
- function getContent(){return txtIn.value||'Animation Handbook'}
+ function getContent(){return txtIn.value.trim()?txtIn.value:'Animation Handbook'}
// Fraction of the loop a track has completed (0-1), so a duration change or rebuild can resume in place
function progressOf(track){
diff --git a/animations/05-text-typography/outline-to-fill/index.html b/animations/05-text-typography/outline-to-fill/index.html
index 25d74f79..a7a2ee63 100644
--- a/animations/05-text-typography/outline-to-fill/index.html
+++ b/animations/05-text-typography/outline-to-fill/index.html
@@ -303,7 +303,7 @@
choices('feel-seg',d=>{ease=d.ease});
choices('outline-color-sw',d=>{vars.setProperty('--stroke-color',d.c)});
choices('fill-color-sw',d=>{vars.setProperty('--fill-color',d.c)});
- txtIn.addEventListener('input',()=>{applyText(txtIn.value.toUpperCase()||'OUTLINE')});
+ txtIn.addEventListener('input',()=>{applyText(txtIn.value.trim()?txtIn.value.toUpperCase():'OUTLINE')});
window.addEventListener('resize',fitText);
apply();applyDir();fitText();
</script>
diff --git a/animations/05-text-typography/scramble-text/index.html b/animations/05-text-typography/scramble-text/index.html
index 6318c72c..9aac7d02 100644
--- a/animations/05-text-typography/scramble-text/index.html
+++ b/animations/05-text-typography/scramble-text/index.html
@@ -170,7 +170,7 @@
// While Loop is on, the text holds 1200ms once fully decoded, then scrambles again; switching Loop
// off lets it finish decoded. Slow motion stretches the per-letter delay and the flicker, not the hold.
function cycle(){
- const text=(txtIn.value||'DECODE THE MESSAGE').toUpperCase();
+ const text=(txtIn.value.trim()?txtIn.value:'DECODE THE MESSAGE').toUpperCase();
const reduce=reduceMotion.matches;
out.innerHTML='';