Skip to main content

Module drag_autoscroll

Module drag_autoscroll 

Source
Expand description

The drag auto-scroll edge ramp, implemented once.

Every view that accepts a drag over a scrolling viewport — ListView, TreeView, TableView, TreeTableView, GridView’s marquee and the TabBar strip — scrolls when the pointer lingers near an edge. Each one carried its own EDGE = 32.0 / MAX_VELOCITY = 12.0 pair and its own copy of the ramp; this module is the single definition they now share.

§Why the band is a pointer-kind question, not a density one

The edge band is the distance from the viewport edge at which auto-scroll begins. What makes it right or wrong is how precisely the user can park a pointer near an edge, which is a property of the device: a mouse cursor lands where it is put, a fingertip covers roughly 9 mm of screen and its reported centre wanders. So the band widens for a coarse pointer and is unchanged for a precise one — it does not move with TargetDensity, which describes how big the UI’s targets are.

The velocity cap is neither: it is a rate, not a dimension, and the same 12 dp per tick reads correctly under every pointer and every density.

Reference: engineering/docs/density-inventory.md §3b, and the touch design’s Constants table (“DnD edge auto-scroll band / max velocity”).

Constants§

EDGE_BAND_COARSE
Edge band for a coarse pointer (a finger), in dp — twice the precise band, because a contact patch’s reported centre cannot be parked as finely as a cursor.
EDGE_BAND_PRECISE
Edge band for a precise pointer (mouse, pen), in dp. The value every data view used before the touch programme, kept exactly.
MAX_VELOCITY
Cap on the per-tick auto-scroll step, in dp. A rate, not a dimension: the same under every pointer kind and every density.

Functions§

band_for
The edge band for a pointer kind.
step
The auto-scroll step, in dp, for a pointer at pointer_main along a viewport of viewport_extent.