Skip to main content

Module scroll_position

Module scroll_position 

Source
Expand description

How far a scroller is scrolled, kept where it outlives the widget tree, and the scroller the views’ lists are shown in.

Another view shown in a list’s place throws the scroller’s own state away, and so does closing the popup. A ScrollPosition, the first thing in a scroller, keeps how far it is scrolled in a cell the model owns; coming back, the view scrolls to where the cell says it was.

A scroller that is new, as every one is in a popup that just opened, does that by itself: Restoring, around it, scrolls it to where the cell says before it is first drawn. Nobody sees its top go by, and no message has to find a window that may not be there yet.

It takes no room and draws nothing. What it keeps is how far its own place is above the top of what is in view, which, for the first thing in a scroller, is how far the scroller is scrolled.

Over the row of a long note that shows in full, the same thing keeps how far the top of that row is scrolled out of view: what the list is scrolled back by when the note is cut again (see Expanded).

sequenceDiagram
    participant model as The model's cell
    participant position as ScrollPosition
    participant scroller as The scroller
    Note over scroller: the reader scrolls
    scroller->>position: drawn, so far above the top of the view
    position->>model: that far
    Note over scroller: the popup closes: the scroller and its state are gone
    Note over scroller: the popup opens: a new scroller, at its top
    model->>scroller: scrolled to where the cell says, before the first frame (Restoring)
    Note over scroller: the reader sees the list where it was

Why the place has to be kept at all, and what else is kept the same way, is in crate::guide::architecture.

Structs§

PlaceInScroller
Keeps place at how far down what is in a scroller its own place is: put before a list that is not the first thing in its scroller, how far the scroller is scrolled when the list’s first row is at the top of what is in view.
Restored 🔒
Whether a Restoring has put its scroller where it was. Widget state: it starts over with the widget tree, as the scroller’s own place does.
Restoring
content, which holds the scroller scroller, scrolled to position before it is first drawn. After that the scroller is its user’s.
ScrollPosition
Keeps position at how far its own place is above the top of what is in view: for the first thing in a scroller, how far that is scrolled.

Functions§

list_scroller
content, a view’s list and whatever it has above and under it, in the scroller the views share, which keeps position at how far it is scrolled, and starts out there.