Documentation
¶
Overview ¶
Package scrollwheel coalesces rapid mouse wheel events into batched scroll messages, preventing per-event Update + Render cycles from pegging CPU.
The coalescer intercepts wheel events via a Bubble Tea filter, accumulates deltas over a short debounce window and flushes them as a single Msg. A user-supplied Resolver maps the current model to an application-defined scroll target so the coalescer can route events correctly and flush immediately when the target changes mid-batch.
Index ¶
Constants ¶
const DefaultDelay = 12 * time.Millisecond
DefaultDelay is the debounce window for coalescing wheel events.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coalescer ¶
type Coalescer[T comparable] struct { // contains filtered or unexported fields }
Coalescer batches rapid mouse wheel events and flushes them as a single Msg after a short debounce window.
func New ¶
New creates a coalescer. The send function is typically tea.Program.Send; it must be safe to call from any goroutine.
func (*Coalescer[T]) Filter ¶
Filter is a tea.WithFilter-compatible function. It swallows mouse wheel events directed at a scrollable view, accumulates their delta and returns nil so Bubble Tea skips the normal Update + Render cycle. Non-wheel messages pass through unchanged.
type Msg ¶
type Msg[T comparable] struct { Target T Delta int }
Msg carries an accumulated scroll delta for a given target. Positive delta means scroll down, negative means scroll up.