Mirror to Gitea / mirror (push) Skipped
Use real public-domain photos throughout (Chicago skyline, CTA signage, Marina City, Union Station, guitars, synths, cassette, Game Boy and floppy stickers, daisies, clouds, flowers, a vintage postcard and stamp), credited on a new /credits page. Lean into Chicago: CTA 'L' line colors for sections and categories, a Chicago star logo, flag footer, a CTA platform work page with split-flap board and arrival rows, and a Greetings from Chicago postcard on contact. Add GSAP + Lenis scroll motion and React Bits components (split-flap, ticker, circular badge, count-up, sticker peel, scrambled text, halftone reveal, CRT terminal, staggered mobile menu). Rebuild pages mobile-first, drop the katakana, and lazy-load the 3D viewer.
76 lines
2.4 KiB
TypeScript
76 lines
2.4 KiB
TypeScript
/**
|
|
* Site-wide motion: Lenis smooth scrolling (desktop; touch keeps native
|
|
* scrolling) driven by GSAP's ticker, plus ScrollTrigger reveals.
|
|
*
|
|
* data-reveal fade + rise when scrolled into view
|
|
* data-reveal="tilt" same, with a slight paper-like rotation
|
|
* data-reveal-stagger reveal direct children one after another
|
|
* data-parallax="0.2" drift vertically while scrolling (desktop only)
|
|
*
|
|
* Everything is skipped when the visitor prefers reduced motion.
|
|
*/
|
|
import Lenis from 'lenis';
|
|
import 'lenis/dist/lenis.css';
|
|
import { gsap } from 'gsap';
|
|
import { ScrollTrigger } from 'gsap/ScrollTrigger';
|
|
|
|
gsap.registerPlugin(ScrollTrigger);
|
|
|
|
const reduce = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
let lenis: Lenis | null = null;
|
|
let ctx: gsap.Context | null = null;
|
|
|
|
function startLenis() {
|
|
if (lenis || reduce.matches) return;
|
|
lenis = new Lenis({ lerp: 0.12, wheelMultiplier: 1, autoRaf: false });
|
|
lenis.on('scroll', ScrollTrigger.update);
|
|
gsap.ticker.add((time) => lenis?.raf(time * 1000));
|
|
gsap.ticker.lagSmoothing(0);
|
|
}
|
|
|
|
function setup() {
|
|
ctx?.revert();
|
|
ctx = gsap.context(() => {
|
|
if (reduce.matches) return;
|
|
|
|
gsap.utils.toArray<HTMLElement>('[data-reveal]').forEach((el) => {
|
|
const targets = el.hasAttribute('data-reveal-stagger') ? Array.from(el.children) : [el];
|
|
gsap.from(targets, {
|
|
y: 36,
|
|
autoAlpha: 0,
|
|
rotate: el.dataset.reveal === 'tilt' ? -2.5 : 0,
|
|
duration: 0.85,
|
|
ease: 'power3.out',
|
|
stagger: 0.07,
|
|
scrollTrigger: { trigger: el, start: 'top 90%', once: true },
|
|
});
|
|
});
|
|
|
|
const mm = gsap.matchMedia();
|
|
mm.add('(min-width: 52rem)', () => {
|
|
gsap.utils.toArray<HTMLElement>('[data-parallax]').forEach((el) => {
|
|
const amount = parseFloat(el.dataset.parallax || '0.15');
|
|
gsap.to(el, {
|
|
yPercent: -100 * amount,
|
|
ease: 'none',
|
|
scrollTrigger: { trigger: el, start: 'top bottom', end: 'bottom top', scrub: true },
|
|
});
|
|
});
|
|
});
|
|
});
|
|
lenis?.resize();
|
|
ScrollTrigger.refresh();
|
|
}
|
|
|
|
document.addEventListener('astro:page-load', () => {
|
|
startLenis();
|
|
setup();
|
|
});
|
|
document.addEventListener('astro:before-swap', () => {
|
|
ctx?.revert();
|
|
ctx = null;
|
|
});
|
|
|
|
// Expose for menus that need to lock scrolling.
|
|
(window as unknown as { __lenis?: () => Lenis | null }).__lenis = () => lenis;
|