Skip to content

Commit 98d5016

Browse files
author
张昱
committed
Refactor touch handling in shouldScrollViewHandleTouch
Replaced conversion of initial touch location to scrollView coordinates with conversion of scrollView frame to surfaceView coordinates. This simplifies the containment check for touch handling.
1 parent b8929ec commit 98d5016

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/Core.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,11 +626,11 @@ class Core: NSObject, UIGestureRecognizerDelegate {
626626
private func shouldScrollViewHandleTouch(_ scrollView: UIScrollView?, point: CGPoint, velocity: CGFloat) -> Bool {
627627
// When no scrollView, nothing to handle.
628628
guard let scrollView = scrollView else { return false }
629-
let convertedInitialLocation = panGestureRecognizer.view?.convert(
630-
initialLocation,
631-
to: scrollView
629+
let scrollViewFrame = surfaceView.convert(
630+
scrollView.frame,
631+
from: scrollView.superview
632632
)
633-
guard let convertedInitialLocation = convertedInitialLocation, scrollView.frame.contains(convertedInitialLocation) else { return false }
633+
guard scrollViewFrame.contains(initialLocation) else { return false }
634634

635635
// Prevents moving a panel on swipe actions using _UISwipeActionPanGestureRecognizer.
636636
// [Warning] Do not apply this to WKWebView. Since iOS 17.4, WKWebView has an additional pan

0 commit comments

Comments
 (0)