         }
     }
 
+    @objc func didTap(gr: UITapGestureRecognizer) {
+        reset()
+        presentedViewController?.dismiss(animated: true, completion: {})
+    }
+
     private var transitionShouldFinish: Bool {
         if progress > progressThreshold || yVelocity > velocityThreshold {
             return true

    fileprivate var isInteractive: Bool = false
    fileprivate let interactiveTransition = UIPercentDrivenInteractiveTransition()
    fileprivate var presentedViewController: UIViewController?
    fileprivate var gestureRecognizer: UIPanGestureRecognizer?
    private var yVelocity: CGFloat = 0.0
    private var progress: CGFloat = 0.0
    private let velocityThreshold: CGFloat = 50.0

        return isInteractive ? interactiveTransition : nil
    }
}

extension ModalTransitionDelegate: UIGestureRecognizerDelegate {
    func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        let location = gestureRecognizer.location(in: presentedViewController?.view)
        if location.y < 0 {
            return true
        } else {
            return false
        }
    }
}
