Commit 75a825e 1 parent 3805a32 commit 75a825e Copy full SHA for 75a825e
File tree 1 file changed +7
-3
lines changed
crates/egui/src/containers
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -499,9 +499,13 @@ impl ScrollArea {
499
499
self . show_viewport ( ui, |ui, viewport| {
500
500
ui. set_height ( ( row_height_with_spacing * total_rows as f32 - spacing. y ) . at_least ( 0.0 ) ) ;
501
501
502
- let min_row = ( viewport. min . y / row_height_with_spacing) . floor ( ) as usize ;
503
- let max_row = ( viewport. max . y / row_height_with_spacing) . ceil ( ) as usize + 1 ;
504
- let max_row = max_row. at_most ( total_rows) ;
502
+ let mut min_row = ( viewport. min . y / row_height_with_spacing) . floor ( ) as usize ;
503
+ let mut max_row = ( viewport. max . y / row_height_with_spacing) . ceil ( ) as usize + 1 ;
504
+ if max_row > total_rows {
505
+ let diff = max_row. saturating_sub ( min_row) ;
506
+ max_row = total_rows;
507
+ min_row = total_rows. saturating_sub ( diff) ;
508
+ }
505
509
506
510
let y_min = ui. max_rect ( ) . top ( ) + min_row as f32 * row_height_with_spacing;
507
511
let y_max = ui. max_rect ( ) . top ( ) + max_row as f32 * row_height_with_spacing;
You can’t perform that action at this time.
0 commit comments