Prevent plot from resetting one axis while zooming/dragging the other (#4252)

* Closes <https://github.com/emilk/egui/issues/4251>
This commit is contained in:
YgorSouza 2024-03-28 10:43:28 +01:00 committed by GitHub
parent 3dba73e63e
commit c4f16af721
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -1021,7 +1021,7 @@ impl Plot {
delta.y = 0.0; delta.y = 0.0;
} }
mem.transform.translate_bounds(delta); mem.transform.translate_bounds(delta);
mem.auto_bounds = !allow_drag; mem.auto_bounds = mem.auto_bounds.and(!allow_drag);
} }
// Zooming // Zooming
@ -1092,7 +1092,7 @@ impl Plot {
} }
if zoom_factor != Vec2::splat(1.0) { if zoom_factor != Vec2::splat(1.0) {
mem.transform.zoom(zoom_factor, hover_pos); 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() { if allow_scroll.any() {