core/scrollview/options.go
Functions
func DirectionOpt
func DirectionOpt(d ScrollDirection) Option {
return func(c *config) {
c.direction = d
}
}
func OnScroll
OnScroll sets the callback invoked when the scroll position changes.
The callback receives the new (scrollX, scrollY) offsets.
func OnScroll(fn func(x, y float32)) Option {
return func(c *config) {
c.onScroll = fn
}
}
func PainterOpt
PainterOpt sets the painter used to render the scrollbar.
Each design system provides its own painter. If not set,
[DefaultPainter] is used.
func PainterOpt(p Painter) Option {
return func(c *config) {
c.painter = p
}
}
func ScrollStep
ScrollStep sets the number of pixels scrolled per wheel tick.
Default is 40 pixels.
func ScrollStep(step float32) Option {
return func(c *config) {
c.scrollStep = step
}
}
func ScrollX
ScrollX sets the initial horizontal scroll offset.
func ScrollX(x float32) Option {
return func(c *config) {
c.scrollX = x
}
}
func ScrollXReadonlySignal
ScrollXReadonlySignal binds the horizontal scroll offset to a read-only signal.
When set, this takes highest precedence over all other scrollX sources.
func ScrollXReadonlySignal(sig state.ReadonlySignal[float32]) Option {
return func(c *config) {
c.readonlyScrollXSignal = sig
}
}
func ScrollXSignal
ScrollXSignal binds the horizontal scroll offset to a reactive signal.
This is a TWO-WAY binding: the widget reads the offset from the signal,
and when the user scrolls, the new offset is written back to the signal.
func ScrollXSignal(sig state.Signal[float32]) Option {
return func(c *config) {
c.scrollXSignal = sig
}
}
func ScrollY
ScrollY sets the initial vertical scroll offset.
func ScrollY(y float32) Option {
return func(c *config) {
c.scrollY = y
}
}
func ScrollYReadonlySignal
ScrollYReadonlySignal binds the vertical scroll offset to a read-only signal.
When set, this takes highest precedence over all other scrollY sources.
func ScrollYReadonlySignal(sig state.ReadonlySignal[float32]) Option {
return func(c *config) {
c.readonlyScrollYSignal = sig
}
}
func ScrollYSignal
ScrollYSignal binds the vertical scroll offset to a reactive signal.
This is a TWO-WAY binding: the widget reads the offset from the signal,
and when the user scrolls, the new offset is written back to the signal.
func ScrollYSignal(sig state.Signal[float32]) Option {
return func(c *config) {
c.scrollYSignal = sig
}
}
func ScrollbarOpt
ScrollbarOpt sets the scrollbar visibility mode.
Default is [ScrollbarAuto].
func ScrollbarOpt(v ScrollbarVisibility) Option {
return func(c *config) {
c.scrollbar = v
}
}
DirectionOpt sets the scroll direction.
Default is [Vertical].