Skip to content

Modernize: TypeScript, hooks, rAF springs, tests, fixes for all open issues - #10

Merged
adamcwade merged 1 commit into
masterfrom
modernize
Jun 10, 2026
Merged

Modernize: TypeScript, hooks, rAF springs, tests, fixes for all open issues#10
adamcwade merged 1 commit into
masterfrom
modernize

Conversation

@adamcwade

Copy link
Copy Markdown
Owner

What this does

Full modernization of the library, closing every open issue.

Library rewrite

  • Function components with hooks in strict TypeScript, same public API as v1 (container + ParallaxMousemove.Layer, same props, same springSettings numbers)
  • react-motion removed: a small self-contained damped spring integrator (semi-implicit Euler, fixed 60Hz timestep) drives the motion, so the package has zero runtime dependencies
  • Animation runs on requestAnimationFrame and writes transforms directly to the DOM node, so mousemove never re-renders React
  • prefers-reduced-motion respected automatically, plus an explicit disabled prop
  • SSR safe: all window access lives in effects

Issues fixed

Toolchain

  • tsup build: ESM + CJS + .d.ts, proper exports map, sideEffects: false
  • vitest 4 + Testing Library: 21 tests covering spring convergence, factor math, retargeting mid-flight, settle-and-stop frame scheduling, unmount cleanup, the frozen-containerStyle regression, reduced motion, and disabled mode
  • GitHub Actions CI on Node 20/22/24 (typecheck, test, build)
  • npm audit: 0 vulnerabilities
  • Version bumped to 2.0.0; README rewritten with full API docs and a v1 migration section

Verified

  • 21/21 tests pass, tsc --noEmit clean, build emits ESM/CJS/DTS
  • Repo URLs updated to adamcwade

🤖 Generated with Claude Code

Rewrite the library as function components in strict TypeScript with a
self-contained spring integrator on requestAnimationFrame, replacing
react-motion and the 2017 CRA-ejected toolchain. Build with tsup
(ESM + CJS + bundled .d.ts), test with vitest 4 and Testing Library
(21 tests), CI on Node 20/22/24. Peer deps now react >=16.8, tested
against React 19.

Fixes #1: react-motion prop-type warnings are gone with the dependency.
Fixes #4: movement runs on requestAnimationFrame, not a 75ms setTimeout.
Fixes #5: fullHeight tracks window height in state instead of mutating
the containerStyle prop, with a frozen-object regression test.
Fixes #8: TypeScript declarations ship with the package.
Fixes #9: the deprecated babel-preset-stage-0 era toolchain is removed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@adamcwade
adamcwade merged commit 7ed045e into master Jun 10, 2026
0 of 3 checks passed
adamcwade added a commit that referenced this pull request Jun 11, 2026
Modernize: TypeScript, hooks, rAF springs, tests, fixes for all open issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant