diff options
author | 2021-11-15 15:30:53 +0700 | |
---|---|---|
committer | 2021-11-15 15:30:53 +0700 | |
commit | 94d62bca9ac651888a42b7f878e4afb97688ad47 (patch) | |
tree | 6532ae2373ab9d648f3d2d134c493cdc5a9dfbf2 /native | |
parent | 9a254a211b60ede11a92e62197e922493a108fcc (diff) | |
download | iced-94d62bca9ac651888a42b7f878e4afb97688ad47.tar.gz iced-94d62bca9ac651888a42b7f878e4afb97688ad47.tar.bz2 iced-94d62bca9ac651888a42b7f878e4afb97688ad47.zip |
Use `value` in `Slider` to store the `previous` value
Diffstat (limited to 'native')
-rw-r--r-- | native/src/widget/slider.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs index ef9dea01..7a3e8071 100644 --- a/native/src/widget/slider.rs +++ b/native/src/widget/slider.rs @@ -147,7 +147,6 @@ where #[derive(Debug, Clone, Copy, PartialEq, Default)] pub struct State { is_dragging: bool, - previous: Option<f64>, } impl State { @@ -220,14 +219,10 @@ where } }; - if let Some(previous) = self.state.previous { - if (new_value.into() - previous).abs() > f64::EPSILON { - messages.push((self.on_change)(new_value)); - self.state.previous = Some(new_value.into()); - } - } else { + if (self.value.into() - new_value.into()).abs() > f64::EPSILON { messages.push((self.on_change)(new_value)); - self.state.previous = Some(new_value.into()); + + self.value = new_value; } }; |