From 73671bad4a164f80b8237cf14243e86c20bba0d2 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 11 Dec 2025 10:51:20 +1000 Subject: [PATCH] Fix no auto_bounds preventing pan/zoom/scroll The previous logic would force reset the bounds for an axis if its auto_bounds was false. I believe that the behavior of mem.auto_bounds already sufficiently achieves the intended behavior here. Scenarios tested: - User can pan/zoom/scroll with auto_bounds true/false - Double-click resets auto_bounds the plot (regardless of default_auto_bounds setting) - Plot bounds are updated when plot data changes after double-clicking - User can still interact with the plot (pan/zoom/scroll) after double-clicking Fixes #151 --- egui_plot/src/plot.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/egui_plot/src/plot.rs b/egui_plot/src/plot.rs index b6fd3085..a48fbf43 100644 --- a/egui_plot/src/plot.rs +++ b/egui_plot/src/plot.rs @@ -977,7 +977,6 @@ impl<'a> Plot<'a> { mem.auto_bounds = true.into(); } - let any_dynamic_modifications = !plot_ui.bounds_modifications.is_empty(); // Apply bounds modifications. for modification in &plot_ui.bounds_modifications { match modification { @@ -1006,11 +1005,11 @@ impl<'a> Plot<'a> { } } - // Reset bounds to initial bounds if they haven't been modified. - if (!self.default_auto_bounds.x && !any_dynamic_modifications) || mem.auto_bounds.x { + // Reset bounds to initial bounds if current auto_bounds are active. + if mem.auto_bounds.x { bounds.set_x(&self.min_auto_bounds); } - if (!self.default_auto_bounds.y && !any_dynamic_modifications) || mem.auto_bounds.y { + if mem.auto_bounds.y { bounds.set_y(&self.min_auto_bounds); }