File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
slider/src/main/java/io/monstarlab/mosaic/slider Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ public class SliderState(
66
66
internal val offsetAsFraction: Float
67
67
get() = if (totalWidth == 0f ) 0f else {
68
68
val valueFraction = value.valueToFraction(range)
69
- valueDistribution.inverse(valueFraction)
69
+ valueDistribution.inverse(valueFraction).coerceIn( 0f , 1f )
70
70
}
71
71
72
72
@@ -136,8 +136,10 @@ public class SliderState(
136
136
}
137
137
138
138
private fun Float.coerceIntoDisabledRange (): Float {
139
- if (disabledRange.isEmpty()) return this
139
+ if (disabledRange.isEmpty() || ! disabledRange.contains(this )) return this
140
+ if (this - disabledRange.start < disabledRange.endInclusive - this ) disabledRange.start else disabledRange.endInclusive
140
141
// check if disabled range is on the left or right
142
+
141
143
return if (disabledRange.start == range.start) {
142
144
coerceAtLeast(disabledRange.endInclusive)
143
145
} else {
You can’t perform that action at this time.
0 commit comments