ScrollArea
ui.widgets.mountScrollAreaDéfilement dessiné sur mesure, barres de défilement et positionnement programmatique.
BEHAVIOR CONTRACT
Molette / trackpad, bornage, inertie, scrollbar, scrollIntoView et alignement au pixel partagent un état.
RECORDED INTERACTION
Le harness fait défiler le contenu et enregistre le déplacement du 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;
}Le code source tel quel de la story dans le Storybook (zenit 5f9add5+wip 2026-09-30). W désigne ui.widgets ; col / row / label sont de petits helpers de mise en page du Storybook.
ScrollAreaProps
ui.widgets.mountScrollAreafn mountScrollArea(props: ScrollAreaProps, scope: *Scope, cx: *Cx) !ScrollAreaResultChamp
Type
Défaut
Description
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.mountScrollAreaChamp
Type
Défaut
Description
container*Node—
—
content*Node—
—
state*ScrollState—
—