From c9d189293a158d567aaf8f9614c675e990e6d4c0 Mon Sep 17 00:00:00 2001 From: Brandon Shelley Date: Tue, 19 Feb 2019 14:15:41 -0800 Subject: [PATCH] Implement shouldTransition(for scrollView: UIScrollView?) delegate method --- Source/DeckPresentationController.swift | 4 ++++ Source/DeckTransitionViewControllerProtocol.swift | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/Source/DeckPresentationController.swift b/Source/DeckPresentationController.swift index 4d72e2f..f0bc940 100644 --- a/Source/DeckPresentationController.swift +++ b/Source/DeckPresentationController.swift @@ -561,6 +561,10 @@ final class DeckPresentationController: UIPresentationController, UIGestureRecog return } + if let deckViewController = presentedViewController as? DeckTransitionViewControllerProtocol { + guard deckViewController.shouldTransition!(for: ScrollViewDetector(withViewController: presentedViewController).scrollView) else { return } + } + switch gestureRecognizer.state { case .began: diff --git a/Source/DeckTransitionViewControllerProtocol.swift b/Source/DeckTransitionViewControllerProtocol.swift index edd0f9e..dbedb37 100644 --- a/Source/DeckTransitionViewControllerProtocol.swift +++ b/Source/DeckTransitionViewControllerProtocol.swift @@ -57,5 +57,11 @@ import UIKit /// `childViewControllerForDeck` variable is also implemented. @objc optional var scrollViewForDeck: UIScrollView { get } + /// Calls a delegate method to determine whether or not a Deck transition + /// should take place. + + /// - Note: Default for this method always returns `true` + @objc optional func shouldTransition(for scrollView: UIScrollView?) -> Bool + }