Skip to content

Commit 84a3426

Browse files
authored
Fix dynamic bounds modifications (#96)
* This broke in #74 The problem was caused by using `PlotUi::set_auto_bounds`. I don't fully understand it all. I really don't like this. The code is confusing and lacking of tests, but as usual, I don't have time to dig into it right now.
1 parent fb3ff8b commit 84a3426

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

egui_plot/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ impl<'a> Plot<'a> {
994994
mem.auto_bounds = true.into();
995995
}
996996

997+
let any_dynamic_modifications = !bounds_modifications.is_empty();
997998
// Apply bounds modifications.
998999
for modification in bounds_modifications {
9991000
match modification {
@@ -1017,10 +1018,10 @@ impl<'a> Plot<'a> {
10171018
}
10181019

10191020
// Reset bounds to initial bounds if they haven't been modified.
1020-
if !default_auto_bounds.x || mem.auto_bounds.x {
1021+
if (!default_auto_bounds.x && !any_dynamic_modifications) || mem.auto_bounds.x {
10211022
bounds.set_x(&min_auto_bounds);
10221023
}
1023-
if !default_auto_bounds.y || mem.auto_bounds.y {
1024+
if (!default_auto_bounds.y && !any_dynamic_modifications) || mem.auto_bounds.y {
10241025
bounds.set_y(&min_auto_bounds);
10251026
}
10261027

0 commit comments

Comments
 (0)