From 0d6d1c95d0e639e1230d9324356e10e4d72ed8ad Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 12 Jul 2024 23:27:37 +0800 Subject: [PATCH] Fix ProgressBar example to avoid over the range. --- crates/story/src/progress_story.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/story/src/progress_story.rs b/crates/story/src/progress_story.rs index 95100126..8436e9d4 100644 --- a/crates/story/src/progress_story.rs +++ b/crates/story/src/progress_story.rs @@ -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.)); })), ), )