I have a Slider with a range 0..1000 and steps=10....
# compose
r
I have a Slider with a range 0..1000 and steps=10. It produces 11 intervals (size ≈ 91) and 12 endpoints. Eh? I could see 9 and 10, or 10 and 11, depending on the meaning of "step", but 11/12? That's expected?
f
if you check the
Slider
implementation, you find this
Copy code
private fun stepsToTickFractions(steps: Int): FloatArray {
    return if (steps == 0) floatArrayOf() else FloatArray(steps + 2) { it.toFloat() / (steps + 1) }
so if you specify 10 steps, the float array has 12 entries, with these values
Copy code
0.0
0.09090909
0.18181819
0.27272728
0.36363637
0.45454547
0.54545456
0.6363636
0.72727275
0.8181818
0.90909094
1.0
👀 1
r
It's a bit odd to me, but it is what it is. I can just add a
-1
to my logic. Thanks.
👍 1
f
based on the formula above, it would seem that when you indicate you want N steps, it is understood that you want N stop points between the left and right edges of your slider
r
I tried to get the design changed during alpha, over 2.5 years ago, but it didn’t go anywhere: https://issuetracker.google.com/u/3/issues/179800038
f
that's too bad, the way it's implemented is definitively not as you'd expect