Skip to content

createAutoScroller

createAutoScroller(options): AutoScroller

Defined in: dom/src/dom-utils/autoscroll.ts:75

The autoscroll of a drag near the edge of the viewport: every animation frame scrollLeft moves by the core’s current velocity, until that is 0. It only writes scrollLeft and says so (scrolled): the host reports the offset to the core like any other scroll, which grows the infinite timeline and places the dragged bar under the still pointer again, all before the frame is painted.

The velocity is px per frame of a 60 Hz display, and a frame moves velocity * dt / 16.67, with dt the time since the previous frame, so that a 120 Hz or 30 Hz display scrolls as fast as a 60 Hz one. dt is capped at 64 ms (a throttled tab must not throw the chart), and the first frame of a run counts as a 60 Hz one.

The position is kept as a float of its own, because an element rounds what it is given to its pixels (a velocity of 0.4 would read back as the same pixel forever), and is taken from the element again when that moved by more than a pixel from what was written: the scroll compensation of an extension moved it, or the content ends there (so the loop does not wind up against the end and then jump when the range grows).

AutoScrollerOptions

See AutoScrollerOptions.

AutoScroller

The loop, idle until start.