diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index 2616fb4148d..8f6e1c0abb0 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -732,7 +732,12 @@ impl ScrollArea { ctx.animate_bool_responsive(id.with("v"), show_bars[1]), ); - let current_bar_use = show_bars_factor.yx() * ui.spacing().scroll.allocated_width(); + let scroll_style = ui.spacing().scroll; + let current_bar_use = if scroll_style.floating { + show_bars.to_vec2().yx() * scroll_style.allocated_width() + } else { + show_bars_factor.yx() * scroll_style.allocated_width() + }; let available_outer = ui.available_rect_before_wrap(); @@ -1158,9 +1163,12 @@ impl Prepared { let outer_rect = Rect::from_min_size(inner_rect.min, inner_rect.size() + current_bar_use); + // Epsilon to prevent jitter from floating-point rounding. + let epsilon = 0.5; + let content_is_too_large = Vec2b::new( - direction_enabled[0] && inner_rect.width() < content_size.x, - direction_enabled[1] && inner_rect.height() < content_size.y, + direction_enabled[0] && (inner_rect.width() + epsilon < content_size.x), + direction_enabled[1] && (inner_rect.height() + epsilon < content_size.y), ); let max_offset = content_size - inner_rect.size();