@swmansion/react-native-bottom-sheet 0.15.0-next.6 → 0.15.0-next.7
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.
- package/ios/BottomSheetHostingView.swift +30 -10
- package/package.json +1 -1
|
@@ -189,10 +189,18 @@ public final class BottomSheetHostingView: UIView {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
private var presentedSheetFrame: CGRect {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
guard activeSpring != nil else { return sheetContainer.frame }
|
|
193
|
+
// Mid-settle, derive the on-screen frame from the spring instead of the
|
|
194
|
+
// presentation layer (which lags one commit behind right after a snap
|
|
195
|
+
// starts). The container's transform is translation-only.
|
|
196
|
+
let size = sheetContainer.bounds.size
|
|
197
|
+
let center = sheetContainer.center
|
|
198
|
+
return CGRect(
|
|
199
|
+
x: center.x - size.width / 2,
|
|
200
|
+
y: center.y - size.height / 2 + currentTranslationY,
|
|
201
|
+
width: size.width,
|
|
202
|
+
height: size.height
|
|
203
|
+
)
|
|
196
204
|
}
|
|
197
205
|
|
|
198
206
|
override public func point(inside point: CGPoint, with _: UIEvent?) -> Bool {
|
|
@@ -518,7 +526,7 @@ public final class BottomSheetHostingView: UIView {
|
|
|
518
526
|
|
|
519
527
|
@discardableResult
|
|
520
528
|
private func cancelActiveSpring() -> CGFloat {
|
|
521
|
-
let visualTy =
|
|
529
|
+
let visualTy = currentTranslationY
|
|
522
530
|
activeSpring = nil
|
|
523
531
|
activeSpringEmitsSettle = false
|
|
524
532
|
stopDisplayLink()
|
|
@@ -914,11 +922,15 @@ extension BottomSheetHostingView: UIGestureRecognizerDelegate {
|
|
|
914
922
|
private extension BottomSheetHostingView {
|
|
915
923
|
var currentTranslationY: CGFloat {
|
|
916
924
|
// During a settle the modal is driven by a keyframe animation on the render
|
|
917
|
-
// server
|
|
918
|
-
//
|
|
919
|
-
//
|
|
920
|
-
|
|
921
|
-
|
|
925
|
+
// server (the model `transform` already holds the final target), so read the
|
|
926
|
+
// analytical spring the keyframes were sampled from. The presentation layer
|
|
927
|
+
// is deliberately not used: right after a snap starts it still holds the
|
|
928
|
+
// previously committed transform, and that stale value (e.g. the identity
|
|
929
|
+
// transform from before the first layout) reads as a wide-open sheet — which
|
|
930
|
+
// briefly flashed the scrim on mount. A drag assigns `transform` directly,
|
|
931
|
+
// so outside a settle the model value is correct.
|
|
932
|
+
if let spring = activeSpring {
|
|
933
|
+
return spring.value(at: CACurrentMediaTime())
|
|
922
934
|
}
|
|
923
935
|
return sheetContainer.transform.ty
|
|
924
936
|
}
|
|
@@ -940,6 +952,14 @@ private extension BottomSheetHostingView {
|
|
|
940
952
|
return
|
|
941
953
|
}
|
|
942
954
|
|
|
955
|
+
// Until the first layout places the sheet, the identity transform reads as
|
|
956
|
+
// a fully-open sheet; keep the scrim hidden until the sheet is positioned.
|
|
957
|
+
if !hasLaidOut {
|
|
958
|
+
scrimView.alpha = 0
|
|
959
|
+
scrimView.isHidden = true
|
|
960
|
+
return
|
|
961
|
+
}
|
|
962
|
+
|
|
943
963
|
// If we're settled on the closed detent, dynamic detent/content updates can
|
|
944
964
|
// momentarily report a stale non-zero position. Keep scrim fully hidden.
|
|
945
965
|
if
|
package/package.json
CHANGED