ScrollArea
ui.widgets.mountScrollAreaSelbst gezeichnetes Scrollen, Scrollbars und programmatische Positionierung.
BEHAVIOR CONTRACT
Mausrad / Trackpad, Begrenzung, Momentum, Scrollbar, scrollIntoView und Pixelausrichtung teilen sich den Zustand.
RECORDED INTERACTION
Der Harness scrollt den Inhalt und zeichnet die Bewegung des Thumbs auf.
// ── 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;
}Der unveränderte Quellcode der Story aus dem Storybook (zenit 5f9add5+wip 2026-09-30). W steht für ui.widgets; col / row / label sind kleine Layout-Helfer des Storybooks.
ScrollAreaProps
ui.widgets.mountScrollAreafn mountScrollArea(props: ScrollAreaProps, scope: *Scope, cx: *Cx) !ScrollAreaResultFeld
Typ
Standard
Beschreibung
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.mountScrollAreaFeld
Typ
Standard
Beschreibung
container*Node—
—
content*Node—
—
state*ScrollState—
—