Documentation
¶
Overview ¶
Package scroll contains the small, state-free rules shared by Sidecar's scrollable surfaces. Rendering and content ownership stay with each surface; this package only answers movement and boundary questions in rows from the top, where negative deltas move up and positive deltas move down.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OffsetAtRow ¶ added in v1.4.0
OffsetAtRow maps a track row to the smallest scroll offset whose thumb top renders on or below that row, clamped to [0, totalItems-visibleItems]. Rows on a track with no thumb (content fits) map to 0. The mapping is monotonic in row. Re-rendering the returned offset pins the thumb back on the queried row exactly while travel (trackHeight minus thumb size) does not exceed maxOffset (totalItems minus visibleItems); beyond that ratio rows outnumber offsets, and re-rendering lands below the queried row instead, never above it.
func RowForOffset ¶ added in v1.4.0
RowForOffset maps a scroll offset to the track row where the renderer places the thumb top, clamped to [0, trackHeight-1]. Tracks with no thumb map every offset to 0.
Types ¶
type Bounds ¶
Bounds describes a vertical viewport position and its inclusive maximum.
func (Bounds) AtBoundary ¶
AtBoundary reports whether delta points out of the scrollable range.
type ThumbLoc ¶ added in v1.4.0
type ThumbLoc struct {
Size int // Thumb height in rows; always >= 1 when Has is set.
Pos int // Top row of the thumb, in [0, TrackHeight-Size].
Has bool // False when all content fits and no thumb should be drawn.
}
ThumbLoc is the proportional placement of a vertical scrollbar thumb within its track. All scrollbar surfaces share this math so the drawn thumb and the hit-tested one can never disagree.
func ThumbLocFor ¶ added in v1.4.0
ThumbLocFor computes proportional thumb placement from list geometry, matching the renderer's arithmetic exactly: size is the visible fraction of the track with a floor of one row, and position tracks the scroll offset across the remaining travel. Has is false when totalItems does not exceed visibleItems.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package scrolltest provides the shared inertial-wheel stress fixture used by boundary tests across sidecar.
|
Package scrolltest provides the shared inertial-wheel stress fixture used by boundary tests across sidecar. |