Skip to content

Commit 03b6b7f

Browse files
committed
better solution
1 parent fef0280 commit 03b6b7f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.view.MotionEvent
66
import android.view.View
77
import android.view.ViewGroup
88
import android.widget.EditText
9+
import com.facebook.react.uimanager.RootView
910
import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
1011
import com.swmansion.gesturehandler.react.RNGestureHandlerRootView
1112
import java.util.*
@@ -14,6 +15,7 @@ class GestureHandlerOrchestrator(
1415
private val wrapperView: ViewGroup,
1516
private val handlerRegistry: GestureHandlerRegistry,
1617
private val viewConfigHelper: ViewConfigurationHelper,
18+
private val rootView: ViewGroup,
1719
) {
1820
/**
1921
* Minimum alpha (value from 0 to 1) that should be set to a view so that it can be treated as a
@@ -56,6 +58,11 @@ class GestureHandlerOrchestrator(
5658
if (finishedHandlersCleanupScheduled && handlingChangeSemaphore == 0) {
5759
cleanupFinishedHandlers()
5860
}
61+
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
62+
if (awaitingHandlers.isEmpty() && rootView is RootView) {
63+
rootView.onChildEndedNativeGesture(rootView, event)
64+
}
65+
}
5966
return true
6067
}
6168

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
3636
wrappedView,
3737
registry,
3838
RNViewConfigurationHelper(),
39+
rootView,
3940
).apply {
4041
minimumAlphaForTraversal = MIN_ALPHA_FOR_TOUCH
4142
}
@@ -94,7 +95,7 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
9495
action = MotionEvent.ACTION_CANCEL
9596
}
9697
if (rootView is RootView) {
97-
rootView.onChildEndedNativeGesture(rootView, event)
98+
rootView.onChildStartedNativeGesture(rootView, event)
9899
}
99100
event.recycle()
100101
}

0 commit comments

Comments
 (0)