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