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: Marquee / Ticker's one copy in Compare is the same strip as Copy 1 and stops with the real row, its pose keeps the end of the visitor's words in view, and the reduced-motion notes follow Play and Pause
matinf21a25760958
diff --git a/animations/05-text-typography/marquee-ticker/index.html b/animations/05-text-typography/marquee-ticker/index.htmlindex 1b3a98da..04443d2d 100644--- a/animations/05-text-typography/marquee-ticker/index.html+++ b/animations/05-text-typography/marquee-ticker/index.html@@ -65,8 +65,9 @@.zarrow::before{content:"";position:absolute;left:0;right:9px;top:5px;height:3px;border-radius:2px;background:var(--ui-accent)}.zarrow::after{content:"";position:absolute;right:0;top:0;border-style:solid;border-width:6.5px 0 6.5px 10px;border-color:transparent transparent transparent var(--ui-accent)}.zback{transform:translateX(-50%)}- @media(hover:hover){.stage[data-hb-mode="inside"]:has(.r1:hover) .zwin{animation-play-state:paused}}- .stage[data-hb-mode="inside"]:has(.r1.paused) .zwin{animation-play-state:paused}+ /* Pointing at the first row, or tapping it on a touch screen, stops the window in See inside and the one copy in Compare too */+ @media(hover:hover){.stage[data-hb-mode="inside"]:has(.r1:hover) .zwin,.stage[data-hb-mode="compare"]:has(.r1:hover) .solo-track{animation-play-state:paused}}+ .stage[data-hb-mode="inside"]:has(.r1.paused) .zwin,.stage[data-hb-mode="compare"]:has(.r1.paused) .solo-track{animation-play-state:paused}/* Compare: on top the common mistake, a single copy of the text that slides out, leaves a gap and jumps back; below it thefirst row with its two copies, which loops with no seam */.stage[data-hb-mode="compare"]{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:repeat(2,minmax(0,1fr))}@@ -221,13 +222,16 @@const stage=document.getElementById('stage');const rows=document.getElementById('rows'),zoom=document.getElementById('zoom'),solo=document.getElementById('solo');const reduceMQ=matchMedia('(prefers-reduced-motion: reduce)');- // Under reduced motion the loop starts paused, so both views are still pictures, and their notes say so (the markup's own words- // otherwise, also when reduced motion is turned off while the page is open)+ // Under reduced motion the loop starts paused, so both views are still pictures, and their notes say so. Once the visitor+ // presses Play, or turns reduced motion off, the notes say the markup's own words again. The shared script sends hb:pause on+ // every press of Pause or Play, and once at boot under reduced motion, when it pauses the loop.const notes=[...document.querySelectorAll('[data-hb-for]')],moving=notes.map(n=>n.textContent),still=['Inside, shown still: the strip is two identical copies end to end, and the arrow shows how far the box slides before it jumps back to the start.','Shown still: on top, One copy, the text has slid most of the way out and left a gap; below, Two copies, the second copy fills it.'];- function describe(){notes.forEach((n,i)=>{n.textContent=reduceMQ.matches?still[i]:moving[i]})}+ let paused=reduceMQ.matches;+ function describe(){notes.forEach((n,i)=>{n.textContent=reduceMQ.matches&&paused?still[i]:moving[i]})}describe();+ document.addEventListener('hb:pause',e=>{paused=e.detail.paused;describe()});const vars=document.documentElement.style;const txtIn=document.getElementById('text-inp');const noHover=matchMedia('(hover:none)');@@ -292,7 +296,7 @@function buildViews(){const row=rows.querySelector('.r1'),track=row&&row.querySelector('.marq-track');if(!track)return;- const copyW=track.scrollWidth/2,rowW=stage.clientWidth,rowH=row.offsetHeight,itemW=track.firstElementChild.offsetWidth;+ const copyW=track.scrollWidth/2,rowW=stage.clientWidth,rowH=row.offsetHeight;// the zoom's side margins are 2% of the box's width, 10 to 20 pixels, as in the stylesconst zoomW=Math.max(1,rowW-2*Math.min(20,Math.max(10,rowW*.02)));const k=Math.min(1,zoomW/track.scrollWidth),h=rowH*k,cw=copyW*k;@@ -320,13 +324,14 @@add('lbl zcap',{},'In the box',win);add('zarrow',{top:h+74+'px',width:cw+'px'});add('lbl zcap zback',{left:cw+'px',top:h+93+'px'},'Jumps back here');- // Compare's mistake: the same text, but one copy of it, sliding by its own width before it starts over+ // Compare's mistake: the same strip as Copy 1 (the first row's own first copy), but only that one copy, sliding by its own+ // width in the time the row takes, then starting over. The two halves differ only by the second copy.solo.innerHTML='';const srow=document.createElement('div');srow.className='marq-row solo-row';const st=document.createElement('div');st.className='solo-track';- st.appendChild(makeItem(getContent(),separator,false));+ for(let i=0;i<track.children.length/2;i++)st.appendChild(track.children[i].cloneNode(true));srow.appendChild(st);solo.appendChild(srow);- st.style.animationDuration=Math.round(itemW/spd*1000)+'ms';+ st.style.animationDuration=track.durMs+'ms';syncWindow();poseSolo();}@@ -338,12 +343,12 @@const sync=()=>{if(a.currentTime!=null&&b.playState!=='idle')b.currentTime=a.currentTime%t.durMs};if(a&&b){sync();b.ready.then(sync,()=>{})}}- // Compare's mistake starts at its telling moment, the one copy most of the way out and the gap plain, so the jump back comes- // soon after Compare is pressed; under reduced motion the loop is paused, and it holds there. That is 70% of the way, or later- // for text wider than the box, so that the text left covers at most 40% of the box (measured on the first row's own copy).+ // Compare's mistake starts at its telling moment: the one copy has slid so far that what is left of it covers 40% of the box,+ // its last words beside a plain gap, and the jump back comes within seconds; under reduced motion the loop is paused, and it+ // holds there. The copy's width is measured on the first row, which is always shown.function poseSolo(){- const t=solo.querySelector('.solo-track'),a=t&&t.getAnimations()[0],item=rows.querySelector('.r1 .marq-item');- if(a&&a.effect&&item)a.currentTime=Math.max(.7,1-.4*stage.clientWidth/item.offsetWidth)*a.effect.getComputedTiming().duration;+ const t=solo.querySelector('.solo-track'),a=t&&t.getAnimations()[0],r=rows.querySelector('.r1 .marq-track');+ if(a&&a.effect&&r)a.currentTime=Math.max(0,1-.4*stage.clientWidth/(r.scrollWidth/2))*a.effect.getComputedTiming().duration;}// The mode switch: draws the mode at once. A view's animation starts when the view is shown, so the window is set to the first// row's place then, and the mistake is posed. Pause and Slow motion reach every animation in the stage.