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
feat: add contact generation, IntersectionObserver, and scroll animation
matin14161b7a2f21
diff --git a/animations/01-scroll-based/fly-in-fly-out-contact-list/index.html b/animations/01-scroll-based/fly-in-fly-out-contact-list/index.htmlindex ec24fea9..daf27655 100644--- a/animations/01-scroll-based/fly-in-fly-out-contact-list/index.html+++ b/animations/01-scroll-based/fly-in-fly-out-contact-list/index.html@@ -168,5 +168,130 @@</div>+<script>+ const CONTACTS = [+ {i:'SK',n:'Sara Klein', s:'Design lead · Berlin', t:'now', b:0,o:true },+ {i:'MR',n:'Marco Rossi', s:'Engineering · Milan', t:'2h', b:3,o:false},+ {i:'YT',n:'Yuki Tanaka', s:'Product · Tokyo', t:'1d', b:0,o:false},+ {i:'AO',n:'Amara Okafor', s:'Research · Lagos', t:'now', b:0,o:true },+ {i:'LP',n:'Lena Park', s:'UX · Seoul', t:'5m', b:1,o:true },+ {i:'JB',n:'Jules Bernard', s:'Data · Paris', t:'3h', b:0,o:false},+ {i:'RM',n:'Ravi Mehta', s:'Infra · Mumbai', t:'2d', b:0,o:false},+ {i:'CF',n:'Clara Ferreira',s:'Brand · São Paulo', t:'30m', b:7,o:true },+ {i:'SO',n:"Sam O'Brien", s:'Mobile · Dublin', t:'now', b:0,o:true },+ {i:'NW',n:'Nia Williams', s:'Growth · London', t:'1h', b:2,o:false},+ {i:'DK',n:'Dae-Jung Kim', s:'Security · Busan', t:'4h', b:0,o:false},+ {i:'HZ',n:'Hana Zhao', s:'ML · Shanghai', t:'now', b:0,o:true },+ {i:'TN',n:'Tariq Nassar', s:'Strategy · Dubai', t:'2d', b:0,o:false},+ {i:'EV',n:'Elena Vasquez', s:'Finance · Mexico City', t:'45m', b:4,o:false},+ {i:'IB',n:'Ivan Brykov', s:'Platform · Kyiv', t:'now', b:0,o:true },+ ];+ const COLORS = ['#1a3a5c','#2d1b3d','#1e3a1e','#3d2000','#1a3a3a',+ '#3a1a1a','#1a2a3d','#2d1a3d','#1e2d1e','#3a2a00'];+ const avatarColor = i => COLORS[(i.charCodeAt(0)+i.charCodeAt(1))%COLORS.length];++ const list = document.getElementById('contact-list');+ const rows = CONTACTS.map(c => {+ const el = document.createElement('div');+ el.className = 'row';+ el.innerHTML =+ `<div class="avatar" style="background:${avatarColor(c.i)}">${c.i}</div>` ++ `<div class="row-info"><div class="row-name">${c.n}</div>` ++ `<div class="row-sub">${c.s}</div></div>` ++ `<div class="row-meta">` ++ (c.b ? `<span class="badge">${c.b}</span>` : `<span class="dot ${c.o?'online':'offline'}"></span>`) ++ `<span class="meta-time">${c.t}</span></div>`;+ list.appendChild(el);+ return el;+ });++ const stage = document.getElementById('stage');+ const scrollProg = document.getElementById('scroll-prog');+ const visCount = document.getElementById('visible-count');+ const distSl = document.getElementById('dist-sl');+ const distVal = document.getElementById('dist-val');+ const scaleSl = document.getElementById('scale-sl');+ const scaleVal = document.getElementById('scale-val');+ const zoneSl = document.getElementById('zone-sl');+ const zoneVal = document.getElementById('zone-val');+ const previewTog = document.getElementById('preview-tog');+ const resetBtn = document.getElementById('reset-btn');+ const zoneOverlay = document.getElementById('zone-overlay');+ const zoneExit = document.getElementById('zone-exit');+ const zoneEntry = document.getElementById('zone-entry');+ const motionMQ = window.matchMedia('(prefers-reduced-motion: reduce)');++ let DIST = 40, SCALE = 0.94, Z = 0.25, mode = 'all';+ let ticking = false;+ const visible = new Set();++ const io = new IntersectionObserver(entries => {+ entries.forEach(e => e.isIntersecting ? visible.add(e.target) : visible.delete(e.target));+ }, { root: stage, rootMargin: '25% 0px', threshold: 0 });+ rows.forEach(r => io.observe(r));++ function lerp(a, b, t) { return a + (b - a) * t; }+ function clamp(v, lo, hi) { return Math.min(Math.max(v, lo), hi); }++ function applyRow(el) {+ const pos = (el.offsetTop - stage.scrollTop) / stage.clientHeight;+ const reduced = motionMQ.matches;+ let opacity = 1, ty = 0, sc = 1;++ if (pos < Z) {+ const t = clamp(pos / Z, 0, 1);+ opacity = reduced ? lerp(0.3, 1, t) : (mode !== 'translate' ? lerp(0, 1, t) : 1);+ if (!reduced && mode !== 'fade') ty = lerp(-DIST, 0, t);+ if (!reduced && mode === 'all') sc = lerp(SCALE, 1, t);+ } else if (pos > 1 - Z) {+ const t = clamp((1 - pos) / Z, 0, 1);+ opacity = reduced ? lerp(0.3, 1, t) : (mode !== 'translate' ? lerp(0, 1, t) : 1);+ if (!reduced && mode !== 'fade') ty = lerp(DIST, 0, t);+ if (!reduced && mode === 'all') sc = lerp(SCALE, 1, t);+ }++ el.style.opacity = opacity;+ el.style.transform = `translate3d(0,${ty}px,0) scale(${sc})`;+ }++ function updateOverlay() {+ const h = stage.clientHeight, zH = Math.round(h * Z);+ zoneExit.style.height = zH + 'px';+ zoneEntry.style.height = zH + 'px';+ zoneEntry.style.top = (h - zH) + 'px';+ }++ function update() {+ const st = stage.scrollTop;+ const max = stage.scrollHeight - stage.clientHeight;+ scrollProg.textContent = max > 0 ? Math.round(st / max * 100) + '%' : '0%';+ visible.forEach(applyRow);+ visCount.textContent = visible.size;+ ticking = false;+ }++ stage.addEventListener('scroll', () => {+ if (!ticking) { requestAnimationFrame(update); ticking = true; }+ }, { passive: true });++ distSl.addEventListener('input', () => { DIST = +distSl.value; distVal.textContent = DIST + 'px'; update(); });+ scaleSl.addEventListener('input', () => { SCALE = scaleSl.value / 100; scaleVal.textContent = SCALE.toFixed(2); update(); });+ zoneSl.addEventListener('input', () => { Z = zoneSl.value / 100; zoneVal.textContent = zoneSl.value + '%'; updateOverlay(); update(); });+ document.querySelectorAll('input[name="mode"]').forEach(r =>+ r.addEventListener('change', () => { mode = r.value; update(); }));+ previewTog.addEventListener('change', () => zoneOverlay.classList.toggle('visible', previewTog.checked));++ resetBtn.addEventListener('click', () => {+ distSl.value = 40; DIST = 40; distVal.textContent = '40px';+ scaleSl.value = 94; SCALE = 0.94; scaleVal.textContent = '0.94';+ zoneSl.value = 25; Z = 0.25; zoneVal.textContent = '25%';+ document.querySelector('input[value="all"]').checked = true; mode = 'all';+ previewTog.checked = false; zoneOverlay.classList.remove('visible');+ stage.scrollTop = 0; updateOverlay(); update();+ });++ updateOverlay();+ update();+</script></body></html>