Skip to content

Simplify scroll reveal animation with CSS transitions#5

Merged
becktothefuture merged 4 commits into
mainfrom
claude/mobile-first-optimization-DenWE
Apr 22, 2026
Merged

Simplify scroll reveal animation with CSS transitions#5
becktothefuture merged 4 commits into
mainfrom
claude/mobile-first-optimization-DenWE

Conversation

@becktothefuture
Copy link
Copy Markdown
Owner

Summary

Refactored the scroll-reveal animation system from a complex JavaScript-based approach with frame-by-frame easing calculations to a simpler CSS transition-based system using IntersectionObserver.

Key Changes

  • Removed complex scroll animation logic: Eliminated ~200 lines of JavaScript handling easing functions, progress calculations, active record tracking, and frame-based measurements (easeOutPower, applyScrollIntroState, measureActiveRecords, etc.)

  • Simplified IntersectionObserver: Replaced sophisticated observer with threshold-based intersection detection that simply adds an is-visible class when elements enter the viewport

  • CSS-driven animations: Moved animation logic to CSS with:

    • Cubic-bezier easing curves (replacing power-based easing)
    • CSS transitions for opacity and transform
    • Stagger effect via --stagger-index CSS variable instead of speed-based multipliers
  • Updated ScrollIntro component:

    • Removed speed prop (was 'base' or 'slow')
    • Added index prop for stagger calculations
    • Simplified observer cleanup logic
  • CSS refinements:

    • Standardized breakpoints (600px, 1024px, 1280px)
    • Updated spacing scale (--space-10 adjusted)
    • Consolidated media queries (removed duplicate 760px breakpoint)
    • Added .js-ready class detection for progressive enhancement
  • Added screenshot capture tooling: New scripts/capture-screenshots.mjs for visual regression testing across multiple viewports and sections

  • Updated package.json: Added screenshot capture npm scripts

Implementation Details

The new system relies on:

  • A single js-ready class added to <html> to enable transitions only when JavaScript is ready
  • IntersectionObserver with threshold: 0.12 and rootMargin: '0px 0px -8% 0px' for reveal timing
  • CSS transition-delay calculated from --stagger-index (max 4) × 70ms for cascading reveals
  • Graceful fallback: elements are visible by default; animations only apply when JS is ready and motion is not reduced

This approach reduces bundle size, improves maintainability, and provides better performance by leveraging native browser animations.

https://claude.ai/code/session_014BQEj343rKYdVUCEGhdPBN

claude added 4 commits April 22, 2026 08:05
Adds @playwright/test (pinned 1.56.0 to match local chromium rev 1194),
scripts/capture-screenshots.mjs and npm run screenshot:{baseline,after}.
Captures full-page + clipped per-section PNGs at 375/430/768/1280/1440 so
mobile + desktop changes are visible before/after.

https://claude.ai/code/session_014BQEj343rKYdVUCEGhdPBN
Replaces the per-frame rAF manager (300px translate, 20% settle band,
same easing power for 'base' and 'slow') with a shared IO that flips
.is-visible once and unobserves. Initial offset drops to 36px and is
gated behind .js-ready on <html>, so no-JS and slow-hydration users see
content in place instead of a blank page (the previous default hid
content 300px below with opacity 0). Stagger is driven by
--stagger-index and CSS transition-delay, passed via index prop on
benefit/install/science list items. 'speed=slow' was dead code (same
ease power as base) and has been removed.

https://claude.ai/code/session_014BQEj343rKYdVUCEGhdPBN
Playwright's fullPage CDP capture does not fire scroll/resize events,
so IntersectionObserver-gated content stays hidden in the screenshot.
Walk the page top-to-bottom before the fullpage capture so every
scroll-intro reveals, and also capture a separate first-paint.png to
surface hidden-content regressions on initial load.

https://claude.ai/code/session_014BQEj343rKYdVUCEGhdPBN
… token header

- Remove duplicate @media (max-width: 1023.98px) block (rules were
  either duplicated or overridden in the second block)
- Merge duplicate @media (max-width: 599.98px) blocks; second block
  overrode depth-lab grid columns from 2-col to 1-col — consolidated
  into single block with corrected declarations
- Add design-token summary comment at top of styles.css to orient
  contributors (breakpoints, shell, space scale, scroll-reveal)
- Remove stale "site currently broken" badge and text from README;
  replace with live site link

https://claude.ai/code/session_014BQEj343rKYdVUCEGhdPBN
@becktothefuture becktothefuture merged commit e14bcd3 into main Apr 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants