diff --git a/PanModal/Controller/PanModalPresentationController.swift b/PanModal/Controller/PanModalPresentationController.swift index 11fb2a6e..e44e1645 100644 --- a/PanModal/Controller/PanModalPresentationController.swift +++ b/PanModal/Controller/PanModalPresentationController.swift @@ -816,6 +816,14 @@ private extension PanModalPresentationController { extension PanModalPresentationController: UIGestureRecognizerDelegate { + /** + Asks the delegate if the pan modal should begin to track the pan gesture + */ + public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { + guard gestureRecognizer == panGestureRecognizer else { return true } + return presentable?.shouldBeginPanGesture(panGestureRecognizer) ?? true + } + /** Do not require any other gesture recognizers to fail */ diff --git a/PanModal/Presentable/PanModalPresentable+Defaults.swift b/PanModal/Presentable/PanModalPresentable+Defaults.swift index 76a0679f..66fd0df4 100644 --- a/PanModal/Presentable/PanModalPresentable+Defaults.swift +++ b/PanModal/Presentable/PanModalPresentable+Defaults.swift @@ -96,6 +96,10 @@ public extension PanModalPresentable where Self: UIViewController { var showDragIndicator: Bool { return shouldRoundTopCorners } + + func shouldBeginPanGesture(_ panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool { + return true + } func shouldRespond(to panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool { return true diff --git a/PanModal/Presentable/PanModalPresentable.swift b/PanModal/Presentable/PanModalPresentable.swift index 76c15015..515bd97f 100644 --- a/PanModal/Presentable/PanModalPresentable.swift +++ b/PanModal/Presentable/PanModalPresentable.swift @@ -173,6 +173,15 @@ public protocol PanModalPresentable: AnyObject { */ var showDragIndicator: Bool { get } + /** + Asks the delegate if the pan modal should begin to track the pan gesture. + + Return false to not track the pan gesture and possibly let other observers track the gesture + + Default value is true. + */ + func shouldBeginPanGesture(_ panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool + /** Asks the delegate if the pan modal should respond to the pan modal gesture recognizer.