Repository navigation
Scroll: a notched mouse wheel glides as Chromium's does, on the device grid - #1150
Conversation
Whole notches of a mouse wheel (`WheelEvent::notch`, whole-line deltas on Windows) that no `on_wheel` handler takes ease to where they send a viewport on Chromium's mouse-wheel curve (cc/animation/scroll_offset_animation_curve.cc, kInverseDelta): cubic-bezier(0.42, 0, 0.58, 1) over 200 ms up to 120 device pixels, 100 ms from 480. A notch that comes while it moves sends it on from where it is with the speed it had (UpdateTarget, EaseInOutWithInitialSlope and the 2.5x velocity bound), so stacked notches run as one motion and a notch back turns it round. The ease is `ScrollMode::Wheel` on the vertical axis and `XMotion::Wheel` on the horizontal one, whose velocity and optional glide are now one `XMotion`. It steps at every frame; a hand, a key, a fling or `Tx::scroll_to` take the viewport over at once; reduced motion, or `Runtime::set_wheel_glide(false)`, lands it at once. macOS, Linux, precise trackpads and free-spinning wheels move 1:1 as before. A run of notches picks and keeps its viewport as #1123's deltas do (`Runtime::wheel_run`); a viewport that is gliding counts its room from where its ease heads, so a run that begins while one glides to its end starts on the viewport around it.
…takes no catch-up time As Chromium's scroll offsets are (measured at 1.875x: every offset of a notch's ease is a whole device pixel), so everything in the viewport moves by the same whole pixels each frame and draws as it did instead of at a new fraction of a pixel every frame. The time a frame charges to motion that was already running (`frame::clock::split`'s catch-up) no longer advances an ease a notch started or retargeted since the last frame.
…e or an anchor holds What moved the offset under a running ease since it last stepped (rows mounting and measuring above the reader, content arriving above, an anchor keeping what's on screen) now moves the ease's start and end by the same amount, as Chromium's ApplyAdjustment does, so the next frame doesn't pull the content back by what the measurement moved.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
…me, and stays put when sent back The two reads of #1150, together: - An extra notch at an end no longer starts an empty ease that lets go of a streaming reply: a notch with no ease running starts from a finished curve (`WheelCurve::still`), and one that sends it nowhere new changes no mode. - An ease sent to the end of a viewport that follows its bottom remembers it (`to_end`): as the end grows under it (a reply streaming) it takes its target with the end, lands there and pins. - Within a device pixel of the end, the end wins over the device grid (`on_grid_or_end`), so the room test hands the next run on and the pin threshold holds at any zoom. - A notch that sends a running ease back to where it is (a flick back before the next frame) lands it where it is, as Chromium's stays put, rather than finishing the ease before it. - A retarget of a moving ease is the same motion going on and keeps the frame's catch-up (it was a half step at 60 Hz after each stacked notch); a zero step doesn't count as a frame; and an ease from rest starts at its first frame, which draws where it was, as Chromium's does. - A notch or not is decided by a run's first delta and kept for the run (`DeltaKind`), so a fast touchpad swipe's whole-line delta doesn't start an ease the next fraction throws away. - Linux eases too: winit gives a wheel's detents there as whole lines (X11 buttons 4-7 and XInput2's position over its increment, Wayland's discrete values) and a touchpad's as fractions or pixels. - A `scroll_to` glide that starts during an ease keeps the ease's speed, and an app's keep (rows above measured, an anchor holding what's on screen) moves the ease with it rather than ending it, as Chromium's `ApplyAdjustment` does.
The first read's confirmation of #1150 at 5e4e46b: - An ease sent to the end of a viewport that follows its bottom pins on the frame it gets there. The end growing under it restarts its segment every frame a reply grows, so waiting for the curve to finish left the list trailing the end until the stream paused. - A retarget keeps whether its ease's first frame has come: two notches before that frame still start the ease on it, rather than the second's retarget charging that frame's catch-up. - A run of wheel deltas is notched only while every delta is whole: a touchpad swipe whose first delta was exactly a line is precise from its first fraction on.
|
Windows whole suite ( |
A notched mouse wheel now glides instead of jumping, on Chromium's curve: the ease the owner asked for on 16 Nov ("wheel jumps", "everywhere").
What's in:
on_wheelhandler takes ease to where they send a viewport, vertically and sideways. A notch is a run of whole-line deltas (WheelEvent::notch); the run's first delta decides and the run keeps it, so a fast touchpad swipe's whole-line delta stays precise.value120) stays 1:1, unlike Chromium, which eases it.The curve (
runtime/scroll/wheel.rs, fromcc/animation/scroll_offset_animation_curve.cc,kInverseDelta):cubic-bezier(0.42, 0, 0.58, 1), its duration from the whole remaining travel in device px: 200 ms up to 120 px, 100 ms from 480. One notch takes 200, 191.7 and 181.3 ms at 1×, 1.5× and 1.875×.UpdateTarget,EaseInOutWithInitialSlope, the 2.5× velocity bound). Stacked notches run as one motion, and a notch back turns it round. A retarget keeps the frame's catch-up, so the frame after a stacked notch is a whole step at 60 Hz. A notch that sends it back to where it is (a flick back before the next frame) lands it there. Two notches before the first frame still start on it. In the rare case where the velocity bound leaves a segment no time (wheel.rs:146), it stays where it is; Chromium jumps to the new target.(v * scale).round() / scale: steps of 2/3 pt at 1.5× and 8/15 pt at 1.875×. So it lands on the grid point nearest the notch's target, not exactly on the target. The exception is within a device pixel of an end, where it lands exactly on the end, so the next run hands on and a following list pins.Which viewport: the one #1137's chain picks: the topmost hit under the pointer, then its scroll ancestors. A gliding viewport counts its room from where its ease is heading.
What stays instant (A11Y): only a notched wheel eases.
ScrollMode::WheelandXMotion::Wheelare started only byRuntime::wheel_notchand the horizontal notch path. Anything else takes the viewport over at once: a focus move, Tab's reveal,Tx::scroll_toandscroll_into_view, AccessKit's scroll actions, Find, a hand, a key or a fling.scroll_toglide that starts during an ease keeps the ease's speed.ApplyAdjustmentmoves a running smooth scroll.Runtime::set_wheel_glide(false).Frames and drawing (both reads):
AnimSource::SCROLL), never a loop-only one, and everything that reads the offset reads what is drawn.on_scroll_offsetnow fires on every eased frame, up to 48 a notch at 240 Hz. Every handler in the app is cheap per call or already coalesced:Cell;Cell;show_sheet) for each new rounded viewport: up to 48 a notch. The worker drains its queue and renders only the newest frame (office/worker.rs), so superseded ones are dropped; a driven row counts them.State: the ease is a mode of the viewport's own state machine, not a flag:
ScrollMode::Wheel(WheelCurve)vertically andXMotion::Wheel(WheelCurve)sideways.XMotionreplaces the axis's separate velocity and glide fields. A run's kind isDeltaKind:Idle,NotchedorPrecise.Tests: no test is added. One line of test code changes:
mode.rs:339, a match arm in the existing test module that the newScrollMode::Wheelvariant forces.Driven rows (headless capture tickets on blade; offsets per frame from the app's trace, and pixels where marked). Every app is OpenCode (Rune)
dev8ad4ab46, release-quick, with Rune patched to a clean worktree (no uncommitted changes) unless the row says otherwise:ease-app-0fc1193e: Rune0fc1193e, this head;ease-1147-d777e8c4: Rune0fc1193emerged with Text in a scrolling list moves in whole pixels with its box #1147's head16854238;pin-db591e09:devdb591e09as pinned (Rune10a39584, Scroll: a wheel passes only to a region around the one under it, as Chromium chains a scroll #1137).ease-app-0fc1193eease-app-0fc1193eease-app-0fc1193eease-app-0fc1193eease-app-0fc1193eease-app-0fc1193eease-app-0fc1193ePresented::same), so the landing frame is presented.ease-app-0fc1193eease-app-0fc1193e/listease-app-0fc1193eease-app-0fc1193eandease-1147-d777e8c4pin-db591e09/list (800 pt; the timeline 0) and the app menu (0 and 0) all pass.ease-app-0fc1193e(counted from the rows)Rows while a reply streams (
fixture-stream-rows.ts). The fixture'ssessionscene, at 800×360, 144 Hz, 1× and 1.5×. A prompt sent from the composer at 1.25 s brings a reply that streams from about 1.5 s to 2.8 s. "On the end" means the content's lowest drawn edge sits where it did while the list was pinned before any notch.ease-app-0fc1193eease-app-0fc1193eease-app-0fc1193e; controlkeep-rq(#1137, no ease)Owed:
drive-server.ts10k session, which a headless run can't open yet (--sessionlooks the id up in a list a headless run hasn't filled).