Skip to content

Commit

Permalink
fix: add notifyNativeGestureEnded
Browse files Browse the repository at this point in the history
brings this more in line with existing react patterns

copied from bluesky-social/social-app@88b1878
  • Loading branch information
gpp-0 committed Jan 17, 2025
1 parent 5d3af22 commit 5dfdb2e
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand All @@ -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)
}
}

0 comments on commit 5dfdb2e

Please sign in to comment.