         }
     }
     
+    private func calculateTopConstraintUponDrag(translationY: CGFloat) {
+        
+        guard let containerViewYUponDragBegin = containerViewYUponDragBegin else {
+            return
+        }
+        
+        let maxY = containerViewYUponDragBegin + 10
+        let minY = containerViewYUponDragBegin - 10
+
+        containerViewTopConstraint?.constant = max(min(containerViewYUponDragBegin + translationY, maxY), minY)
+    }
+    
     private func toggleConstraints(shouldPinToTop: Bool) {
         if shouldPinToTop {
             containerViewHeightConstraint?.isActive = false

            let containerViewSafeAreaFrame = viewController.view.convert(containerView.frame, to: safeAreaBackgroundView)
            let containerViewYUponDragBegin = containerViewSafeAreaFrame.origin.y
            self.containerViewYUponDragBegin = containerViewYUponDragBegin
            self.containerViewWasPinnedToTopUponDragBegin = containerViewYUponDragBegin == containerPinnedTopSpacing

            containerViewTopConstraint?.constant = max(containerViewYUponDragBegin + translationY, containerPinnedTopSpacing)
            toggleConstraints(shouldPinToTop: true)
        case .changed:
            
            guard let containerViewYUponDragBegin = containerViewYUponDragBegin else {
                gestureRecognizer.state = .ended
                return
            }
            
            containerViewTopConstraint?.constant = max(containerViewYUponDragBegin + translationY, containerPinnedTopSpacing)
            toggleConstraints(shouldPinToTop: true)
        case .ended:


        // always active constraints
        let trailingConstraint = viewController.view.trailingAnchor.constraint(equalTo: containerView.trailingAnchor)
        let bottomConstraint = viewController.view.bottomAnchor.constraint(equalTo: containerView.bottomAnchor)
        let leadingConstraint = viewController.view.leadingAnchor.constraint(equalTo: containerView.leadingAnchor)
        NSLayoutConstraint.activate([trailingConstraint, bottomConstraint, leadingConstraint])
        
