scrollbar: use divCeil to calculate correct height
This commit is contained in:
parent
f7cbd42ed5
commit
40e5b673b6
1 changed files with 1 additions and 2 deletions
|
@ -25,8 +25,7 @@ pub fn draw(self: Scrollbar, win: vaxis.Window) void {
|
||||||
// don't draw when all items can be shown
|
// don't draw when all items can be shown
|
||||||
if (self.view_size >= self.total) return;
|
if (self.view_size >= self.total) return;
|
||||||
|
|
||||||
var bar_height = self.view_size * win.height / self.total;
|
const bar_height = @max(std.math.divCeil(usize, self.view_size * win.height, self.total) catch unreachable, 1);
|
||||||
if (bar_height < 0) bar_height = 1;
|
|
||||||
const bar_top = self.top * win.height / self.total;
|
const bar_top = self.top * win.height / self.total;
|
||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
while (i < bar_height) : (i += 1)
|
while (i < bar_height) : (i += 1)
|
||||||
|
|
Loading…
Reference in a new issue