11diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java b/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
2- index 80c68034b193a47bedb56ca527352de9548e8ac6..1fac4b40c9f376a4f6d6b7fa60e4d247e8ef8550 100644
2+ index 80c68034b193a47bedb56ca527352de9548e8ac6..a35708d92227c72de73e81ca52be77c8a7e8ea7b 100644
33--- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
44+++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
5- @@ -9,6 +9,7 @@ import android.view.Menu;
6- import android.view.MenuItem;
7- import android.view.MotionEvent;
8- import android.view.View;
9- + import android.view.ViewConfiguration;
10- import android.webkit.JavascriptInterface;
11- import android.webkit.ValueCallback;
12- import android.webkit.WebChromeClient;
13- @@ -122,14 +123,55 @@ public class RNCWebView extends WebView implements LifecycleEventListener {
5+ @@ -122,14 +122,49 @@ public class RNCWebView extends WebView implements LifecycleEventListener {
146 cleanupCallbacksAndDestroy();
157 }
168
179+ private float touchDownX;
1810+ private float touchDownY;
1911+ private float lastTouchY;
2012+ private boolean multiTouch;
21- + private boolean horizontalGesture;
22- + private final int touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
2313+
2414 @Override
2515 public boolean onTouchEvent(MotionEvent event) {
@@ -30,9 +20,10 @@ index 80c68034b193a47bedb56ca527352de9548e8ac6..1fac4b40c9f376a4f6d6b7fa60e4d247
3020 return super.onTouchEvent(event);
3121 }
3222
33- + // Keep horizontal drags through vertical drift. Only nested scrolling retains
34- + // vertical drags until the document's scroll edge. A nested document with no
35- + // vertical range keeps its gestures: an iframe may scroll inside it.
23+ + // Horizontal intent is checked even when nested scrolling is disabled.
24+ + // Only nested scrolling retains vertical drags until the document's scroll
25+ + // edge. A nested document with no vertical range keeps its gestures: an
26+ + // iframe may scroll inside it.
3627+ // A gesture with a second finger stays with the page until every finger lifts.
3728+ private boolean shouldYieldToParent(MotionEvent event) {
3829+ switch (event.getActionMasked()) {
@@ -41,24 +32,19 @@ index 80c68034b193a47bedb56ca527352de9548e8ac6..1fac4b40c9f376a4f6d6b7fa60e4d247
4132+ touchDownY = event.getY();
4233+ lastTouchY = touchDownY;
4334+ multiTouch = false;
44- + horizontalGesture = false;
4535+ return false;
4636+ case MotionEvent.ACTION_POINTER_DOWN:
4737+ multiTouch = true;
4838+ return false;
4939+ case MotionEvent.ACTION_MOVE:
50- + if (multiTouch || horizontalGesture ) return false;
40+ + if (multiTouch) return false;
5141+ float dy = event.getY() - lastTouchY;
5242+ lastTouchY = event.getY();
53- + float distanceX = Math.abs(event.getX() - touchDownX);
54- + float distanceY = Math.abs(event.getY() - touchDownY);
55- + if (Math.max(distanceX, distanceY) <= touchSlop) return false;
56- + if (distanceX > distanceY) {
57- + horizontalGesture = true;
43+ + if (dy == 0) return false;
44+ + if (Math.abs(event.getY() - touchDownY) < Math.abs(event.getX() - touchDownX)) {
5845+ return false;
5946+ }
6047+ if (!this.nestedScrollEnabled) return true;
61- + if (dy == 0) return false;
6248+ if (!canScrollVertically(1) && !canScrollVertically(-1)) return false;
6349+ return !canScrollVertically(dy > 0 ? -1 : 1);
6450+ default:
0 commit comments