scroll

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func OffsetAtRow(totalItems, visibleItems, trackHeight, row int) int

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

func RowForOffset(totalItems, visibleItems, trackHeight, offset int) int

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

type Bounds struct {
	Position int
	Maximum  int
}

Bounds describes a vertical viewport position and its inclusive maximum.

func (Bounds) AtBoundary

func (b Bounds) AtBoundary(delta int) bool

AtBoundary reports whether delta points out of the scrollable range.

func (Bounds) Move

func (b Bounds) Move(delta int) (position int, changed bool)

Move applies delta and clamps the result to the scrollable range. Changed is false at either boundary, which lets callers avoid downstream work.

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

func ThumbLocFor(totalItems, scrollOffset, visibleItems, trackHeight int) ThumbLoc

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL