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: Zoom Into Image: Compare names where the plain picture is when it is out of its half, reduced-motion poses held at every scroll position, gaps beside the split, halfway, label fades with the outline
Claudec167f6c45b18
diff --git a/animations/01-scroll-based/zoom-into-image/index.html b/animations/01-scroll-based/zoom-into-image/index.htmlindex 4e4cf30a..662727d2 100644--- a/animations/01-scroll-based/zoom-into-image/index.html+++ b/animations/01-scroll-based/zoom-into-image/index.html@@ -57,6 +57,7 @@.tg-win{top:0;left:0;white-space:nowrap}.tg-a{top:10px;left:10px;white-space:nowrap}.tg-b{top:10px;left:calc(50% + 10px);white-space:nowrap}+ .tg-gone{top:50cqh;left:25%;transform:translate(-50%,-50%);white-space:nowrap}.split{top:0;left:50%;width:2px;margin-left:-1px;height:100cqh;background:rgba(244,244,242,.4)}.stage[data-hb-mode="inside"] .names,.stage[data-hb-mode="compare"] .names{display:block}.stage[data-hb-mode="inside"] .faint,.stage[data-hb-mode="inside"] .tg-all,.stage[data-hb-mode="inside"] .tg-win,.stage[data-hb-mode="inside"] .tg-start{display:block}@@ -64,12 +65,13 @@.stage[data-hb-mode="inside"] #zoom-img svg{filter:brightness(1.5)}.stage[data-hb-mode="inside"] .frame-border{border-style:dashed;border-color:rgba(244,244,242,.6)}.stage[data-hb-mode="compare"] .full,.stage[data-hb-mode="compare"] .tg-a,.stage[data-hb-mode="compare"] .tg-b,.stage[data-hb-mode="compare"] .split{display:block}- .stage[data-hb-mode="compare"] .spacer{padding:0 8px 0 50%}+ .stage[data-hb-mode="compare"][data-gone] .tg-gone{display:block}+ .stage[data-hb-mode="compare"] .spacer{padding:0 8px 0 calc(50% + 8px)}.stage[data-hb-mode="compare"] #zoom-sticky{justify-content:flex-end}.stage[data-hb-mode="compare"] #zoom-img{width:50%}.stage[data-hb-mode="compare"] #frame,.stage[data-hb-mode="compare"] #caption{left:50%}.stage[data-hb-mode="compare"] .frame-border{border-color:rgba(244,244,242,.5)}- .stage[data-hb-mode="compare"] #caption{padding-bottom:26px}+ .stage[data-hb-mode="compare"] #caption{padding:0 10px 26px}.stage[data-hb-mode="compare"] #caption .cap-title{font-size:clamp(13px,2.2vw,22px);letter-spacing:1px}/* Reduced motion: the page shows the whole picture whatever the scroll, so each mode poses its own still, over the page'srules: See inside the window at its start with an arrow for how far it would open, Compare the window half open */@@ -80,6 +82,10 @@.stage[data-hb-mode="inside"] .frame-border,.stage[data-hb-mode="compare"] .frame-border{opacity:1!important}.stage[data-hb-mode="inside"] .names .arr{display:block}.stage[data-hb-mode="inside"] .tg-start{display:none}+ /* The posed view is held for the whole scroll, so it shows wherever the box sits: the frame's section spans the box's+ whole height (its margins cancel the spacers, so the scroll length is the same) and the spacers' words are hidden */+ .stage[data-hb-mode="inside"] #zoom-section,.stage[data-hb-mode="compare"] #zoom-section{height:370cqh;margin:-60cqh 0}+ .stage[data-hb-mode="inside"] .spacer,.stage[data-hb-mode="compare"] .spacer{color:transparent}.stage[data-hb-mode="compare"] .full{display:none}.stage[data-hb-mode="compare"] .faint{display:block;inset:0 50% 0 0;opacity:1;z-index:0}}@@ -115,6 +121,7 @@<i class="split"></i><p class="tg tg-a" data-hb-caption>Full picture</p><p class="tg tg-b" data-hb-caption>Window opens</p>+ <p class="tg tg-gone" data-hb-caption>Scrolled past ↑</p><p class="tg tg-all" data-hb-caption>The whole picture,already there</p><p class="tg tg-win" data-hb-caption>Window: about half the box</p>@@ -281,7 +288,7 @@ already there</p>d.className=cls;d.inert=true;d.setAttribute('aria-hidden','true');d.append(svg);return d};zoomSticky.prepend(copyOf('faint'));zoomSec.prepend(copyOf('full'));- const tgAll=stage.querySelector('.tg-all'),tgWin=stage.querySelector('.tg-win'),arrow=stage.querySelector('.arr');+ const tgGone=stage.querySelector('.tg-gone'),tgAll=stage.querySelector('.tg-all'),tgWin=stage.querySelector('.tg-win'),arrow=stage.querySelector('.arr');const LABELS={normal:'A picture that opens up as you scroll',inside:'The whole picture shown faintly, with the bright window that uncovers it',@@ -294,7 +301,7 @@ already there</p>},still:{inside:'Shown still: the bright part is the window you would see at first, and the arrow shows how far it would open as you scroll; the rest of the picture is already there.',- compare:'Shown still, half open: Full picture is an ordinary image; Window opens has uncovered only part of the picture, as it would half way down the box.',+ compare:'Shown still, half open: Full picture is an ordinary image; Window opens has uncovered only part of the picture, as it would halfway down the box.',},};const insideNote=document.querySelector('[data-hb-for="inside"]'),compareNote=document.querySelector('[data-hb-for="compare"]');@@ -309,18 +316,25 @@ already there</p>const raw=(st-pinStart)/budget,p=clamp(raw,0,1);const still=motionMQ.matches;// reduced motion: the CSS rule above shows the full picture and the caption and hides the outline, whatever the scroll position+ const cap=!still&&p>0.88?(p-0.88)/0.12:0;if(!still){const inset=lerp(startPct,0,p);const radius=lerp(brStart,0,p);zoomImg.style.clipPath=`inset(${inset.toFixed(2)}% round ${radius.toFixed(1)}px)`;- const cap=p>0.88?((p-0.88)/0.12).toFixed(3):'0';- caption.style.opacity=cap;+ caption.style.opacity=cap.toFixed(3);frameBorder.style.opacity=(1-cap).toFixed(3); // the starting-frame outline fades out as the caption fades in}+ if(mode==='compare'){+ // Compare: the ordinary picture scrolls by, so where less than a quarter of it is in its half a caption says where it is+ const vT=st-pinStart,top=H*.75,seen=Math.max(0,Math.min(vT+H,top+H)-Math.max(vT,top))/H;+ if(!still&&seen<.25){stage.setAttribute('data-gone','');put(tgGone,vT>top?'Scrolled past ↑':'Coming up ↓')}+ else stage.removeAttribute('data-gone');+ }if(mode!=='inside')return;// See inside: the marks belong to the held picture, so they show only while it is held. The window label rides the// window's lower edge, below the outline, and stays above the caption; the same share draws it as draws the window.- stage.toggleAttribute('data-held',raw>=-.001&&raw<=1.001);+ stage.toggleAttribute('data-held',still||(raw>=-.001&&raw<=1.001));+ tgAll.style.opacity=still?1:(1-cap).toFixed(3); // it fades with the outline once the window has openedconst inset=still?startPct:lerp(startPct,0,p);put(tgWin,still?'Window at the start':'Window: '+widthWords(1-inset/50));tgWin.style.transform=`translate(${(W-tgWin.offsetWidth)/2}px,${Math.min(H*(1-inset/100)+H*.02+5,H-30).toFixed(1)}px)`;@@ -340,7 +354,7 @@ already there</p>document.addEventListener('hb:mode',e=>{mode=e.detail.mode;stage.setAttribute('aria-label',LABELS[mode]);- stage.removeAttribute('data-held');+ stage.removeAttribute('data-held');stage.removeAttribute('data-gone');describe();update();});stage.addEventListener('scroll',()=>{if(!ticking){requestAnimationFrame(update);ticking=true}},{passive:true});