From c4f16af721be7060662cc76f2bd7793e3b656217 Mon Sep 17 00:00:00 2001 From: YgorSouza <43298013+YgorSouza@users.noreply.github.com> Date: Thu, 28 Mar 2024 10:43:28 +0100 Subject: [PATCH] Prevent plot from resetting one axis while zooming/dragging the other (#4252) * Closes --- crates/egui_plot/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/egui_plot/src/lib.rs b/crates/egui_plot/src/lib.rs index 26567117..6056f46b 100644 --- a/crates/egui_plot/src/lib.rs +++ b/crates/egui_plot/src/lib.rs @@ -1021,7 +1021,7 @@ impl Plot { delta.y = 0.0; } mem.transform.translate_bounds(delta); - mem.auto_bounds = !allow_drag; + mem.auto_bounds = mem.auto_bounds.and(!allow_drag); } // Zooming @@ -1092,7 +1092,7 @@ impl Plot { } if zoom_factor != Vec2::splat(1.0) { mem.transform.zoom(zoom_factor, hover_pos); - mem.auto_bounds = !allow_zoom; + mem.auto_bounds = mem.auto_bounds.and(!allow_zoom); } } if allow_scroll.any() {