Skip to content

Commit bf2c0b8

Browse files
Fix: can't drag to the end of track on iOS (#334)
* Check if targeted value exceeds the range * Cover the check with comment explaining its purpose
1 parent 8cc6558 commit bf2c0b8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ios/RNCSliderManager.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,14 @@ - (void)tapHandler:(UITapGestureRecognizer *)gesture {
7777
}
7878

7979
static float discreteValue(RNCSlider *sender, float value) {
80+
// Check if thumb should reach the maximum value and put it on the end of track if yes.
81+
// To avoid affecting the thumb when on maximum, the `step >= (value - maximum)` is not checked.
82+
if (sender.step > 0 && value >= sender.maximumValue) {
83+
return sender.maximumValue;
84+
}
85+
8086
// If step is set and less than or equal to difference between max and min values,
8187
// pick the closest discrete multiple of step to return.
82-
8388
if (sender.step > 0 && sender.step <= (sender.maximumValue - sender.minimumValue)) {
8489

8590
// Round up when increase, round down when decrease.

0 commit comments

Comments
 (0)