@@ -656,14 +656,19 @@ class Core: NSObject, UIGestureRecognizerDelegate {
656
656
}
657
657
658
658
private func panningChange( with translation: CGPoint ) {
659
- os_log ( msg, log: devLog, type: . debug, " panningChange -- translation = \( value ( of: translation) ) " )
660
659
let pre = value ( of: layoutAdapter. surfaceLocation)
661
660
let diff = value ( of: translation - initialTranslation)
662
661
let next = pre + diff
663
662
664
- layoutAdapter. updateInteractiveEdgeConstraint ( diff: diff,
665
- scrollingContent: shouldScrollingContentInMoving ( from: pre, to: next) ,
666
- allowsRubberBanding: behaviorAdapter. allowsRubberBanding ( for: ) )
663
+ os_log ( msg, log: devLog, type: . debug, """
664
+ panningChange -- translation = \( value ( of: translation) ) , diff = \( diff) , pre = \( pre) , next = \( next)
665
+ """ )
666
+
667
+ layoutAdapter. updateInteractiveEdgeConstraint (
668
+ diff: diff,
669
+ scrollingContent: shouldScrollingContentInMoving ( from: pre, to: next) ,
670
+ allowsRubberBanding: behaviorAdapter. allowsRubberBanding ( for: )
671
+ )
667
672
668
673
let cur = value ( of: layoutAdapter. surfaceLocation)
669
674
@@ -676,31 +681,36 @@ class Core: NSObject, UIGestureRecognizerDelegate {
676
681
}
677
682
}
678
683
679
- private func shouldScrollingContentInMoving( from pre: CGFloat , to next: CGFloat ) -> Bool {
684
+ /// Determines if the content should scroll while the surface is moving from `cur` to `target`.
685
+ ///
686
+ /// - Note: `cur` argument starts from an anchor location of surface view in a state. For example,
687
+ /// it starts from zero if the state is full whose FloatingPanelLayoutAnchor.absoluteInset is zero
688
+ /// and there is no additional safe area insets like a navigation bar. Therefore, `cur` argument
689
+ /// can be minus if the absoluteInset is minus with such a condition.
690
+ private func shouldScrollingContentInMoving( from cur: CGFloat , to target: CGFloat ) -> Bool {
680
691
// Don't allow scrolling if the initial panning location is in the grabber area.
681
692
if surfaceView. grabberAreaContains ( initialLocation) {
682
693
return false
683
694
}
684
- if let scrollView = scrollView, scrollView. panGestureRecognizer. state == . changed {
695
+ if let sv = scrollView, sv. panGestureRecognizer. state == . changed {
696
+ let ( contentSize, bounds, alwaysBounceHorizontal, alwaysBounceVertical)
697
+ = ( sv. contentSize, sv. bounds, sv. alwaysBounceHorizontal, sv. alwaysBounceVertical)
698
+
685
699
switch layoutAdapter. position {
686
700
case . top:
687
- if pre > . zero, pre < next,
688
- scrollView. contentSize. height > scrollView. bounds. height || scrollView. alwaysBounceVertical {
701
+ if cur < target, contentSize. height > bounds. height || alwaysBounceVertical {
689
702
return true
690
703
}
691
704
case . left:
692
- if pre > . zero, pre < next,
693
- scrollView. contentSize. width > scrollView. bounds. width || scrollView. alwaysBounceHorizontal {
705
+ if cur < target, contentSize. width > bounds. width || alwaysBounceHorizontal {
694
706
return true
695
707
}
696
708
case . bottom:
697
- if pre > . zero, pre > next,
698
- scrollView. contentSize. height > scrollView. bounds. height || scrollView. alwaysBounceVertical {
709
+ if cur > target, contentSize. height > bounds. height || alwaysBounceVertical {
699
710
return true
700
711
}
701
712
case . right:
702
- if pre > . zero, pre > next,
703
- scrollView. contentSize. width > scrollView. bounds. width || scrollView. alwaysBounceHorizontal {
713
+ if cur > target, contentSize. width > bounds. width || alwaysBounceHorizontal {
704
714
return true
705
715
}
706
716
}
0 commit comments