Use value in Slider to store the previous value
This commit is contained in:
parent
9a254a211b
commit
94d62bca9a
1 changed files with 3 additions and 8 deletions
|
|
@ -147,7 +147,6 @@ where
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
is_dragging: bool,
|
is_dragging: bool,
|
||||||
previous: Option<f64>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
|
|
@ -220,14 +219,10 @@ where
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(previous) = self.state.previous {
|
if (self.value.into() - new_value.into()).abs() > f64::EPSILON {
|
||||||
if (new_value.into() - previous).abs() > f64::EPSILON {
|
|
||||||
messages.push((self.on_change)(new_value));
|
|
||||||
self.state.previous = Some(new_value.into());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
messages.push((self.on_change)(new_value));
|
messages.push((self.on_change)(new_value));
|
||||||
self.state.previous = Some(new_value.into());
|
|
||||||
|
self.value = new_value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue