Skip to content

Commit 3fd5a2f

Browse files
authored
iOS: Fix problem where slider returned to original position. (callstack#235)
If the slide was quick, the new tap gesture recognizer would be invoked and cause the slider to return to its original position (ignoring the slide).
1 parent 93c9605 commit 3fd5a2f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/ios/RNCSliderManager.m

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
#import <React/RCTEventDispatcher.h>
1212
#import "RNCSlider.h"
1313
#import <React/UIView+React.h>
14-
#import "os/log.h"
1514

1615
@implementation RNCSliderManager
16+
{
17+
BOOL _isSliding;
18+
}
1719

1820
RCT_EXPORT_MODULE()
1921

@@ -38,6 +40,11 @@ - (UIView *)view
3840
}
3941

4042
- (void)tapHandler:(UITapGestureRecognizer *)gesture {
43+
// Ignore this tap if in the middle of a slide.
44+
if (_isSliding) {
45+
return;
46+
}
47+
4148
// Bail out if the source view of the gesture isn't an RNCSlider.
4249
if ([gesture.view class] != [RNCSlider class]) {
4350
return;
@@ -121,11 +128,13 @@ - (void)sliderValueChanged:(RNCSlider *)sender
121128
- (void)sliderTouchStart:(RNCSlider *)sender
122129
{
123130
RNCSendSliderEvent(sender, NO, YES);
131+
_isSliding = YES;
124132
}
125133

126134
- (void)sliderTouchEnd:(RNCSlider *)sender
127135
{
128136
RNCSendSliderEvent(sender, NO, NO);
137+
_isSliding = NO;
129138
}
130139

131140
RCT_EXPORT_VIEW_PROPERTY(value, float);

0 commit comments

Comments
 (0)