class ScrollPosition
Swift
final class ScrollPosition
Where a ScrollView is — for an app that has to remember it and put it
back: a folder list returning to the row it was opened from, or a tab
whose list should not come back scrolled to where another tab left it.
A reference the app keeps, one per place it wants remembered, and not a
binding: the offset is the renderer's and changes every frame of a scroll,
and an observed value would rebuild the app's body on each of them.
offset follows the renderer without anyone being told. scroll(to:)
puts the view there after the next layout — once the content's new length
is known, so an offset saved in a long folder is not clamped against the
short one being left — and before a lazy list decides which rows to mount,
so the first frame there is already full. It jumps rather than eases: the
point is to be where you were, not to be seen travelling there.
Handing a ScrollView a different position puts it where that one was.
Sources/LavaUI/ScrollView.swift:112
Constructors
init(offset: Float = 0)
Creates a position at offset points from the start.
Sources/LavaUI/ScrollView.swift:118
Properties
var offset: Float { get }
Where the view last was, in points from the top (or leading edge).
Sources/LavaUI/ScrollView.swift:114
Methods
func scroll(to offset: Float)
Moves the view to offset points from the start after the next layout,
without easing. Negative offsets are treated as zero; offsets past the end
are clamped against the content's length.
Sources/LavaUI/ScrollView.swift:125
func scrollToTop()
Moves the view back to the start. Same as scroll(to: 0).
Sources/LavaUI/ScrollView.swift:132