Skip to content

docs(react): keep the custom animation frame loop running - #559

Open
dajiaohuang wants to merge 1 commit into
darkroomengineering:mainfrom
dajiaohuang:fix/react-readme-recurring-raf-20261016
Open

dajiaohuang wants to merge 1 commit into
darkroomengineering:mainfrom
dajiaohuang:fix/react-readme-recurring-raf-20261016

Conversation

@dajiaohuang

Copy link
Copy Markdown

What & why

The React README's custom requestAnimationFrame example schedules update only once, while explicitly setting options.autoRaf to false. After that first frame, wheel input starts a Lenis animation but nothing advances it, so the page does not scroll.

Schedule the next frame inside update, and retain the latest request ID so the existing effect cleanup cancels the pending frame on unmount. This changes only the example; no library behavior changes.

No companion issue: this is a small, directly reproducible documentation fix. Existing #410 addressed disabling the automatic loop, rather than keeping the custom loop running.

How to verify

Copy the example into a React app, import the recommended Lenis CSS, and add a long article below it. Once mounted, scroll with the mouse wheel, then unmount the component.

Tested with React 19.2.4 and real Chromium 151.0.7922.34 through Playwright on an isolated loopback miniapp, bundling the documented App with the local Lenis build:

  • Before: after mount, the example executes one update. A 500px wheel input leaves window.scrollY at 0 and isScrolling at smooth.
  • After: the same input reaches window.scrollY === 500, emits scrolling callbacks, and settles with isScrolling === false.
  • Unmount: no further update callbacks; Lenis root classes are removed.
  • Core checks also passed for automatic/manual RAF, scrollTo completion, stop/start/destroy, nested native scrolling, horizontal container scrolling, anchors, and live reduced motion.
  • bun install --frozen-lockfile --ignore-scripts and bun run build passed (including generated declarations). Dependency install scripts were not run. Standalone tsc --noEmit is not green on the unchanged base: unresolved self-package lenis imports and Nuxt #imports; this documentation change does not alter those paths.

Checklist

  • PR is focused on a single logical change
  • Linked the related issue (or explained why there isn't one)
  • Applicable build/browser/diff checks pass locally; standalone typecheck limit disclosed above
  • Updated docs/types where relevant (docs only; no type changes)

@dajiaohuang
dajiaohuang requested a review from a team as a code owner October 16, 2026 02:03
@vercel

vercel Bot commented Oct 16, 2026

Copy link
Copy Markdown

@dajiaohuang is attempting to deploy a commit to the Darkroom Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant