feat(core): detect middle-click autoscroll and yield wheel events (#528) - #536
Open
clementroche wants to merge 3 commits into
Open
feat(core): detect middle-click autoscroll and yield wheel events (#528)#536clementroche wants to merge 3 commits into
clementroche wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Track the browser's native middle-click autoscroll with a small phase state machine (middle pointerdown starts it, pointerup latches sticky mode, the next click's pointerup exits) and ignore wheel events while it is active so lenis doesn't fight the native scrolling. Detection only attaches on Chromium on Windows — the only place native autoscroll ships enabled — and skips middle-clicks on links, which open a tab instead of autoscrolling. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
arzafran
force-pushed
the
feat/auto-scroll-detection
branch
from
August 11, 2026 13:08
1a6b0f5 to
16b330b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #528 (wheel vs middle-click autoscroll jitter). Replaces the bare reset-on-middle-click with an
AutoScrollDetectionclass that tracks the browser's native autoscroll lifecycle, so lenis can stop smoothing wheel events while native autoscroll is driving the scroll.pointerdownstarts autoscroll (phase 1), itspointeruplatches sticky mode (phase 2), and the next click'spointerup— any button — exits (phase 3). While phases 1–2 are active,onVirtualScrollignores wheel events and lets the browser handle them.toggleevent fires on enter/exit and resets lenis's animated scroll state, replacing the previous unconditional reset on middlepointerdown.keydownresets detection to idle — keyboard input exits native autoscroll in Chromium — and so does windowblur, since after a focus loss the state can't be trusted. Both keep the flag from going stale and silently disabling wheel smoothing.Windows+ChromeUA check — Edge/Brave/Opera keep theChrometoken; Firefox/Safari don't match). Prevents the flag from going stale on platforms where the pointer events fire but no autoscroll follows.<a>opens a tab instead of autoscrolling, so it doesn't arm the flag.Test plan
Native autoscroll can't be triggered synthetically (CDP/dispatched events), so this needs real hardware verification on Windows.
🤖 Generated with Claude Code