react-native-nitro-modal 0.3.7-rc → 0.3.8-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -74,7 +74,6 @@ internal class BottomSheetPresenter(
|
|
|
74
74
|
private var lastDetentIndex = -1
|
|
75
75
|
private var reportedRestingTop = Int.MIN_VALUE
|
|
76
76
|
|
|
77
|
-
/** The detent a settle we started is heading for, until it arrives; -1 otherwise. */
|
|
78
77
|
private var settlingTo = -1
|
|
79
78
|
|
|
80
79
|
/** The behavior is dragging the sheet (as opposed to a nested scroll moving it). */
|
|
@@ -468,18 +467,31 @@ internal class BottomSheetPresenter(
|
|
|
468
467
|
}
|
|
469
468
|
|
|
470
469
|
/**
|
|
471
|
-
* Gives up dragging the sheet down on nested scrollable content
|
|
472
|
-
*
|
|
473
|
-
* a new gesture collapses the sheet.
|
|
470
|
+
* Gives up dragging the sheet down on nested scrollable content that can
|
|
471
|
+
* still scroll up, or that scrolled during the gesture: it scrolls back to
|
|
472
|
+
* its top, and only a new gesture collapses the sheet.
|
|
473
|
+
*
|
|
474
|
+
* The behavior asks the nested scroll's target whether it can scroll up,
|
|
475
|
+
* but the target may only wrap the scroll view: a ScrollView with a
|
|
476
|
+
* RefreshControl reports its SwipeRefreshLayout, which never scrolls
|
|
477
|
+
* itself. The views under the finger are asked instead.
|
|
474
478
|
*/
|
|
475
479
|
private inner class SheetBehavior : BottomSheetBehavior<FrameLayout>() {
|
|
476
480
|
private var contentScrolled = false
|
|
477
481
|
|
|
482
|
+
/** Where the gesture started, in the sheet's coordinates. */
|
|
483
|
+
private var downX = 0f
|
|
484
|
+
private var downY = 0f
|
|
485
|
+
|
|
478
486
|
override fun onInterceptTouchEvent(parent: CoordinatorLayout, child: FrameLayout, event: MotionEvent): Boolean {
|
|
479
|
-
if (event.actionMasked == MotionEvent.ACTION_DOWN
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
487
|
+
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
|
|
488
|
+
downX = event.x - child.left - child.translationX
|
|
489
|
+
downY = event.y - child.top - child.translationY
|
|
490
|
+
if (state in states()) {
|
|
491
|
+
// React may have mounted the scrollable content after the last layout
|
|
492
|
+
// pass; laying out again re-finds it. The resting sheet doesn't move.
|
|
493
|
+
onLayoutChild(parent, child, parent.layoutDirection)
|
|
494
|
+
}
|
|
483
495
|
}
|
|
484
496
|
return super.onInterceptTouchEvent(parent, child, event)
|
|
485
497
|
}
|
|
@@ -505,7 +517,7 @@ internal class BottomSheetPresenter(
|
|
|
505
517
|
consumed: IntArray,
|
|
506
518
|
type: Int,
|
|
507
519
|
) {
|
|
508
|
-
if (dy < 0 && contentScrolled) return
|
|
520
|
+
if (dy < 0 && (contentScrolled || canScrollUpAt(child, downX, downY))) return
|
|
509
521
|
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type)
|
|
510
522
|
}
|
|
511
523
|
|