scrollbars

master
Dustin Swan 2 weeks ago
parent 783146dabc
commit 80cd8d6c7b
Signed by: dustinswan
GPG Key ID: 30D46587E2100467

@ -24,6 +24,32 @@ button = config \
} }
}; };
# scrollable
scrollable = config \
barHeight = max 20 (config.h * config.h / config.totalHeight);
barY = config.scrollY * config.h / config.totalHeight;
showBar = config.totalHeight > config.h;
ui.stack {
children = [
ui.scrollable {
w = config.w,
h = config.h,
scrollX = 0,
scrollY = config.scrollY,
onScroll = config.onScroll,
child = config.child
},
...(showBar
| True \ [ui.positioned {
x = config.w - 4,
y = barY,
child = ui.rect { w = 4, h = barHeight, color = "rgba(255,255,255,0.3)", radius = 2 }
}]
| False \ [])
]
};
box = config \ box = config \
defaults = { defaults = {
w = 100, w = 100,

@ -114,9 +114,10 @@ palette = config \
onChange = text \ batch [paletteState.query := text], onChange = text \ batch [paletteState.query := text],
}, },
ui.scrollable { scrollable {
w = contentWidth, w = contentWidth,
h = listHeight, h = listHeight,
totalHeight = totalHeight,
scrollX = 0, scrollX = 0,
scrollY = paletteState.scrollOffset, scrollY = paletteState.scrollOffset,
onScroll = onScroll, onScroll = onScroll,

Loading…
Cancel
Save