                 } else if transitionShouldStarted && !transitionStarted {
                     if transitionStarted {
                         DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
+                            guard let transitionContext = self.transitionContext else {
+                                fatalError("Invalid 'transitionContext' value. This property should not be nil")
+                            }
                             if self.transitionStarted {
                                 self.cancelTransition(currentPercentComplete: progress)
-                                self.transitionContext.cancelInteractiveTransition()
+                                transitionContext.cancelInteractiveTransition()
                             }
                         }
                     }

        let animation : () -> Void = { [weak self] in self?.updateTransition(percentComplete: 1.0) }
        let completion : (Bool) -> Void = { [weak self] _ in
            if let transition = self {
                let fromViewController = transition.transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!
                let toViewController = transition.transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!
                
                if transition.present {
                    fromViewController.view.isHidden = false
                    
                    transition.contentSnapshotView.removeFromSuperview()
                    transition.contentSnapshotView.addGestureRecognizer(transition.panRecognizer)
                    transition.contentSnapshotView.addGestureRecognizer(transition.tapRecognizer)
                    
                    toViewController.view.addSubview(transition.contentSnapshotView)
                } else {
                    toViewController.view.isHidden = false
                    transition.removeShadow(fromView: toViewController.view)

    //MARK: - Private methods
    //
    private func createSnapshotView(from: UIView) -> UIView {
        let snapshotViewOptional = from.snapshotView(afterScreenUpdates: true)
        guard let snapshotView = snapshotViewOptional else {
            fatalError("Invalid snapshot view")
        }
        snapshotView.frame = from.frame
        addShadow(toView: snapshotView)

