react-native-screen-transitions 3.3.0-rc.2 → 3.3.0
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/LICENSE +21 -0
- package/README.md +51 -7
- package/lib/commonjs/blank-stack/components/stack-view.js +2 -1
- package/lib/commonjs/blank-stack/components/stack-view.js.map +1 -1
- package/lib/commonjs/blank-stack/components/stack-view.native.js +2 -1
- package/lib/commonjs/blank-stack/components/stack-view.native.js.map +1 -1
- package/lib/commonjs/component-stack/components/stack-view.js +2 -1
- package/lib/commonjs/component-stack/components/stack-view.js.map +1 -1
- package/lib/commonjs/shared/animation/resolve-snap-target.js +48 -0
- package/lib/commonjs/shared/animation/resolve-snap-target.js.map +1 -0
- package/lib/commonjs/shared/animation/snap-to.js +35 -34
- package/lib/commonjs/shared/animation/snap-to.js.map +1 -1
- package/lib/commonjs/shared/components/create-transition-aware-component.js +15 -7
- package/lib/commonjs/shared/components/create-transition-aware-component.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/helpers/get-active-overlay.js +3 -2
- package/lib/commonjs/shared/components/overlay/helpers/get-active-overlay.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/variations/float-overlay.js +46 -9
- package/lib/commonjs/shared/components/overlay/variations/float-overlay.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/variations/overlay-host.js +7 -7
- package/lib/commonjs/shared/components/overlay/variations/overlay-host.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/variations/screen-overlay.js +23 -3
- package/lib/commonjs/shared/components/overlay/variations/screen-overlay.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container.js +2 -1
- package/lib/commonjs/shared/components/screen-container.js.map +1 -1
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js +6 -6
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js +7 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-screen-gesture-handlers.js +37 -8
- package/lib/commonjs/shared/hooks/gestures/use-screen-gesture-handlers.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js +12 -13
- package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
- package/lib/commonjs/shared/hooks/lifecycle/use-close-transition.js +5 -2
- package/lib/commonjs/shared/hooks/lifecycle/use-close-transition.js.map +1 -1
- package/lib/commonjs/shared/hooks/lifecycle/use-screen-events.js +14 -4
- package/lib/commonjs/shared/hooks/lifecycle/use-screen-events.js.map +1 -1
- package/lib/commonjs/shared/hooks/navigation/use-optimistic-focused-index.js +20 -0
- package/lib/commonjs/shared/hooks/navigation/use-optimistic-focused-index.js.map +1 -0
- package/lib/commonjs/shared/hooks/navigation/use-screen-state.js +11 -8
- package/lib/commonjs/shared/hooks/navigation/use-screen-state.js.map +1 -1
- package/lib/commonjs/shared/hooks/reanimated/use-shared-value-state.js +4 -1
- package/lib/commonjs/shared/hooks/reanimated/use-shared-value-state.js.map +1 -1
- package/lib/commonjs/shared/providers/gestures.provider.js +17 -6
- package/lib/commonjs/shared/providers/gestures.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/layout-anchor.provider.js +7 -5
- package/lib/commonjs/shared/providers/layout-anchor.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/register-bounds.provider.js +25 -6
- package/lib/commonjs/shared/providers/register-bounds.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/styles.provider.js +1 -6
- package/lib/commonjs/shared/providers/screen/styles.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/stack/direct.provider.js +15 -16
- package/lib/commonjs/shared/providers/stack/direct.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/stack/managed.provider.js +19 -16
- package/lib/commonjs/shared/providers/stack/managed.provider.js.map +1 -1
- package/lib/commonjs/shared/stores/bounds.store.js +46 -0
- package/lib/commonjs/shared/stores/bounds.store.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/index.js +6 -4
- package/lib/commonjs/shared/utils/bounds/index.js.map +1 -1
- package/lib/commonjs/shared/utils/gesture/determine-snap-target.js +9 -2
- package/lib/commonjs/shared/utils/gesture/determine-snap-target.js.map +1 -1
- package/lib/commonjs/shared/utils/gesture/find-collapse-target.js +11 -1
- package/lib/commonjs/shared/utils/gesture/find-collapse-target.js.map +1 -1
- package/lib/commonjs/shared/utils/gesture/validate-snap-points.js +11 -2
- package/lib/commonjs/shared/utils/gesture/validate-snap-points.js.map +1 -1
- package/lib/commonjs/shared/utils/overlay/visibility.js +19 -0
- package/lib/commonjs/shared/utils/overlay/visibility.js.map +1 -0
- package/lib/module/blank-stack/components/stack-view.js +2 -1
- package/lib/module/blank-stack/components/stack-view.js.map +1 -1
- package/lib/module/blank-stack/components/stack-view.native.js +2 -1
- package/lib/module/blank-stack/components/stack-view.native.js.map +1 -1
- package/lib/module/component-stack/components/stack-view.js +2 -1
- package/lib/module/component-stack/components/stack-view.js.map +1 -1
- package/lib/module/shared/animation/resolve-snap-target.js +44 -0
- package/lib/module/shared/animation/resolve-snap-target.js.map +1 -0
- package/lib/module/shared/animation/snap-to.js +34 -34
- package/lib/module/shared/animation/snap-to.js.map +1 -1
- package/lib/module/shared/components/create-transition-aware-component.js +16 -8
- package/lib/module/shared/components/create-transition-aware-component.js.map +1 -1
- package/lib/module/shared/components/overlay/helpers/get-active-overlay.js +4 -2
- package/lib/module/shared/components/overlay/helpers/get-active-overlay.js.map +1 -1
- package/lib/module/shared/components/overlay/variations/float-overlay.js +47 -11
- package/lib/module/shared/components/overlay/variations/float-overlay.js.map +1 -1
- package/lib/module/shared/components/overlay/variations/overlay-host.js +7 -7
- package/lib/module/shared/components/overlay/variations/overlay-host.js.map +1 -1
- package/lib/module/shared/components/overlay/variations/screen-overlay.js +24 -5
- package/lib/module/shared/components/overlay/variations/screen-overlay.js.map +1 -1
- package/lib/module/shared/components/screen-container.js +2 -1
- package/lib/module/shared/components/screen-container.js.map +1 -1
- package/lib/module/shared/hooks/animation/use-screen-animation.js +6 -6
- package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js +7 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-screen-gesture-handlers.js +37 -8
- package/lib/module/shared/hooks/gestures/use-screen-gesture-handlers.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-scroll-registry.js +12 -13
- package/lib/module/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
- package/lib/module/shared/hooks/lifecycle/use-close-transition.js +5 -2
- package/lib/module/shared/hooks/lifecycle/use-close-transition.js.map +1 -1
- package/lib/module/shared/hooks/lifecycle/use-screen-events.js +13 -4
- package/lib/module/shared/hooks/lifecycle/use-screen-events.js.map +1 -1
- package/lib/module/shared/hooks/navigation/use-optimistic-focused-index.js +17 -0
- package/lib/module/shared/hooks/navigation/use-optimistic-focused-index.js.map +1 -0
- package/lib/module/shared/hooks/navigation/use-screen-state.js +12 -9
- package/lib/module/shared/hooks/navigation/use-screen-state.js.map +1 -1
- package/lib/module/shared/hooks/reanimated/use-shared-value-state.js +4 -1
- package/lib/module/shared/hooks/reanimated/use-shared-value-state.js.map +1 -1
- package/lib/module/shared/providers/gestures.provider.js +17 -6
- package/lib/module/shared/providers/gestures.provider.js.map +1 -1
- package/lib/module/shared/providers/layout-anchor.provider.js +7 -5
- package/lib/module/shared/providers/layout-anchor.provider.js.map +1 -1
- package/lib/module/shared/providers/register-bounds.provider.js +25 -6
- package/lib/module/shared/providers/register-bounds.provider.js.map +1 -1
- package/lib/module/shared/providers/screen/styles.provider.js +1 -6
- package/lib/module/shared/providers/screen/styles.provider.js.map +1 -1
- package/lib/module/shared/providers/stack/direct.provider.js +15 -16
- package/lib/module/shared/providers/stack/direct.provider.js.map +1 -1
- package/lib/module/shared/providers/stack/managed.provider.js +19 -16
- package/lib/module/shared/providers/stack/managed.provider.js.map +1 -1
- package/lib/module/shared/stores/bounds.store.js +46 -0
- package/lib/module/shared/stores/bounds.store.js.map +1 -1
- package/lib/module/shared/utils/bounds/index.js +6 -4
- package/lib/module/shared/utils/bounds/index.js.map +1 -1
- package/lib/module/shared/utils/gesture/determine-snap-target.js +9 -2
- package/lib/module/shared/utils/gesture/determine-snap-target.js.map +1 -1
- package/lib/module/shared/utils/gesture/find-collapse-target.js +11 -1
- package/lib/module/shared/utils/gesture/find-collapse-target.js.map +1 -1
- package/lib/module/shared/utils/gesture/validate-snap-points.js +11 -2
- package/lib/module/shared/utils/gesture/validate-snap-points.js.map +1 -1
- package/lib/module/shared/utils/overlay/visibility.js +12 -0
- package/lib/module/shared/utils/overlay/visibility.js.map +1 -0
- package/lib/typescript/blank-stack/components/stack-view.d.ts.map +1 -1
- package/lib/typescript/blank-stack/components/stack-view.native.d.ts.map +1 -1
- package/lib/typescript/component-stack/components/stack-view.d.ts.map +1 -1
- package/lib/typescript/shared/animation/resolve-snap-target.d.ts +3 -0
- package/lib/typescript/shared/animation/resolve-snap-target.d.ts.map +1 -0
- package/lib/typescript/shared/animation/snap-to.d.ts +2 -0
- package/lib/typescript/shared/animation/snap-to.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-transition-aware-component.d.ts +1 -0
- package/lib/typescript/shared/components/create-transition-aware-component.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/helpers/get-active-overlay.d.ts +1 -1
- package/lib/typescript/shared/components/overlay/helpers/get-active-overlay.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/variations/float-overlay.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/variations/overlay-host.d.ts +7 -0
- package/lib/typescript/shared/components/overlay/variations/overlay-host.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/variations/screen-overlay.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-container.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-screen-gesture-handlers.d.ts +1 -1
- package/lib/typescript/shared/hooks/gestures/use-screen-gesture-handlers.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-scroll-registry.d.ts +0 -2
- package/lib/typescript/shared/hooks/gestures/use-scroll-registry.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/lifecycle/use-close-transition.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/lifecycle/use-screen-events.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/navigation/use-optimistic-focused-index.d.ts +7 -0
- package/lib/typescript/shared/hooks/navigation/use-optimistic-focused-index.d.ts.map +1 -0
- package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts +6 -0
- package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/reanimated/use-shared-value-state.d.ts.map +1 -1
- package/lib/typescript/shared/index.d.ts +4 -0
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/gestures.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/layout-anchor.provider.d.ts +1 -1
- package/lib/typescript/shared/providers/layout-anchor.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/register-bounds.provider.d.ts +1 -0
- package/lib/typescript/shared/providers/register-bounds.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/styles.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/stack/direct.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/stack/managed.provider.d.ts.map +1 -1
- package/lib/typescript/shared/stores/bounds.store.d.ts +2 -0
- package/lib/typescript/shared/stores/bounds.store.d.ts.map +1 -1
- package/lib/typescript/shared/types/screen.types.d.ts +36 -1
- package/lib/typescript/shared/types/screen.types.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/index.d.ts.map +1 -1
- package/lib/typescript/shared/utils/gesture/determine-snap-target.d.ts.map +1 -1
- package/lib/typescript/shared/utils/gesture/find-collapse-target.d.ts.map +1 -1
- package/lib/typescript/shared/utils/gesture/validate-snap-points.d.ts.map +1 -1
- package/lib/typescript/shared/utils/overlay/visibility.d.ts +11 -0
- package/lib/typescript/shared/utils/overlay/visibility.d.ts.map +1 -0
- package/package.json +8 -2
- package/src/blank-stack/components/stack-view.native.tsx +2 -1
- package/src/blank-stack/components/stack-view.tsx +2 -1
- package/src/component-stack/components/stack-view.tsx +2 -1
- package/src/shared/animation/resolve-snap-target.ts +53 -0
- package/src/shared/animation/snap-to.ts +47 -38
- package/src/shared/components/create-transition-aware-component.tsx +34 -10
- package/src/shared/components/overlay/helpers/get-active-overlay.ts +3 -2
- package/src/shared/components/overlay/variations/float-overlay.tsx +53 -8
- package/src/shared/components/overlay/variations/overlay-host.tsx +16 -6
- package/src/shared/components/overlay/variations/screen-overlay.tsx +35 -3
- package/src/shared/components/screen-container.tsx +15 -9
- package/src/shared/hooks/animation/use-screen-animation.tsx +8 -8
- package/src/shared/hooks/gestures/use-build-gestures.tsx +5 -1
- package/src/shared/hooks/gestures/use-screen-gesture-handlers.ts +63 -16
- package/src/shared/hooks/gestures/use-scroll-registry.tsx +10 -9
- package/src/shared/hooks/lifecycle/use-close-transition.ts +6 -3
- package/src/shared/hooks/lifecycle/use-screen-events.ts +15 -4
- package/src/shared/hooks/navigation/use-optimistic-focused-index.ts +19 -0
- package/src/shared/hooks/navigation/use-screen-state.tsx +24 -8
- package/src/shared/hooks/reanimated/use-shared-value-state.ts +4 -1
- package/src/shared/providers/gestures.provider.tsx +49 -22
- package/src/shared/providers/layout-anchor.provider.tsx +28 -25
- package/src/shared/providers/register-bounds.provider.tsx +43 -6
- package/src/shared/providers/screen/styles.provider.tsx +1 -7
- package/src/shared/providers/stack/direct.provider.tsx +18 -19
- package/src/shared/providers/stack/managed.provider.tsx +22 -19
- package/src/shared/stores/bounds.store.ts +56 -0
- package/src/shared/types/screen.types.ts +39 -1
- package/src/shared/utils/bounds/index.ts +6 -4
- package/src/shared/utils/gesture/determine-snap-target.ts +15 -4
- package/src/shared/utils/gesture/find-collapse-target.ts +11 -1
- package/src/shared/utils/gesture/validate-snap-points.ts +15 -2
- package/src/shared/utils/overlay/visibility.ts +23 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounds.store.d.ts","sourceRoot":"","sources":["../../../../src/shared/stores/bounds.store.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,kBAAkB,EAEvB,KAAK,UAAU,EACf,MAAM,yBAAyB,CAAC;AAEjC,KAAK,KAAK,GAAG,MAAM,CAAC;AACpB,KAAK,SAAS,GAAG,MAAM,CAAC;AAExB,MAAM,MAAM,QAAQ,GAAG;IACtB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACvB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,SAAS,EAAE,CAAC;CAC3B,CAAC;AAEF,KAAK,OAAO,GAAG;IACd,MAAM,EAAE,gBAAgB,GAAG,QAAQ,CAAC;IACpC,WAAW,EAAE,CAAC,gBAAgB,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC;CAClD,CAAC;AASF,iBAAS,gBAAgB,CACxB,GAAG,EAAE,KAAK,EACV,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,UAAe,EACvB,YAAY,CAAC,EAAE,SAAS,EAAE,QAW1B;AAED,iBAAS,aAAa,CACrB,GAAG,EAAE,KAAK,EACV,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,UAAe,EACvB,YAAY,CAAC,EAAE,SAAS,EAAE,QAa1B;AAED,iBAAS,kBAAkB,CAC1B,GAAG,EAAE,KAAK,EACV,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,UAAe,EACvB,YAAY,CAAC,EAAE,SAAS,EAAE,QAiB1B;AAoBD;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,GAAG,QAAQ,GAAG,IAAI,CAoBhE;AAED,iBAAS,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,IAAI,CA2BxE;AAED;;;GAGG;AACH,iBAAS,KAAK,CAAC,SAAS,EAAE,SAAS,QAmBlC;AAED,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"bounds.store.d.ts","sourceRoot":"","sources":["../../../../src/shared/stores/bounds.store.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,kBAAkB,EAEvB,KAAK,UAAU,EACf,MAAM,yBAAyB,CAAC;AAEjC,KAAK,KAAK,GAAG,MAAM,CAAC;AACpB,KAAK,SAAS,GAAG,MAAM,CAAC;AAExB,MAAM,MAAM,QAAQ,GAAG;IACtB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACvB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,SAAS,EAAE,CAAC;CAC3B,CAAC;AAEF,KAAK,OAAO,GAAG;IACd,MAAM,EAAE,gBAAgB,GAAG,QAAQ,CAAC;IACpC,WAAW,EAAE,CAAC,gBAAgB,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC;CAClD,CAAC;AASF,iBAAS,gBAAgB,CACxB,GAAG,EAAE,KAAK,EACV,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,UAAe,EACvB,YAAY,CAAC,EAAE,SAAS,EAAE,QAW1B;AAED,iBAAS,aAAa,CACrB,GAAG,EAAE,KAAK,EACV,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,UAAe,EACvB,YAAY,CAAC,EAAE,SAAS,EAAE,QAa1B;AAED,iBAAS,gBAAgB,CACxB,GAAG,EAAE,KAAK,EACV,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,UAAe,EACvB,YAAY,CAAC,EAAE,SAAS,EAAE,QAgD1B;AAED,iBAAS,kBAAkB,CAC1B,GAAG,EAAE,KAAK,EACV,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,UAAe,EACvB,YAAY,CAAC,EAAE,SAAS,EAAE,QAiB1B;AAoBD;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,GAAG,QAAQ,GAAG,IAAI,CAoBhE;AAED,iBAAS,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,IAAI,CA2BxE;AAED;;;GAGG;AACH,iBAAS,KAAK,CAAC,SAAS,EAAE,SAAS,QAmBlC;AAED,eAAO,MAAM,UAAU;;;;;;;;CAQtB,CAAC"}
|
|
@@ -45,6 +45,16 @@ export type TransitionAwareProps<T extends object> = AnimatedProps<T> & {
|
|
|
45
45
|
* </Transition.View>
|
|
46
46
|
*/
|
|
47
47
|
sharedBoundTag?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Re-measures this component when the screen regains focus and updates
|
|
50
|
+
* any matching shared-bound source link in place.
|
|
51
|
+
*
|
|
52
|
+
* Useful when layout can change while unfocused (for example, programmatic
|
|
53
|
+
* ScrollView/FlatList scrolling triggered from another screen).
|
|
54
|
+
*
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
remeasureOnFocus?: boolean;
|
|
48
58
|
};
|
|
49
59
|
export type ScreenTransitionConfig = {
|
|
50
60
|
/**
|
|
@@ -56,7 +66,10 @@ export type ScreenTransitionConfig = {
|
|
|
56
66
|
*/
|
|
57
67
|
transitionSpec?: TransitionSpec;
|
|
58
68
|
/**
|
|
59
|
-
*
|
|
69
|
+
* Controls whether swipe-to-dismiss is enabled.
|
|
70
|
+
*
|
|
71
|
+
* For screens with `snapPoints`, gesture-driven snapping between non-dismiss
|
|
72
|
+
* snap points remains available even when this is `false`.
|
|
60
73
|
*/
|
|
61
74
|
gestureEnabled?: boolean;
|
|
62
75
|
/**
|
|
@@ -152,6 +165,16 @@ export type ScreenTransitionConfig = {
|
|
|
152
165
|
* @default true
|
|
153
166
|
*/
|
|
154
167
|
expandViaScrollView?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Locks gesture-based snap movement to the current snap point.
|
|
170
|
+
*
|
|
171
|
+
* When enabled, users cannot gesture between snap points. If dismiss gestures
|
|
172
|
+
* are allowed (`gestureEnabled !== false`), swipe-to-dismiss still works.
|
|
173
|
+
* Programmatic `snapTo()` calls are not affected.
|
|
174
|
+
*
|
|
175
|
+
* @default false
|
|
176
|
+
*/
|
|
177
|
+
gestureSnapLocked?: boolean;
|
|
155
178
|
/**
|
|
156
179
|
* Controls how touches interact with the backdrop area (outside the screen content).
|
|
157
180
|
*
|
|
@@ -163,5 +186,17 @@ export type ScreenTransitionConfig = {
|
|
|
163
186
|
* @default 'block' (or 'passthrough' for component stacks)
|
|
164
187
|
*/
|
|
165
188
|
backdropBehavior?: "block" | "passthrough" | "dismiss" | "collapse";
|
|
189
|
+
/**
|
|
190
|
+
* Custom component to render as the backdrop layer.
|
|
191
|
+
* When provided, replaces the default backdrop entirely — including press handling.
|
|
192
|
+
*
|
|
193
|
+
* Use `useScreenAnimation()` inside the component to access animation values.
|
|
194
|
+
* Use your navigation method of choice (e.g. `router.back()`) to handle dismissal.
|
|
195
|
+
*
|
|
196
|
+
* `backdropBehavior` still controls container-level pointer events when this is set.
|
|
197
|
+
*
|
|
198
|
+
* @default undefined
|
|
199
|
+
*/
|
|
200
|
+
backdropComponent?: React.FC;
|
|
166
201
|
};
|
|
167
202
|
//# sourceMappingURL=screen.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen.types.d.ts","sourceRoot":"","sources":["../../../../src/shared/types/screen.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACX,uBAAuB,EACvB,cAAc,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG;IACvE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"screen.types.d.ts","sourceRoot":"","sources":["../../../../src/shared/types/screen.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACX,uBAAuB,EACvB,cAAc,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG;IACvE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACpC;;OAEG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAElD;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;IAEzD;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAE9C;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,KAAK,CAAC,SAAS,CAAC;IAEnD;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;;;;;;OASG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAE7C;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;;;;;;;OAWG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;IAEpE;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;CAC7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/bounds/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,wBAAwB,EAExB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/bounds/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,wBAAwB,EAExB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,0BAA0B,CAAC;AAoK3E,eAAO,MAAM,YAAY,GACxB,OAAO,IAAI,CAAC,wBAAwB,EAAE,QAAQ,CAAC,KAC7C,cAyGF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"determine-snap-target.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/gesture/determine-snap-target.ts"],"names":[],"mappings":"AAAA,UAAU,wBAAwB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,yBAAyB;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EACnC,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,cAAoB,EACpB,UAAiB,GACjB,EAAE,wBAAwB,GAAG,yBAAyB,
|
|
1
|
+
{"version":3,"file":"determine-snap-target.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/gesture/determine-snap-target.ts"],"names":[],"mappings":"AAAA,UAAU,wBAAwB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,yBAAyB;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EACnC,eAAe,EACf,UAAU,EACV,QAAQ,EACR,SAAS,EACT,cAAoB,EACpB,UAAiB,GACjB,EAAE,wBAAwB,GAAG,yBAAyB,CAqDtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-collapse-target.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/gesture/find-collapse-target.ts"],"names":[],"mappings":"AAEA,UAAU,wBAAwB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,EAAE,EACpB,UAAU,EAAE,OAAO,GACjB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"find-collapse-target.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/gesture/find-collapse-target.ts"],"names":[],"mappings":"AAEA,UAAU,wBAAwB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,EAAE,EACpB,UAAU,EAAE,OAAO,GACjB,wBAAwB,CA8B1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-snap-points.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/gesture/validate-snap-points.ts"],"names":[],"mappings":"AAAA,UAAU,wBAAwB;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,yBAAyB;IAClC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,GAAI,6BAGhC,yBAAyB,KAAG,
|
|
1
|
+
{"version":3,"file":"validate-snap-points.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/gesture/validate-snap-points.ts"],"names":[],"mappings":"AAAA,UAAU,wBAAwB;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,yBAAyB;IAClC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,GAAI,6BAGhC,yBAAyB,KAAG,wBAkC9B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OverlayMode } from "../../types/overlay.types";
|
|
2
|
+
type OverlayOptionsLike = {
|
|
3
|
+
overlay?: unknown;
|
|
4
|
+
overlayMode?: OverlayMode;
|
|
5
|
+
overlayShown?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const isOverlayVisible: (options?: OverlayOptionsLike) => boolean;
|
|
8
|
+
export declare const isFloatOverlayVisible: (options?: OverlayOptionsLike) => boolean;
|
|
9
|
+
export declare const isScreenOverlayVisible: (options?: OverlayOptionsLike) => boolean;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=visibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visibility.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/overlay/visibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,KAAK,kBAAkB,GAAG;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,UAAU,kBAAkB,KAAG,OAE/D,CAAC;AAEF,eAAO,MAAM,qBAAqB,GACjC,UAAU,kBAAkB,KAC1B,OAEF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAClC,UAAU,kBAAkB,KAC1B,OAEF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-screen-transitions",
|
|
3
|
-
"version": "3.3.0
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Easy screen transitions for React Native and Expo",
|
|
5
5
|
"author": "Ed",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,12 @@
|
|
|
45
45
|
"typecheck": "tsc --noEmit",
|
|
46
46
|
"prepublishOnly": "bun run build",
|
|
47
47
|
"release": "release-it",
|
|
48
|
-
"release:
|
|
48
|
+
"release:stable": "release-it",
|
|
49
|
+
"release:beta": "release-it --preRelease=beta",
|
|
50
|
+
"release:rc": "release-it --preRelease=rc",
|
|
51
|
+
"release:dry-run": "release-it --dry-run",
|
|
52
|
+
"release:beta:dry-run": "release-it --preRelease=beta --dry-run",
|
|
53
|
+
"release:rc:dry-run": "release-it --preRelease=rc --dry-run"
|
|
49
54
|
},
|
|
50
55
|
"keywords": [
|
|
51
56
|
"react-native",
|
|
@@ -112,6 +117,7 @@
|
|
|
112
117
|
},
|
|
113
118
|
"plugins": {
|
|
114
119
|
"@release-it/conventional-changelog": {
|
|
120
|
+
"infile": "CHANGELOG.md",
|
|
115
121
|
"preset": {
|
|
116
122
|
"name": "angular"
|
|
117
123
|
},
|
|
@@ -10,6 +10,7 @@ import { Overlay } from "../../shared/components/overlay";
|
|
|
10
10
|
import { ScreenComposer } from "../../shared/providers/screen/screen-composer";
|
|
11
11
|
import { withStackCore } from "../../shared/providers/stack/core.provider";
|
|
12
12
|
import { withManagedStack } from "../../shared/providers/stack/managed.provider";
|
|
13
|
+
import { isScreenOverlayVisible } from "../../shared/utils/overlay/visibility";
|
|
13
14
|
import type {
|
|
14
15
|
BlankStackDescriptor,
|
|
15
16
|
BlankStackNavigationHelpers,
|
|
@@ -31,7 +32,7 @@ const SceneView = React.memo(function SceneView({
|
|
|
31
32
|
return (
|
|
32
33
|
<NavigationContext.Provider value={navigation}>
|
|
33
34
|
<NavigationRouteContext.Provider value={route}>
|
|
34
|
-
{descriptor.options
|
|
35
|
+
{isScreenOverlayVisible(descriptor.options) && <Overlay.Screen />}
|
|
35
36
|
{render()}
|
|
36
37
|
</NavigationRouteContext.Provider>
|
|
37
38
|
</NavigationContext.Provider>
|
|
@@ -10,6 +10,7 @@ import { Overlay } from "../../shared/components/overlay";
|
|
|
10
10
|
import { ScreenComposer } from "../../shared/providers/screen/screen-composer";
|
|
11
11
|
import { withStackCore } from "../../shared/providers/stack/core.provider";
|
|
12
12
|
import { withManagedStack } from "../../shared/providers/stack/managed.provider";
|
|
13
|
+
import { isScreenOverlayVisible } from "../../shared/utils/overlay/visibility";
|
|
13
14
|
import type {
|
|
14
15
|
BlankStackDescriptor,
|
|
15
16
|
BlankStackNavigationHelpers,
|
|
@@ -31,7 +32,7 @@ const SceneView = React.memo(function SceneView({
|
|
|
31
32
|
return (
|
|
32
33
|
<NavigationContext.Provider value={navigation}>
|
|
33
34
|
<NavigationRouteContext.Provider value={route}>
|
|
34
|
-
{descriptor.options
|
|
35
|
+
{isScreenOverlayVisible(descriptor.options) && <Overlay.Screen />}
|
|
35
36
|
{render()}
|
|
36
37
|
</NavigationRouteContext.Provider>
|
|
37
38
|
</NavigationContext.Provider>
|
|
@@ -9,6 +9,7 @@ import { ScreenComposer } from "../../shared/providers/screen/screen-composer";
|
|
|
9
9
|
import { withStackCore } from "../../shared/providers/stack/core.provider";
|
|
10
10
|
import { withManagedStack } from "../../shared/providers/stack/managed.provider";
|
|
11
11
|
import { StackType } from "../../shared/types/stack.types";
|
|
12
|
+
import { isScreenOverlayVisible } from "../../shared/utils/overlay/visibility";
|
|
12
13
|
import type {
|
|
13
14
|
ComponentStackDescriptor,
|
|
14
15
|
ComponentStackNavigationHelpers,
|
|
@@ -27,7 +28,7 @@ const SceneView = React.memo(function SceneView({
|
|
|
27
28
|
return (
|
|
28
29
|
<NavigationContext.Provider value={navigation}>
|
|
29
30
|
<NavigationRouteContext.Provider value={route}>
|
|
30
|
-
{descriptor.options
|
|
31
|
+
{isScreenOverlayVisible(descriptor.options) && <Overlay.Screen />}
|
|
31
32
|
{render()}
|
|
32
33
|
</NavigationRouteContext.Provider>
|
|
33
34
|
</NavigationContext.Provider>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type HistoryEntry, HistoryStore } from "../stores/history.store";
|
|
2
|
+
|
|
3
|
+
const hasSnapPoints = (entry: HistoryEntry): boolean => {
|
|
4
|
+
const snapPoints = entry.descriptor.options?.snapPoints;
|
|
5
|
+
return Boolean(snapPoints && snapPoints.length > 0);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const getNavigatorLineage = (entry: HistoryEntry): string[] => {
|
|
9
|
+
const keys: string[] = [];
|
|
10
|
+
const visited = new Set<string>();
|
|
11
|
+
|
|
12
|
+
let nav: any = entry.descriptor.navigation;
|
|
13
|
+
while (nav) {
|
|
14
|
+
const key = nav.getState?.()?.key;
|
|
15
|
+
if (typeof key === "string" && key.length > 0 && !visited.has(key)) {
|
|
16
|
+
keys.push(key);
|
|
17
|
+
visited.add(key);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof nav.getParent !== "function") {
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
nav = nav.getParent();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!visited.has(entry.navigatorKey)) {
|
|
28
|
+
keys.push(entry.navigatorKey);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return keys;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export function resolveSnapTargetEntry(): HistoryEntry | undefined {
|
|
35
|
+
const anchor = HistoryStore.getMostRecent();
|
|
36
|
+
if (!anchor) return undefined;
|
|
37
|
+
|
|
38
|
+
const lineageKeys = getNavigatorLineage(anchor);
|
|
39
|
+
|
|
40
|
+
for (const navigatorKey of lineageKeys) {
|
|
41
|
+
const match = HistoryStore.getByNavigator(navigatorKey).find(hasSnapPoints);
|
|
42
|
+
if (match) return match;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const all = HistoryStore.toArray();
|
|
46
|
+
for (let i = all.length - 1; i >= 0; i--) {
|
|
47
|
+
if (hasSnapPoints(all[i])) {
|
|
48
|
+
return all[i];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
@@ -1,54 +1,34 @@
|
|
|
1
|
-
/** biome-ignore-all lint/style/noNonNullAssertion: <Options always exist> */
|
|
2
1
|
import { runOnUI } from "react-native-reanimated";
|
|
3
2
|
import { DefaultSnapSpec } from "../configs/specs";
|
|
4
3
|
import { AnimationStore } from "../stores/animation.store";
|
|
5
|
-
import {
|
|
4
|
+
import type { HistoryEntry } from "../stores/history.store";
|
|
6
5
|
import { animateToProgress } from "../utils/animation/animate-to-progress";
|
|
7
6
|
import { logger } from "../utils/logger";
|
|
7
|
+
import { resolveSnapTargetEntry } from "./resolve-snap-target";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* import { snapTo } from 'react-native-screen-transitions';
|
|
17
|
-
*
|
|
18
|
-
* // Snap to the first (smallest) snap point
|
|
19
|
-
* snapTo(0);
|
|
20
|
-
*
|
|
21
|
-
* // Snap to the last (largest) snap point
|
|
22
|
-
* snapTo(2); // if there are 3 snap points
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export function snapTo(index: number): void {
|
|
26
|
-
// Find the most recent screen that has snapPoints defined.
|
|
27
|
-
// This handles cases where parent screens (e.g., expo-router) register after
|
|
28
|
-
// ComponentStack screens, but the ComponentStack is what we want to snap.
|
|
29
|
-
const allHistory = HistoryStore.toArray();
|
|
30
|
-
const screenWithSnapPoints = allHistory
|
|
31
|
-
.filter((entry) => {
|
|
32
|
-
const sp = entry.descriptor.options?.snapPoints;
|
|
33
|
-
return sp && sp.length > 0;
|
|
34
|
-
})
|
|
35
|
-
.pop(); // Last item is most recent (toArray returns oldest-first)
|
|
9
|
+
const getSortedSnapPoints = (
|
|
10
|
+
descriptor: HistoryEntry["descriptor"],
|
|
11
|
+
): number[] | null => {
|
|
12
|
+
const snapPoints = descriptor.options?.snapPoints;
|
|
13
|
+
if (!snapPoints || snapPoints.length === 0) return null;
|
|
14
|
+
return [...snapPoints].sort((a, b) => a - b);
|
|
15
|
+
};
|
|
36
16
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
export function snapDescriptorToIndex(
|
|
18
|
+
descriptor: HistoryEntry["descriptor"],
|
|
19
|
+
index: number,
|
|
20
|
+
): boolean {
|
|
21
|
+
const sorted = getSortedSnapPoints(descriptor);
|
|
22
|
+
if (!sorted) {
|
|
23
|
+
logger.warn("snapTo: target screen has no snapPoints");
|
|
24
|
+
return false;
|
|
40
25
|
}
|
|
41
26
|
|
|
42
|
-
const { descriptor } = screenWithSnapPoints;
|
|
43
|
-
const snapPoints = descriptor.options!.snapPoints!;
|
|
44
|
-
|
|
45
|
-
const sorted = [...snapPoints].sort((a, b) => a - b);
|
|
46
|
-
|
|
47
27
|
if (index < 0 || index >= sorted.length) {
|
|
48
28
|
logger.warn(
|
|
49
29
|
`snapTo: index ${index} out of bounds (0-${sorted.length - 1})`,
|
|
50
30
|
);
|
|
51
|
-
return;
|
|
31
|
+
return false;
|
|
52
32
|
}
|
|
53
33
|
|
|
54
34
|
const targetProgress = sorted[index];
|
|
@@ -65,4 +45,33 @@ export function snapTo(index: number): void {
|
|
|
65
45
|
},
|
|
66
46
|
});
|
|
67
47
|
})();
|
|
48
|
+
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Programmatically snap the currently focused screen to a specific snap point.
|
|
54
|
+
*
|
|
55
|
+
* @param index - The index of the snap point to snap to (0-based, sorted ascending)
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* import { snapTo } from 'react-native-screen-transitions';
|
|
60
|
+
*
|
|
61
|
+
* // Snap to the first (smallest) snap point
|
|
62
|
+
* snapTo(0);
|
|
63
|
+
*
|
|
64
|
+
* // Snap to the last (largest) snap point
|
|
65
|
+
* snapTo(2); // if there are 3 snap points
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function snapTo(index: number): void {
|
|
69
|
+
const screenWithSnapPoints = resolveSnapTargetEntry();
|
|
70
|
+
|
|
71
|
+
if (!screenWithSnapPoints) {
|
|
72
|
+
logger.warn("snapTo: No screens with snapPoints in history");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
snapDescriptorToIndex(screenWithSnapPoints.descriptor, index);
|
|
68
77
|
}
|
|
@@ -3,7 +3,11 @@ import type React from "react";
|
|
|
3
3
|
import { type ComponentType, forwardRef, memo } from "react";
|
|
4
4
|
import type { View } from "react-native";
|
|
5
5
|
import { GestureDetector } from "react-native-gesture-handler";
|
|
6
|
-
import Animated, {
|
|
6
|
+
import Animated, {
|
|
7
|
+
runOnUI,
|
|
8
|
+
useAnimatedRef,
|
|
9
|
+
useComposedEventHandler,
|
|
10
|
+
} from "react-native-reanimated";
|
|
7
11
|
import { useAssociatedStyles } from "../hooks/animation/use-associated-style";
|
|
8
12
|
import { useScrollRegistry } from "../hooks/gestures/use-scroll-registry";
|
|
9
13
|
import { RegisterBoundsProvider } from "../providers/register-bounds.provider";
|
|
@@ -25,26 +29,38 @@ export function createTransitionAwareComponent<P extends object>(
|
|
|
25
29
|
React.ComponentRef<typeof Wrapped>,
|
|
26
30
|
TransitionAwareProps<P>
|
|
27
31
|
>((props: any, ref) => {
|
|
32
|
+
const {
|
|
33
|
+
remeasureOnFocus: _remeasureOnFocus,
|
|
34
|
+
onScroll: userOnScroll,
|
|
35
|
+
...scrollableProps
|
|
36
|
+
} = props;
|
|
37
|
+
|
|
28
38
|
// Determine scroll direction from the horizontal prop (standard ScrollView API)
|
|
29
|
-
const scrollDirection =
|
|
39
|
+
const scrollDirection = scrollableProps.horizontal
|
|
40
|
+
? "horizontal"
|
|
41
|
+
: "vertical";
|
|
30
42
|
|
|
31
43
|
// Get scroll handlers and the gesture owner's nativeGesture for this axis
|
|
32
44
|
const { scrollHandler, onContentSizeChange, onLayout, nativeGesture } =
|
|
33
45
|
useScrollRegistry({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
onLayout: props.onLayout,
|
|
46
|
+
onContentSizeChange: scrollableProps.onContentSizeChange,
|
|
47
|
+
onLayout: scrollableProps.onLayout,
|
|
37
48
|
direction: scrollDirection,
|
|
38
49
|
});
|
|
39
50
|
|
|
51
|
+
const composedScrollHandler = useComposedEventHandler([
|
|
52
|
+
scrollHandler,
|
|
53
|
+
userOnScroll ?? null,
|
|
54
|
+
]);
|
|
55
|
+
|
|
40
56
|
const scrollableComponent = (
|
|
41
57
|
<AnimatedComponent
|
|
42
|
-
{...(
|
|
58
|
+
{...(scrollableProps as any)}
|
|
43
59
|
ref={ref}
|
|
44
|
-
onScroll={
|
|
60
|
+
onScroll={composedScrollHandler}
|
|
45
61
|
onContentSizeChange={onContentSizeChange}
|
|
46
62
|
onLayout={onLayout}
|
|
47
|
-
scrollEventThrottle={
|
|
63
|
+
scrollEventThrottle={scrollableProps.scrollEventThrottle || 16}
|
|
48
64
|
/>
|
|
49
65
|
);
|
|
50
66
|
|
|
@@ -64,8 +80,15 @@ export function createTransitionAwareComponent<P extends object>(
|
|
|
64
80
|
React.ComponentRef<typeof AnimatedComponent>,
|
|
65
81
|
TransitionAwareProps<P>
|
|
66
82
|
>((props, _) => {
|
|
67
|
-
const {
|
|
68
|
-
|
|
83
|
+
const {
|
|
84
|
+
children,
|
|
85
|
+
style,
|
|
86
|
+
sharedBoundTag,
|
|
87
|
+
styleId,
|
|
88
|
+
onPress,
|
|
89
|
+
remeasureOnFocus,
|
|
90
|
+
...rest
|
|
91
|
+
} = props as any;
|
|
69
92
|
|
|
70
93
|
const animatedRef = useAnimatedRef<View>();
|
|
71
94
|
|
|
@@ -80,6 +103,7 @@ export function createTransitionAwareComponent<P extends object>(
|
|
|
80
103
|
style={style}
|
|
81
104
|
onPress={onPress}
|
|
82
105
|
sharedBoundTag={sharedBoundTag}
|
|
106
|
+
remeasureOnFocus={remeasureOnFocus}
|
|
83
107
|
>
|
|
84
108
|
{({ captureActiveOnPress, handleInitialLayout }) => (
|
|
85
109
|
<AnimatedComponent
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { StackScene } from "../../../hooks/navigation/use-stack";
|
|
2
|
+
import { isFloatOverlayVisible } from "../../../utils/overlay/visibility";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Find the active float overlay from scenes.
|
|
5
6
|
* Scans from the top of the stack downward to find the first screen
|
|
6
|
-
* with
|
|
7
|
+
* with a visible overlay that isn't explicitly set to legacy screen mode.
|
|
7
8
|
*/
|
|
8
9
|
export function getActiveFloatOverlay(
|
|
9
10
|
scenes: StackScene[],
|
|
@@ -29,7 +30,7 @@ export function getActiveFloatOverlay(
|
|
|
29
30
|
continue;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
if (options
|
|
33
|
+
if (isFloatOverlayVisible(options)) {
|
|
33
34
|
return { scene, overlayIndex: i };
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
+
import { snapDescriptorToIndex } from "../../../animation/snap-to";
|
|
3
|
+
import { useOptimisticFocusedIndex } from "../../../hooks/navigation/use-optimistic-focused-index";
|
|
2
4
|
import { useStack } from "../../../hooks/navigation/use-stack";
|
|
5
|
+
import type { BaseDescriptor } from "../../../providers/screen/keys.provider";
|
|
3
6
|
import { KeysProvider } from "../../../providers/screen/keys.provider";
|
|
4
7
|
import { ScreenStylesProvider } from "../../../providers/screen/styles.provider";
|
|
8
|
+
import type { OverlayProps } from "../../../types/overlay.types";
|
|
5
9
|
import { getActiveFloatOverlay } from "../helpers/get-active-overlay";
|
|
6
10
|
import { OverlayHost } from "./overlay-host";
|
|
7
11
|
|
|
12
|
+
type OverlayScreenState = Omit<
|
|
13
|
+
OverlayProps<BaseDescriptor["navigation"]>,
|
|
14
|
+
"progress" | "overlayAnimation" | "screenAnimation"
|
|
15
|
+
> & {
|
|
16
|
+
index: number;
|
|
17
|
+
snapTo: (index: number) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
8
20
|
/**
|
|
9
21
|
* Float overlay component that renders above all screens.
|
|
10
22
|
* Gets routes and descriptors from stack context.
|
|
11
23
|
*/
|
|
12
24
|
export function FloatOverlay() {
|
|
13
|
-
const { scenes,
|
|
25
|
+
const { scenes, optimisticFocusedIndex, flags, routes, routeKeys } =
|
|
26
|
+
useStack();
|
|
27
|
+
const focusedIndex = useOptimisticFocusedIndex(
|
|
28
|
+
optimisticFocusedIndex,
|
|
29
|
+
routeKeys.length,
|
|
30
|
+
);
|
|
14
31
|
|
|
15
32
|
const activeOverlay = useMemo(
|
|
16
33
|
() =>
|
|
@@ -18,20 +35,48 @@ export function FloatOverlay() {
|
|
|
18
35
|
[scenes, focusedIndex, flags.TRANSITIONS_ALWAYS_ON],
|
|
19
36
|
);
|
|
20
37
|
|
|
21
|
-
|
|
38
|
+
const overlayData = useMemo(() => {
|
|
39
|
+
if (!activeOverlay) return null;
|
|
40
|
+
|
|
41
|
+
const { scene, overlayIndex } = activeOverlay;
|
|
42
|
+
const previous = scenes[overlayIndex - 1]?.descriptor;
|
|
43
|
+
const current = scene.descriptor;
|
|
44
|
+
const next = scenes[overlayIndex + 1]?.descriptor;
|
|
45
|
+
const focusedScene = scenes[focusedIndex] ?? scenes[scenes.length - 1];
|
|
46
|
+
const focusedDescriptor = focusedScene?.descriptor;
|
|
47
|
+
|
|
48
|
+
const overlayScreenState: OverlayScreenState = {
|
|
49
|
+
index: routeKeys.indexOf(current.route.key),
|
|
50
|
+
options: focusedDescriptor?.options ?? {},
|
|
51
|
+
routes,
|
|
52
|
+
focusedRoute: focusedScene?.route ?? current.route,
|
|
53
|
+
focusedIndex,
|
|
54
|
+
meta: focusedDescriptor?.options?.meta,
|
|
55
|
+
navigation: current.navigation,
|
|
56
|
+
snapTo: (index: number) => {
|
|
57
|
+
snapDescriptorToIndex(current, index);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
scene,
|
|
63
|
+
previous,
|
|
64
|
+
current,
|
|
65
|
+
next,
|
|
66
|
+
overlayScreenState,
|
|
67
|
+
};
|
|
68
|
+
}, [activeOverlay, scenes, focusedIndex, routeKeys, routes]);
|
|
69
|
+
|
|
70
|
+
if (!overlayData) {
|
|
22
71
|
return null;
|
|
23
72
|
}
|
|
24
73
|
|
|
25
|
-
const { scene,
|
|
26
|
-
|
|
27
|
-
const previous = scenes[overlayIndex - 1]?.descriptor;
|
|
28
|
-
const current = scene.descriptor;
|
|
29
|
-
const next = scenes[overlayIndex + 1]?.descriptor;
|
|
74
|
+
const { scene, previous, current, next, overlayScreenState } = overlayData;
|
|
30
75
|
|
|
31
76
|
return (
|
|
32
77
|
<KeysProvider current={current} previous={previous} next={next}>
|
|
33
78
|
<ScreenStylesProvider>
|
|
34
|
-
<OverlayHost scene={scene} />
|
|
79
|
+
<OverlayHost scene={scene} overlayScreenState={overlayScreenState} />
|
|
35
80
|
</ScreenStylesProvider>
|
|
36
81
|
</KeysProvider>
|
|
37
82
|
);
|
|
@@ -7,25 +7,33 @@ import { Animated, StyleSheet, useWindowDimensions, View } from "react-native";
|
|
|
7
7
|
import { useDerivedValue } from "react-native-reanimated";
|
|
8
8
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
9
9
|
import { useScreenAnimation } from "../../../hooks/animation/use-screen-animation";
|
|
10
|
-
import { useScreenState } from "../../../hooks/navigation/use-screen-state";
|
|
11
10
|
import type { StackScene } from "../../../hooks/navigation/use-stack";
|
|
12
11
|
import type { BaseDescriptor } from "../../../providers/screen/keys.provider";
|
|
13
12
|
import type { OverlayInterpolationProps } from "../../../types/animation.types";
|
|
14
13
|
import type { OverlayProps } from "../../../types/overlay.types";
|
|
15
14
|
|
|
15
|
+
type OverlayScreenState = Omit<
|
|
16
|
+
OverlayProps<BaseDescriptor["navigation"]>,
|
|
17
|
+
"progress" | "overlayAnimation" | "screenAnimation"
|
|
18
|
+
> & {
|
|
19
|
+
index: number;
|
|
20
|
+
snapTo: (index: number) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
16
23
|
type OverlayHostProps = {
|
|
17
24
|
scene: StackScene;
|
|
25
|
+
overlayScreenState: OverlayScreenState;
|
|
18
26
|
};
|
|
19
27
|
|
|
20
28
|
export const OverlayHost = memo(function OverlayHost({
|
|
21
29
|
scene,
|
|
30
|
+
overlayScreenState,
|
|
22
31
|
}: OverlayHostProps) {
|
|
23
32
|
const OverlayComponent = scene.descriptor.options.overlay;
|
|
24
33
|
const screen = useWindowDimensions();
|
|
25
34
|
const insets = useSafeAreaInsets();
|
|
26
35
|
|
|
27
36
|
const screenAnimation = useScreenAnimation();
|
|
28
|
-
const screenState = useScreenState();
|
|
29
37
|
const relativeProgress = useDerivedValue(() => {
|
|
30
38
|
"worklet";
|
|
31
39
|
return screenAnimation.value.stackProgress;
|
|
@@ -39,12 +47,14 @@ export const OverlayHost = memo(function OverlayHost({
|
|
|
39
47
|
|
|
40
48
|
const overlayProps: OverlayProps<BaseDescriptor["navigation"]> = useMemo(
|
|
41
49
|
() => ({
|
|
42
|
-
...
|
|
50
|
+
...overlayScreenState,
|
|
43
51
|
progress: relativeProgress,
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
/**@deprecated */
|
|
53
|
+
overlayAnimation,
|
|
54
|
+
/**@deprecated */
|
|
55
|
+
screenAnimation,
|
|
46
56
|
}),
|
|
47
|
-
[relativeProgress, overlayAnimation, screenAnimation,
|
|
57
|
+
[relativeProgress, overlayAnimation, screenAnimation, overlayScreenState],
|
|
48
58
|
);
|
|
49
59
|
|
|
50
60
|
if (!OverlayComponent) {
|