ScrollArea
ui.widgets.mountScrollAreaScroll dibujado a medida, barras de desplazamiento y posicionamiento programático.
BEHAVIOR CONTRACT
Rueda / trackpad, límites, inercia, scrollbar, scrollIntoView y alineación a píxel comparten estado.
RECORDED INTERACTION
El harness hace scroll en el contenido y graba cómo se mueve el thumb.
// ── ScrollArea ──
pub fn buildScrollArea(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
const a = cx.allocator;
const sa = try W.mountScrollArea(.{ .width = 320, .height = 320, .direction = .vertical }, scope, cx);
var i: usize = 0;
while (i < 40) : (i += 1) {
var buf: [32]u8 = undefined;
const txt = try std.fmt.bufPrint(&buf, "Scrollable line {d}", .{i});
try sa.content.appendChild(a, try ui.text(cx, txt, .{ .font_size = 13, .color = light.color.fg_primary }));
}
return sa.container;
}El código literal de la story en el Storybook (zenit 5f9add5+wip 2026-09-30). W es ui.widgets; col / row / label son pequeños helpers de layout del Storybook.
ScrollAreaProps
ui.widgets.mountScrollAreafn mountScrollArea(props: ScrollAreaProps, scope: *Scope, cx: *Cx) !ScrollAreaResultCampo
Tipo
Predeterminado
Descripción
width?f32null—
height?f32null—
directionScrollDirection.vertical.horizontal.both.vertical—
content_height?f32null—
content_width?f32null—
scroll_speedf321滚动速度乘数(macOS scrollingDelta 已是像素值,默认 1.0)
paddingPaddingPadding.ZERO—
backgroundColorColor.TRANSPARENT—
state_id?u64null自定义状态 ID(用于跨实例复用或区分滚动状态)
rubber_band_ybooltrue垂直方向是否启用 rubber band(果冻回弹)效果
rubber_band_xbooltrue水平方向是否启用 rubber band(果冻回弹)效果
ScrollAreaResult
ui.widgets.mountScrollAreaCampo
Tipo
Predeterminado
Descripción
container*Node—
—
content*Node—
—
state*ScrollState—
—