Skip to content

Commit

Permalink
Fix slider rounding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
aurexav committed Jul 13, 2024
1 parent 08c75d7 commit b8976a6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/egui/src/widgets/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,13 @@ impl<'a> Slider<'a> {
let end = *self.range.end();
value = value.clamp(start.min(end), start.max(end));
}
if let Some(max_decimals) = self.max_decimals {
value = emath::round_to_decimals(value, max_decimals);
}
if let Some(step) = self.step {
let start = *self.range.start();
value = start + ((value - start) / step).round() * step;
}
if let Some(max_decimals) = self.max_decimals {
value = emath::round_to_decimals(value, max_decimals);
}
set(&mut self.get_set_value, value);
}

Expand Down

0 comments on commit b8976a6

Please sign in to comment.