From 5dfdb2e534fa814919939b35a5481a7bc7b677ca Mon Sep 17 00:00:00 2001 From: gpp-0 Date: Fri, 17 Jan 2025 04:24:15 +0200 Subject: [PATCH] fix: add notifyNativeGestureEnded brings this more in line with existing react patterns copied from bluesky-social/social-app@88b1878 --- .../com/reactnativepagerview/NestedScrollableHost.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/android/src/main/java/com/reactnativepagerview/NestedScrollableHost.kt b/android/src/main/java/com/reactnativepagerview/NestedScrollableHost.kt index 294a3a82..87b58d0f 100644 --- a/android/src/main/java/com/reactnativepagerview/NestedScrollableHost.kt +++ b/android/src/main/java/com/reactnativepagerview/NestedScrollableHost.kt @@ -28,6 +28,7 @@ class NestedScrollableHost : FrameLayout { private var touchSlop = 0 private var initialX = 0f private var initialY = 0f + private var nativeGestureStarted: Boolean = false private val parentViewPager: ViewPager2? get() { var v: View? = parent as? View @@ -77,6 +78,7 @@ class NestedScrollableHost : FrameLayout { if (scaledDx > touchSlop || scaledDy > touchSlop) { NativeGestureUtil.notifyNativeGestureStarted(this, e) + nativeGestureStarted = true if (orientation == null) return if (isVpHorizontal == (scaledDy > scaledDx)) { @@ -95,4 +97,14 @@ class NestedScrollableHost : FrameLayout { } } } + + override fun onTouchEvent(e: MotionEvent): Boolean { + if (e.actionMasked == MotionEvent.ACTION_UP) { + if (nativeGestureStarted) { + NativeGestureUtil.notifyNativeGestureEnded(this, e) + nativeGestureStarted = false + } + } + return super.onTouchEvent(e) + } }