Skip to content

Commit a0bb8b5

Browse files
authored
fix: iOS inverted tap-to-seek in RTL (#677)
1 parent 2f07d2d commit a0bb8b5

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

package/ios/RNCSliderComponentView.mm

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

7878
CGPoint touchPoint = [gesture locationInView:slider];
7979
float rangeWidth = slider.maximumValue - slider.minimumValue;
80-
float sliderPercent = touchPoint.x / slider.bounds.size.width;
80+
81+
float sliderPercent;
82+
if ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:slider.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft) {
83+
sliderPercent = 1.0 - (touchPoint.x / slider.bounds.size.width);
84+
} else {
85+
sliderPercent = touchPoint.x / slider.bounds.size.width;
86+
}
87+
8188
slider.lastValue = slider.value;
8289
float value = slider.minimumValue + (rangeWidth * sliderPercent);
8390

package/ios/RNCSliderManager.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ - (void)tapHandler:(UITapGestureRecognizer *)gesture {
5757

5858
CGPoint touchPoint = [gesture locationInView:slider];
5959
float rangeWidth = slider.maximumValue - slider.minimumValue;
60-
float sliderPercent = touchPoint.x / slider.bounds.size.width;
60+
61+
float sliderPercent;
62+
if ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:slider.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft) {
63+
sliderPercent = 1.0 - (touchPoint.x / slider.bounds.size.width);
64+
} else {
65+
sliderPercent = touchPoint.x / slider.bounds.size.width;
66+
}
67+
6168
slider.lastValue = slider.value;
6269
float value = slider.minimumValue + (rangeWidth * sliderPercent);
6370

0 commit comments

Comments
 (0)