Skip to content

Commit 1df0424

Browse files
committed
Clamp after rounding.
1 parent 38d504f commit 1df0424

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/bevy_core_widgets/src/core_slider.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,15 @@ pub(crate) fn slider_on_drag(
355355
let slider_width = ((node.size().x - thumb_size) * node.inverse_scale_factor).max(1.0);
356356
let span = range.span();
357357
let new_value = if span > 0. {
358-
range.clamp(drag.offset + (distance.x * span) / slider_width)
358+
drag.offset + (distance.x * span) / slider_width
359359
} else {
360360
range.start() + span * 0.5
361361
};
362-
let rounded_value = precision
363-
.map(|prec| prec.round(new_value))
364-
.unwrap_or(new_value);
362+
let rounded_value = range.clamp(
363+
precision
364+
.map(|prec| prec.round(new_value))
365+
.unwrap_or(new_value),
366+
);
365367

366368
if matches!(slider.on_change, Callback::Ignore) {
367369
commands

0 commit comments

Comments
 (0)