Skip to content

Commit 75701fe

Browse files
committed
Fix off by one
1 parent b8f5734 commit 75701fe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ui-libraries/material/src/ui/components/slider.slint

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export component Slider {
4444
background: thumb.background;
4545
}
4646

47-
if root.stop_count > 0: Rectangle {
47+
if root.stop_count > 1: Rectangle {
4848
width: 100%;
4949
height: 100%;
5050

@@ -83,7 +83,7 @@ export component Slider {
8383
}
8484

8585
moved => {
86-
root.set_value(root.length_to_value(state_layer.x + ( self.mouse_x - self.pressed_x), track.width));
86+
root.set_value(root.length_to_value(state_layer.x + (self.mouse_x - self.pressed_x), track.width));
8787
}
8888

8989
pointer_event(event) => {
@@ -131,10 +131,10 @@ export component Slider {
131131
}
132132

133133
function set_value(value: float) {
134-
if root.steps > 0 {
134+
if root.steps > 1 {
135135
root.value = clamp(round(value / root.steps) * root.steps, root.minimum, root.maximum)
136136
} else {
137-
root.value = clamp(value * root.steps, root.minimum, root.maximum)
137+
root.value = clamp(value, root.minimum, root.maximum)
138138
}
139139
}
140140
}

0 commit comments

Comments
 (0)