Skip to content

HumanMouse::scroll snaps back at the end of every scroll #9

Description

@dashn9

HumanMouse::scroll ends each call with a single correction wheel event, and that event is frequently negative on a downward scroll — the page visibly jumps backwards at the end of every scroll.

Observed

Wheel deltas recorded on the page (addEventListener('wheel', ...)) while scrolling a profile page in 120px pushes:

101,12,1,6, 93,9,1,17, 110,12,1,-3, 97,12,1,10, 114,12,1,-7, 105,10,1,4, 113,11,1,-5, ...

Every fourth event is the correction, and roughly half of them reverse direction. On larger single calls the reversal is much bigger — a 5600px scroll produced corrections of -56, -298, -127.

Expected

A downward scroll only ever emits downward deltas. Real wheel or trackpad input does not reverse at the end of a gesture, so the negative tail is a fingerprint as well as a visual glitch.

Cause

rustenium/src/input/human_mouse.rs, in scroll:

  • each eased step is multiplied by noise in 1.0 ± 0.15 and rounded, so accumulated drifts past y_distance about half the time;
  • the trailing correction = y_distance - accumulated is then dispatched as-is, sign included.

Suggested fix

Either clamp each step to the distance still owed (so accumulated can never exceed y_distance), or drop the correction when its sign opposes y_distance. The first keeps the requested distance exact and never reverses; the second is a one-line guard.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions