         }
     }
     
-    var currentContainerState: SlidingContainerPresentedState {
-        return modalContainer.frame.height > 0 ? .expanded : .collapsed
-    }
-    
-    var targetContainerState: SlidingContainerPresentedState {
-        return modalContainer.frame.height > 0 ? .collapsed : .expanded
-    }
-    
     func percent(for recognizer: UIPanGestureRecognizer) -> CGFloat {
-        guard let containerView = modalContainer else { return 0 }
-        let locationInSourceView = recognizer.location(in: containerView)
-        let delta = recognizer.translation(in: containerView)
+        let locationInSourceView = recognizer.location(in: view)
+        let delta = recognizer.translation(in: view)
         let originalLocation = CGPoint(x: locationInSourceView.x - delta.x, y: locationInSourceView.y - delta.y)
-        let height = containerView.bounds.height
+        let width = view.bounds.width
+        let height = view.bounds.height
         
-        let possibleHeight = height - originalLocation.y
-        return delta.y / possibleHeight
+        if anchorEdge == .top {
+            let possibleHeight = originalLocation.y
+            return abs(delta.y) / possibleHeight
+        } else if anchorEdge == .bottom {
+            let possibleHeight = height - originalLocation.y
+            return delta.y / possibleHeight
+        } else if anchorEdge == .left {
+            let possibleWidth = originalLocation.x
+            return abs(delta.x) / possibleWidth
+        } else if anchorEdge == .right {
+            let possibleWidth = width - originalLocation.x
+            return delta.x / possibleWidth
+        } else {
+            fatalError("edge must be .top, .bottom, .left, or .right. actual=\(anchorEdge)")
+        }
     }
     
     public func handlePan(with recognizer: UIPanGestureRecognizer) {

        case .ended:
            let timing = UICubicTimingParameters(animationCurve: .easeOut)
            let velocity = recognizer.velocity(in: view)
            let swiped = velocity.y > velocityThreshold
            let shouldReverse = !swiped && percent(for: recognizer) < 0.5
            runningAnimators.forEach { animator in
                animator.isReversed = shouldReverse

                }
                blurEffectView.isUserInteractionEnabled = isShowing
                blurEffectView.effect = isShowing ? self.blurEffect ?? UIBlurEffect(style: .dark) : nil
                self.modalContainer.layer.cornerRadius = isShowing ? self.cornerRadius : 0
            }
            blurAnimator.startAnimation()
            runningAnimators.append(blurAnimator)
