components/scrollarea
Layout · 50 / 64

ScrollArea

ui.widgets.mountScrollArea

Selbst 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.

examples/storybook/stories.zig:2986
// ── 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;
}
Quellcode auf GitHub ansehenexamples/storybook/stories.zig:2986

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.

zenit · DoppellizenzKostenlos für Open-Source-Projekte unter GPL-3.0-only; Closed-Source- oder kommerzielle Produkte benötigen eine kommerzielle Lizenz.Kontakt zum Autor: zongyi.xzy#gmail.com (# durch @ ersetzen)zenit 5f9add5+wip 2026-09-30