Fix ProgressBar example to avoid over the range.

This commit is contained in:
Jason Lee 2024-07-12 23:27:37 +08:00
parent 9371584e18
commit 0d6d1c95d0

View file

@ -66,14 +66,14 @@ impl Render for ProgressStory {
Button::new("button-5", cx)
.icon(IconName::Minus)
.on_click(cx.listener(|this, _, _| {
this.set_value(this.value - 1.);
this.set_value((this.value - 1.).max(0.));
})),
)
.child(
Button::new("button-6", cx)
.icon(IconName::Plus)
.on_click(cx.listener(|this, _, _| {
this.set_value(this.value + 1.);
this.set_value((this.value + 1.).min(100.));
})),
),
)