slider: Improved bar and thumb position. (#185)
This commit is contained in:
parent
9768755eab
commit
f7f3fcedf3
1 changed files with 4 additions and 2 deletions
|
|
@ -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)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue