         let containerView = transitionContext.containerView
 
         guard let fromViewController = transitionContext.viewController(forKey: .from) else { return }
-        guard let bgView = containerView.subviews.first(where: { $0.tag == Constants.BackgroundViewTag}) as? PresentationBackgroundView else { fatalError() }
-
+        guard let bgView = containerView.subviews.first(where: { $0.tag == Constants.BackgroundViewTag}) as? PresentationBackgroundView, let position = bgView.position else { fatalError() }
+        
         let distanceToMove = fromViewController.view.frame.height
-        let offScreenTransform = CGAffineTransform(translationX: 0, y: distanceToMove)
+        let distanceToMoveWithPosition = (position == .bottom) ? distanceToMove : -distanceToMove
+        let offScreenTransform = CGAffineTransform(translationX: 0, y: distanceToMoveWithPosition)
 
         /// And bring it off screen
         let animator = UIViewPropertyAnimator(duration: properties.animationDuration, dampingRatio: 1.0) {

        /// Override size classes if required
        toViewController.presentationController?.overrideTraitCollection = properties.overridenTraits
            
        /// Pin to the bottom
        NSLayoutConstraint.activate([
            toViewController.view.leadingAnchor.constraint(equalTo: containerView.leadingAnchor),
            toViewController.view.trailingAnchor.constraint(equalTo: containerView.trailingAnchor),
            toViewController.view.bottomAnchor.constraint(equalTo: containerView.bottomAnchor),
        ])
        
        /// If it's a fixed height, add that constraint


        /// Now move this view offscreen
        let distanceToMove = toViewController.view.frame.height
        let distanceToMoveWithPosition = (position == .bottom) ? distanceToMove : -distanceToMove
        let offScreenTransform = CGAffineTransform(translationX: 0, y: distanceToMoveWithPosition)
        toViewController.view.transform = offScreenTransform
        
        /// Prepare the alpha animation
