slider: Improved bar and thumb position. (#185)

This commit is contained in:
Jason Lee 2024-08-29 10:36:47 +08:00 committed by GitHub
parent 9768755eab
commit f7f3fcedf3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -107,6 +107,7 @@ impl Slider {
max - (max - min) * relative
}
};
let value = (value / step).round() * step;
self.value = value.clamp(self.min, self.max);
@ -137,7 +138,7 @@ impl Slider {
},
))
.absolute()
.top(px(-4.))
.top(px(-5.))
.left(relative(self.relative_value()))
.ml(-px(8.))
.size_4()
@ -161,12 +162,13 @@ impl Render for Slider {
div()
.id("slider")
.on_mouse_down(MouseButton::Left, cx.listener(Self::on_mouse_down))
.py_1()
.h_5()
.child(
div()
.id("slider-bar")
.relative()
.w_full()
.my_1p5()
.h_1p5()
.bg(cx.theme().slider_bar.opacity(0.2))
.active(|this| this.bg(cx.theme().slider_bar.opacity(0.4)))