this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

ScrollView: do scroll bounds checking early

The ScrollView will panic if scroll.y is given a number that is outside
the content size.

authored by

Jari Vetoniemi and committed by
Tim Culverhouse
9bbcebb7 5a438e54

+4 -5
+4 -5
src/widgets/ScrollView.zig
··· 51 51 cols: usize, 52 52 rows: usize, 53 53 }) void { 54 - var content_cols = content_size.cols; 54 + const content_cols = if (self.vertical_scrollbar) |_| content_size.cols +| 1 else content_size.cols; 55 + const max_scroll_x = content_cols -| parent.width; 56 + const max_scroll_y = content_size.rows -| parent.height; 57 + self.scroll.restrictTo(max_scroll_x, max_scroll_y); 55 58 if (self.vertical_scrollbar) |opts| { 56 59 const vbar: vaxis.widgets.Scrollbar = .{ 57 60 .character = opts.character, ··· 67 70 }); 68 71 bg.fill(.{ .char = opts.character, .style = opts.bg }); 69 72 vbar.draw(bg); 70 - content_cols +|= 1; 71 73 } 72 - const max_scroll_x = content_cols -| parent.width; 73 - const max_scroll_y = content_size.rows -| parent.height; 74 - self.scroll.restrictTo(max_scroll_x, max_scroll_y); 75 74 } 76 75 77 76 pub const BoundingBox = struct {