ScrollState
A hoistable state holder for the scroll position of a ScrollPane.
x and y are two-way: assigning them scrolls the pane, and the user scrolling it - by wheel, scrollbar or keyboard - writes the new position back. The metrics the position is bounded by (extentWidth, extentHeight, viewWidth, viewHeight) and the largest useful position (maxX, maxY) follow the content and the pane's size, so state.y = state.maxY scrolls to the bottom of whatever is currently there.
Every value is snapshot-observable: reading one inside a composable (or a snapshotFlow collector) subscribes to later scrolling and resizing, so the reader recomposes as the pane moves.
canScrollForwardX, canScrollBackwardX, canScrollForwardY and canScrollBackwardY answer whether an axis has anywhere left to scroll, for a caller that offers a way to scroll further and wants it disabled at the end. A reader of one of them stands still until the answer itself changes.
revealRect scrolls to a region of the content instead of to a coordinate, for a caller that knows where something is but not where the pane has to stand to show it.
scroll runs a block that holds the position for as long as it lasts, for a caller that moves the pane over time - a step per frame - rather than in one write. Whatever else moves the position ends the block, so a scroll in progress gives way to the user; isScrollInProgress answers whether one is running.
A position outside the content is not refused, exactly as the widget does not refuse one: the pane takes it, and its next layout pass corrects it and reports the corrected value back here. The position outlives the content it was reached in - new content is scrolled to where the state stands, so a pane that leaves the composition and returns comes back where the user left it. A state renders at most one pane; declaring it on a second one moves it to that pane, and it moves back to the first as soon as the second stops declaring it while the first still does.
See also
Properties
Whether any content is left before the visible part across the pane: false while x stands at 0.
Whether any content is left before the visible part down the pane: false while y stands at 0.
The height of the visible part of the content, in view coordinates; 0 while no pane renders this state.
The width of the visible part of the content, in view coordinates; 0 while no pane renders this state.
Whether a scroll block currently holds the position, for a caller that shows or disables something while the pane is traveling.
The full height of the scrolled content, in view coordinates; 0 while no pane renders this state.
Functions
Brings the region rect names of the pane's content into view - in the content's own coordinates, where its top left corner is the origin, whatever the pane is currently scrolled to - and returns whether it was reached.
Runs block with this state's position to itself, for a caller that moves the pane over time - a step per frame - rather than in one write.