From 87b019065635e73546f45ff796302cdfc936680b Mon Sep 17 00:00:00 2001 From: Ali Emara Date: Mon, 22 Feb 2021 08:21:09 -0800 Subject: [PATCH 1/2] fix direction of dots movement --- Source/PageView/PageView.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/PageView/PageView.swift b/Source/PageView/PageView.swift index 55c2ac9..0eb9d36 100644 --- a/Source/PageView/PageView.swift +++ b/Source/PageView/PageView.swift @@ -166,7 +166,10 @@ extension PageView { } let containerWidth = CGFloat(itemsCount + 1) * selectedItemRadius + space * CGFloat(itemsCount - 1) - let toValue = containerWidth / 2.0 - selectedItemRadius - (selectedItemRadius + space) * CGFloat(index) + + let isRTL = UIView.userInterfaceLayoutDirection(for: self.semanticContentAttribute) == .rightToLeft + let sign: CGFloat = isRTL ? 1 : -1 + let toValue = containerWidth / 2.0 + sign * (selectedItemRadius + (selectedItemRadius + space) * CGFloat(index)) containerX.constant = toValue if animated == true { From 63a47ad53a666c9858a701100f3bce3b77f9c284 Mon Sep 17 00:00:00 2001 From: Ali Emara Date: Mon, 22 Feb 2021 08:21:45 -0800 Subject: [PATCH 2/2] flip direction of gesture in RTL only --- Source/GestureControl/GestureControl.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/GestureControl/GestureControl.swift b/Source/GestureControl/GestureControl.swift index 0c01a36..b1b519e 100644 --- a/Source/GestureControl/GestureControl.swift +++ b/Source/GestureControl/GestureControl.swift @@ -55,6 +55,16 @@ public class GestureControl: UIView { extension GestureControl { @objc dynamic func swipeHandler(_ gesture: UISwipeGestureRecognizer) { - delegate.gestureControlDidSwipe(gesture.direction) + var direction = gesture.direction + let isRTL = UIView.userInterfaceLayoutDirection(for: gesture.view!.semanticContentAttribute) == .rightToLeft + + // Flip direction only if in RTL interface + if (isRTL && direction == .right) { + direction = .left + } else if (isRTL && direction == .left) { + direction = .right + } + + delegate.gestureControlDidSwipe(direction) } }