Repository navigation
Honor acceleration=0 and inertia=0 in SmoothedScrollingEngine - #1337
Merged
lujjjh merged 3 commits intoAug 7, 2026
Merged
Conversation
…ngine When "Scroll acceleration" is at its lower bound (0), bypass the rate-dependent input curve (and the acceleration gain, which is already 1 here) so each wheel tick travels a constant distance and velocity is strictly proportional to input. When "Inertia" is at its lower bound (0), return a momentum decay of 0 so scrolling stops with the wheel and no synthetic momentum is carried. Both changes are gated behind a clean `== lowerBound` short-circuit; the non-zero (legacy) code path is byte-for-byte unchanged, keeping the behavior trivially reversible. AxisTuning is widened from private to internal so the velocity/decay contracts can be exercised directly via @testable unit tests. Adds 7 tests: linearity at acceleration=0 across 4 presets x 2 speeds, golden locks for the legacy desiredVelocity and momentumDecay formulas, momentumDecay==0 at inertia=0, and an end-to-end check that no momentum phase is emitted. Full suite: 530 tests, 0 failures. Closes linearmouse#1303. Co-Authored-By: Claude <[email protected]>
Add testValuesJustAboveLowerBoundStayOnLegacyPath: a value just above the lower bound (0.001) must stay on the legacy path, turning the == lowerBound short-circuit into a verified contract. Catches a future change of == to <= (or a shifted lowerBound): the rate curve stays active at acceleration=0.001 (v(100) > v(25)*4) and legacy decay stays positive at inertia=0.001 (momentumDecay > 0). Full suite: 531 tests, 0 failures. Co-Authored-By: Claude <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates SmoothedScrollingEngine to honor the “off” positions of the smooth scrolling acceleration and inertia sliders (issue #1303), ensuring that 0 disables the rate curve / momentum behavior instead of leaving residual effects due to the legacy formulas and clamps.
Changes:
- Add an
acceleration == lowerBoundshort-circuit inAxisTuning.desiredVelocity(for:)to bypass the rate-dependentpow(normalizedMagnitude, inputExponent)curve and keep velocity strictly proportional to wheel input. - Add an
inertia == lowerBoundshort-circuit inAxisTuning.momentumDecay(for:)so momentum decay becomes0and scrolling stops immediately when wheel input stops. - Widen
AxisTuningvisibility (still nested) and add focused unit tests covering linearity at acceleration=0, decay behavior at inertia=0, and boundary/legacy-path regressions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| LinearMouse/EventTransformer/SmoothedScrollingEngine.swift | Adds explicit lower-bound bypasses for acceleration and inertia in the tuning logic while preserving the legacy path for non-zero values. |
| LinearMouseUnitTests/EventTransformer/SmoothedScrollingEngineTests.swift | Adds unit coverage to lock in the new zero-boundary behavior and ensure legacy behavior remains unchanged when values are non-zero. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
|
Thanks! I was initially concerned that inertia 0 might make smooth scrolling stop too abruptly, but 0 does reasonably imply that inertia is fully disabled. I think this is reasonable to merge and evaluate based on user feedback. |
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
Honor the lower bound of the "Scroll acceleration" and "Inertia" sliders in
SmoothedScrollingEngineso that the extreme "off" positions behave as users expect:pow(normalizedMagnitude, inputExponent)curve (and the acceleration gain, which is already1here) so each wheel tick travels a constant distance — velocity becomes strictly proportional to input.momentumDecay == 0, so scrolling stops the moment the wheel stops, with no synthetic momentum phase.Both changes sit behind a clean
== Scheme.Scrolling.Smoothed.<range>.lowerBoundshort-circuit. The non-zero (legacy) code path is byte-for-byte unchanged, so the behavior is trivially reversible.Root cause:
pow(normalizedMagnitude, profile.inputExponent)amplified distance regardless of the acceleration slider, andmomentumDecaywas clamped to0.72 ... decayCeiling, leaving residual velocity even at inertia = 0.Verification
SmoothedScrollingEngine.AxisTuningwas widened fromprivatetointernalso its velocity/decay contracts can be unit-tested via@testable. 8 focused tests were added:v(100) == v(25) * 4,v(50) == v(25) * 2).== lowerBoundcontract so it can't silently widen to<=.3455.117.momentumDecay == 0at inertia=0 (threedtvalues); end-to-end: nomomentumBeganever emitted.pow(0.89, 0.5)) and at the0.25clamp boundary.Gate green: SwiftFormat + SwiftLint clean (0 serious; 95 pre-existing warnings in unrelated files);
SmoothedScrollingEngineTests27/0; full suite 531 tests, 0 failures.Related issues
Closes #1303.