@@ -395,7 +395,7 @@ class Core: NSObject, UIGestureRecognizerDelegate {
395
395
location = \( value ( of: location) ) , velocity = \( velocity)
396
396
""" )
397
397
398
- let offsetDiff = value ( of : scrollView. contentOffset - contentOffsetForPinning ( of : scrollView) )
398
+ let offsetDiff = offsetFromPinning ( scrollView: scrollView)
399
399
400
400
if insideMostExpandedAnchor {
401
401
// Scroll offset pinning
@@ -596,7 +596,7 @@ class Core: NSObject, UIGestureRecognizerDelegate {
596
596
return false
597
597
}
598
598
599
- let offset = value ( of : scrollView. contentOffset - contentOffsetForPinning ( of : scrollView) )
599
+ let offset = offsetFromPinning ( scrollView: scrollView)
600
600
// The zero offset must be excluded because the offset is usually zero
601
601
// after a panel moves from half/tip to full.
602
602
switch layoutAdapter. position {
@@ -791,13 +791,13 @@ class Core: NSObject, UIGestureRecognizerDelegate {
791
791
log. debug ( " startInteraction -- translation = \( value ( of: translation) ) , location = \( value ( of: location) ) " )
792
792
guard interactionInProgress == false else { return }
793
793
794
- var offset : CGPoint = . zero
794
+ var offset = 0.0
795
795
796
796
initialSurfaceLocation = layoutAdapter. surfaceLocation
797
797
if state == layoutAdapter. mostExpandedState, let scrollView = scrollView {
798
798
if surfaceView. grabberAreaContains ( location) {
799
799
initialScrollOffset = scrollView. contentOffset
800
- } else if value ( of : scrollView. contentOffset ) >= 0 {
800
+ } else if distanceFromPinning ( scrollView : scrollView) >= 0 {
801
801
// The condition must be out of the range defined by `allowScrollPanGesture(for:)`, [-30, 0).
802
802
// It can be true when a panel moves by dragging it with an overlay view,
803
803
// for example, a user drags a panel at the bottom of the search bar in Maps example.
@@ -812,14 +812,14 @@ class Core: NSObject, UIGestureRecognizerDelegate {
812
812
initialScrollOffset = pinningOffset
813
813
814
814
// Fit the surface bounds to a scroll offset content by startInteraction(at:offset:)
815
- let offsetDiff = scrollView. contentOffset - pinningOffset
815
+ let offsetDiff = offsetFromPinning ( scrollView: scrollView )
816
816
switch layoutAdapter. position {
817
817
case . top, . left:
818
- if value ( of : offsetDiff) > 0 {
818
+ if offsetDiff > 0 {
819
819
offset = - offsetDiff
820
820
}
821
821
case . bottom, . right:
822
- if value ( of : offsetDiff) < 0 {
822
+ if offsetDiff < 0 {
823
823
offset = - offsetDiff
824
824
}
825
825
}
@@ -1075,16 +1075,25 @@ class Core: NSObject, UIGestureRecognizerDelegate {
1075
1075
}
1076
1076
}
1077
1077
1078
- private func allowScrollPanGesture( for scrollView: UIScrollView ) -> Bool {
1079
- guard state == layoutAdapter. mostExpandedState else { return false }
1080
- var offsetY : CGFloat = 0
1078
+ private func offsetFromPinning( scrollView: UIScrollView ) -> CGFloat {
1079
+ return value ( of: scrollView. contentOffset - contentOffsetForPinning( of: scrollView) )
1080
+ }
1081
+
1082
+ private func distanceFromPinning( scrollView: UIScrollView ) -> CGFloat {
1083
+ var offset = offsetFromPinning ( scrollView: scrollView)
1081
1084
switch layoutAdapter. position {
1082
1085
case . top, . left:
1083
- offsetY = value ( of : scrollView . fp_contentOffsetMax - scrollView . contentOffset )
1086
+ offset = - offset
1084
1087
case . bottom, . right:
1085
- offsetY = value ( of : scrollView . contentOffset - contentOffsetForPinning ( of : scrollView ) )
1088
+ break ;
1086
1089
}
1087
- return offsetY <= - 30.0 || offsetY > 0
1090
+ return offset
1091
+ }
1092
+
1093
+ private func allowScrollPanGesture( for scrollView: UIScrollView ) -> Bool {
1094
+ guard state == layoutAdapter. mostExpandedState else { return false }
1095
+ var offset = distanceFromPinning ( scrollView: scrollView)
1096
+ return offset <= - 30.0 || offset > 0
1088
1097
}
1089
1098
1090
1099
// MARK: - UIPanGestureRecognizer Intermediation
0 commit comments