react-native-screen-transitions 2.0.4 → 2.1.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/README.md +100 -77
- package/lib/commonjs/components/{bounds-activator.js → bound-capture.js} +4 -4
- package/lib/commonjs/components/bound-capture.js.map +1 -0
- package/lib/commonjs/components/controllers/screen-lifecycle.js +18 -4
- package/lib/commonjs/components/controllers/screen-lifecycle.js.map +1 -1
- package/lib/commonjs/components/create-transition-aware-component.js +14 -12
- package/lib/commonjs/components/create-transition-aware-component.js.map +1 -1
- package/lib/commonjs/components/integrations/masked-view.js +52 -0
- package/lib/commonjs/components/integrations/masked-view.js.map +1 -0
- package/lib/commonjs/components/root-transition-aware.js +6 -15
- package/lib/commonjs/components/root-transition-aware.js.map +1 -1
- package/lib/commonjs/configs/index.js +15 -5
- package/lib/commonjs/configs/index.js.map +1 -1
- package/lib/commonjs/configs/presets.js +378 -7
- package/lib/commonjs/configs/presets.js.map +1 -1
- package/lib/commonjs/configs/specs.js +1 -1
- package/lib/commonjs/hooks/animation/use-associated-style.js +7 -10
- package/lib/commonjs/hooks/animation/use-associated-style.js.map +1 -1
- package/lib/commonjs/hooks/animation/use-screen-animation.js +37 -37
- package/lib/commonjs/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/hooks/bounds/use-bound-registry.js +73 -0
- package/lib/commonjs/hooks/bounds/use-bound-registry.js.map +1 -0
- package/lib/commonjs/hooks/gestures/use-build-gestures.js +156 -152
- package/lib/commonjs/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/hooks/gestures/use-parent-gesture-registry.js +28 -0
- package/lib/commonjs/hooks/gestures/use-parent-gesture-registry.js.map +1 -0
- package/lib/commonjs/hooks/gestures/use-scroll-registry.js +146 -0
- package/lib/commonjs/hooks/gestures/use-scroll-registry.js.map +1 -0
- package/lib/commonjs/index.js +3 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/integrations/native-stack/views/NativeStackView.native.js +7 -4
- package/lib/commonjs/integrations/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/commonjs/providers/gestures.js +16 -16
- package/lib/commonjs/providers/gestures.js.map +1 -1
- package/lib/commonjs/providers/transition-styles.js +44 -0
- package/lib/commonjs/providers/transition-styles.js.map +1 -0
- package/lib/commonjs/stores/bounds.js +142 -1
- package/lib/commonjs/stores/bounds.js.map +1 -1
- package/lib/commonjs/stores/utils/reset-stores-for-screen.js +4 -2
- package/lib/commonjs/stores/utils/reset-stores-for-screen.js.map +1 -1
- package/lib/commonjs/types/gesture.js +11 -0
- package/lib/commonjs/types/gesture.js.map +1 -1
- package/lib/commonjs/utils/animation/derivations.js +39 -0
- package/lib/commonjs/utils/animation/derivations.js.map +1 -0
- package/lib/commonjs/utils/animation/run-transition.js +6 -2
- package/lib/commonjs/utils/animation/run-transition.js.map +1 -1
- package/lib/commonjs/utils/bounds/_utils/flatten-styles.js.map +1 -0
- package/lib/commonjs/utils/bounds/_utils/geometry.js +179 -0
- package/lib/commonjs/utils/bounds/_utils/geometry.js.map +1 -0
- package/lib/commonjs/utils/bounds/{get-bounds.js → _utils/get-bounds.js} +7 -9
- package/lib/commonjs/utils/bounds/_utils/get-bounds.js.map +1 -0
- package/lib/commonjs/utils/bounds/_utils/is-bounds-equal.js +19 -0
- package/lib/commonjs/utils/bounds/_utils/is-bounds-equal.js.map +1 -0
- package/lib/commonjs/utils/bounds/_utils/style-composers.js +201 -0
- package/lib/commonjs/utils/bounds/_utils/style-composers.js.map +1 -0
- package/lib/commonjs/utils/bounds/constants.js +14 -3
- package/lib/commonjs/utils/bounds/constants.js.map +1 -1
- package/lib/commonjs/utils/bounds/index.js +210 -17
- package/lib/commonjs/utils/bounds/index.js.map +1 -1
- package/lib/commonjs/utils/gesture/apply-offset-rules.js +233 -0
- package/lib/commonjs/utils/gesture/apply-offset-rules.js.map +1 -0
- package/lib/commonjs/utils/gesture/check-gesture-activation.js +231 -0
- package/lib/commonjs/utils/gesture/check-gesture-activation.js.map +1 -0
- package/lib/commonjs/utils/gesture/determine-dismissal.js +98 -0
- package/lib/commonjs/utils/gesture/determine-dismissal.js.map +1 -0
- package/lib/module/components/{bounds-activator.js → bound-capture.js} +2 -2
- package/lib/module/components/bound-capture.js.map +1 -0
- package/lib/module/components/controllers/screen-lifecycle.js +18 -4
- package/lib/module/components/controllers/screen-lifecycle.js.map +1 -1
- package/lib/module/components/create-transition-aware-component.js +14 -12
- package/lib/module/components/create-transition-aware-component.js.map +1 -1
- package/lib/module/components/integrations/masked-view.js +48 -0
- package/lib/module/components/integrations/masked-view.js.map +1 -0
- package/lib/module/components/root-transition-aware.js +7 -16
- package/lib/module/components/root-transition-aware.js.map +1 -1
- package/lib/module/configs/index.js +15 -2
- package/lib/module/configs/index.js.map +1 -1
- package/lib/module/configs/presets.js +374 -6
- package/lib/module/configs/presets.js.map +1 -1
- package/lib/module/configs/specs.js +1 -1
- package/lib/module/hooks/animation/use-associated-style.js +6 -10
- package/lib/module/hooks/animation/use-associated-style.js.map +1 -1
- package/lib/module/hooks/animation/use-screen-animation.js +37 -37
- package/lib/module/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/hooks/bounds/use-bound-registry.js +68 -0
- package/lib/module/hooks/bounds/use-bound-registry.js.map +1 -0
- package/lib/module/hooks/gestures/use-build-gestures.js +156 -153
- package/lib/module/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/hooks/gestures/use-parent-gesture-registry.js +23 -0
- package/lib/module/hooks/gestures/use-parent-gesture-registry.js.map +1 -0
- package/lib/module/hooks/gestures/use-scroll-registry.js +140 -0
- package/lib/module/hooks/gestures/use-scroll-registry.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/integrations/native-stack/views/NativeStackView.native.js +7 -4
- package/lib/module/integrations/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/module/providers/gestures.js +16 -16
- package/lib/module/providers/gestures.js.map +1 -1
- package/lib/module/providers/transition-styles.js +39 -0
- package/lib/module/providers/transition-styles.js.map +1 -0
- package/lib/module/stores/bounds.js +142 -1
- package/lib/module/stores/bounds.js.map +1 -1
- package/lib/module/stores/utils/reset-stores-for-screen.js +4 -2
- package/lib/module/stores/utils/reset-stores-for-screen.js.map +1 -1
- package/lib/module/types/gesture.js +7 -0
- package/lib/module/types/gesture.js.map +1 -1
- package/lib/module/utils/animation/derivations.js +34 -0
- package/lib/module/utils/animation/derivations.js.map +1 -0
- package/lib/module/utils/animation/run-transition.js +6 -2
- package/lib/module/utils/animation/run-transition.js.map +1 -1
- package/lib/module/utils/bounds/_utils/flatten-styles.js.map +1 -0
- package/lib/module/utils/bounds/_utils/geometry.js +174 -0
- package/lib/module/utils/bounds/_utils/geometry.js.map +1 -0
- package/lib/module/utils/bounds/{get-bounds.js → _utils/get-bounds.js} +7 -9
- package/lib/module/utils/bounds/_utils/get-bounds.js.map +1 -0
- package/lib/module/utils/bounds/_utils/is-bounds-equal.js +14 -0
- package/lib/module/utils/bounds/_utils/is-bounds-equal.js.map +1 -0
- package/lib/module/utils/bounds/_utils/style-composers.js +194 -0
- package/lib/module/utils/bounds/_utils/style-composers.js.map +1 -0
- package/lib/module/utils/bounds/constants.js +14 -3
- package/lib/module/utils/bounds/constants.js.map +1 -1
- package/lib/module/utils/bounds/index.js +208 -15
- package/lib/module/utils/bounds/index.js.map +1 -1
- package/lib/module/utils/gesture/apply-offset-rules.js +228 -0
- package/lib/module/utils/gesture/apply-offset-rules.js.map +1 -0
- package/lib/module/utils/gesture/check-gesture-activation.js +226 -0
- package/lib/module/utils/gesture/check-gesture-activation.js.map +1 -0
- package/lib/module/utils/gesture/determine-dismissal.js +93 -0
- package/lib/module/utils/gesture/determine-dismissal.js.map +1 -0
- package/lib/typescript/components/bound-capture.d.ts +8 -0
- package/lib/typescript/components/bound-capture.d.ts.map +1 -0
- package/lib/typescript/components/controllers/screen-lifecycle.d.ts.map +1 -1
- package/lib/typescript/components/create-transition-aware-component.d.ts.map +1 -1
- package/lib/typescript/components/integrations/masked-view.d.ts +6 -0
- package/lib/typescript/components/integrations/masked-view.d.ts.map +1 -0
- package/lib/typescript/components/root-transition-aware.d.ts +3 -3
- package/lib/typescript/components/root-transition-aware.d.ts.map +1 -1
- package/lib/typescript/configs/index.d.ts +15 -2
- package/lib/typescript/configs/index.d.ts.map +1 -1
- package/lib/typescript/configs/presets.d.ts +3 -0
- package/lib/typescript/configs/presets.d.ts.map +1 -1
- package/lib/typescript/hooks/animation/use-associated-style.d.ts +6 -4
- package/lib/typescript/hooks/animation/use-associated-style.d.ts.map +1 -1
- package/lib/typescript/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/hooks/bounds/{use-bound-measurer.d.ts → use-bound-registry.d.ts} +5 -4
- package/lib/typescript/hooks/bounds/{use-bound-measurer.d.ts.map → use-bound-registry.d.ts.map} +1 -1
- package/lib/typescript/hooks/gestures/use-build-gestures.d.ts +6 -5
- package/lib/typescript/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/hooks/gestures/use-parent-gesture-registry.d.ts +6 -0
- package/lib/typescript/hooks/gestures/use-parent-gesture-registry.d.ts.map +1 -0
- package/lib/typescript/hooks/gestures/{use-scroll-progress.d.ts → use-scroll-registry.d.ts} +2 -2
- package/lib/typescript/hooks/gestures/use-scroll-registry.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +25 -11
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/integrations/native-stack/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/providers/gestures.d.ts +4 -2
- package/lib/typescript/providers/gestures.d.ts.map +1 -1
- package/lib/typescript/providers/transition-styles.d.ts +8 -0
- package/lib/typescript/providers/transition-styles.d.ts.map +1 -0
- package/lib/typescript/stores/bounds.d.ts +11 -0
- package/lib/typescript/stores/bounds.d.ts.map +1 -1
- package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts +3 -1
- package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts.map +1 -1
- package/lib/typescript/types/bounds.d.ts +5 -1
- package/lib/typescript/types/bounds.d.ts.map +1 -1
- package/lib/typescript/types/gesture.d.ts +14 -0
- package/lib/typescript/types/gesture.d.ts.map +1 -1
- package/lib/typescript/types/navigator.d.ts +5 -1
- package/lib/typescript/types/navigator.d.ts.map +1 -1
- package/lib/typescript/utils/animation/derivations.d.ts +19 -0
- package/lib/typescript/utils/animation/derivations.d.ts.map +1 -0
- package/lib/typescript/utils/animation/run-transition.d.ts +2 -1
- package/lib/typescript/utils/animation/run-transition.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/_types/builder.d.ts +96 -14
- package/lib/typescript/utils/bounds/_types/builder.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/_types/geometry.d.ts +0 -1
- package/lib/typescript/utils/bounds/_types/geometry.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/_utils/flatten-styles.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/{geometry.d.ts → _utils/geometry.d.ts} +8 -5
- package/lib/typescript/utils/bounds/_utils/geometry.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/_utils/get-bounds.d.ts +4 -0
- package/lib/typescript/utils/bounds/_utils/get-bounds.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/_utils/is-bounds-equal.d.ts +7 -0
- package/lib/typescript/utils/bounds/_utils/is-bounds-equal.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/{style-composers.d.ts → _utils/style-composers.d.ts} +7 -10
- package/lib/typescript/utils/bounds/_utils/style-composers.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/constants.d.ts +5 -5
- package/lib/typescript/utils/bounds/constants.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/index.d.ts +2 -4
- package/lib/typescript/utils/bounds/index.d.ts.map +1 -1
- package/lib/typescript/utils/gesture/apply-offset-rules.d.ts +38 -0
- package/lib/typescript/utils/gesture/apply-offset-rules.d.ts.map +1 -0
- package/lib/typescript/utils/gesture/check-gesture-activation.d.ts +38 -0
- package/lib/typescript/utils/gesture/check-gesture-activation.d.ts.map +1 -0
- package/lib/typescript/utils/gesture/determine-dismissal.d.ts +25 -0
- package/lib/typescript/utils/gesture/determine-dismissal.d.ts.map +1 -0
- package/package.json +2 -3
- package/src/__tests__/geometry.test.ts +15 -12
- package/src/components/{bounds-activator.tsx → bound-capture.tsx} +1 -1
- package/src/components/controllers/screen-lifecycle.tsx +13 -5
- package/src/components/create-transition-aware-component.tsx +17 -11
- package/src/components/integrations/masked-view.tsx +56 -0
- package/src/components/root-transition-aware.tsx +31 -39
- package/src/configs/index.ts +26 -2
- package/src/configs/presets.ts +401 -6
- package/src/configs/specs.ts +1 -1
- package/src/hooks/animation/use-associated-style.tsx +12 -11
- package/src/hooks/animation/use-screen-animation.tsx +48 -49
- package/src/hooks/bounds/{use-bound-measurer.tsx → use-bound-registry.tsx} +32 -20
- package/src/hooks/gestures/use-build-gestures.tsx +193 -228
- package/src/hooks/gestures/use-parent-gesture-registry.tsx +18 -0
- package/src/hooks/gestures/use-scroll-registry.tsx +145 -0
- package/src/index.ts +2 -0
- package/src/integrations/native-stack/views/NativeStackView.native.tsx +8 -5
- package/src/providers/gestures.tsx +19 -22
- package/src/providers/transition-styles.tsx +52 -0
- package/src/stores/bounds.ts +156 -0
- package/src/stores/utils/reset-stores-for-screen.ts +7 -2
- package/src/types/bounds.ts +8 -1
- package/src/types/gesture.ts +19 -0
- package/src/types/navigator.ts +5 -1
- package/src/utils/animation/derivations.ts +38 -0
- package/src/utils/animation/run-transition.ts +4 -1
- package/src/utils/bounds/_types/builder.ts +127 -11
- package/src/utils/bounds/_types/geometry.ts +0 -1
- package/src/utils/bounds/_utils/geometry.ts +166 -0
- package/src/utils/bounds/_utils/get-bounds.ts +54 -0
- package/src/utils/bounds/_utils/is-bounds-equal.ts +24 -0
- package/src/utils/bounds/_utils/style-composers.ts +216 -0
- package/src/utils/bounds/constants.ts +37 -22
- package/src/utils/bounds/index.ts +269 -19
- package/src/utils/gesture/apply-offset-rules.ts +314 -0
- package/src/utils/gesture/check-gesture-activation.ts +310 -0
- package/src/utils/gesture/determine-dismissal.ts +131 -0
- package/lib/commonjs/components/bounds-activator.js.map +0 -1
- package/lib/commonjs/hooks/bounds/use-bound-measurer.js +0 -52
- package/lib/commonjs/hooks/bounds/use-bound-measurer.js.map +0 -1
- package/lib/commonjs/hooks/gestures/use-scroll-progress.js +0 -57
- package/lib/commonjs/hooks/gestures/use-scroll-progress.js.map +0 -1
- package/lib/commonjs/utils/bounds/build-bound-styles.js +0 -145
- package/lib/commonjs/utils/bounds/build-bound-styles.js.map +0 -1
- package/lib/commonjs/utils/bounds/flatten-styles.js.map +0 -1
- package/lib/commonjs/utils/bounds/geometry.js +0 -94
- package/lib/commonjs/utils/bounds/geometry.js.map +0 -1
- package/lib/commonjs/utils/bounds/get-bounds.js.map +0 -1
- package/lib/commonjs/utils/bounds/style-composers.js +0 -199
- package/lib/commonjs/utils/bounds/style-composers.js.map +0 -1
- package/lib/commonjs/utils/gesture/apply-gesture-activation-criteria.js +0 -81
- package/lib/commonjs/utils/gesture/apply-gesture-activation-criteria.js.map +0 -1
- package/lib/commonjs/utils/gesture/normalize-gesture-translation.js +0 -21
- package/lib/commonjs/utils/gesture/normalize-gesture-translation.js.map +0 -1
- package/lib/commonjs/utils/index.js +0 -17
- package/lib/commonjs/utils/index.js.map +0 -1
- package/lib/module/components/bounds-activator.js.map +0 -1
- package/lib/module/hooks/bounds/use-bound-measurer.js +0 -47
- package/lib/module/hooks/bounds/use-bound-measurer.js.map +0 -1
- package/lib/module/hooks/gestures/use-scroll-progress.js +0 -52
- package/lib/module/hooks/gestures/use-scroll-progress.js.map +0 -1
- package/lib/module/utils/bounds/build-bound-styles.js +0 -141
- package/lib/module/utils/bounds/build-bound-styles.js.map +0 -1
- package/lib/module/utils/bounds/flatten-styles.js.map +0 -1
- package/lib/module/utils/bounds/geometry.js +0 -89
- package/lib/module/utils/bounds/geometry.js.map +0 -1
- package/lib/module/utils/bounds/get-bounds.js.map +0 -1
- package/lib/module/utils/bounds/style-composers.js +0 -191
- package/lib/module/utils/bounds/style-composers.js.map +0 -1
- package/lib/module/utils/gesture/apply-gesture-activation-criteria.js +0 -76
- package/lib/module/utils/gesture/apply-gesture-activation-criteria.js.map +0 -1
- package/lib/module/utils/gesture/normalize-gesture-translation.js +0 -16
- package/lib/module/utils/gesture/normalize-gesture-translation.js.map +0 -1
- package/lib/module/utils/index.js +0 -4
- package/lib/module/utils/index.js.map +0 -1
- package/lib/typescript/components/bounds-activator.d.ts +0 -8
- package/lib/typescript/components/bounds-activator.d.ts.map +0 -1
- package/lib/typescript/hooks/gestures/use-scroll-progress.d.ts.map +0 -1
- package/lib/typescript/utils/bounds/build-bound-styles.d.ts +0 -4
- package/lib/typescript/utils/bounds/build-bound-styles.d.ts.map +0 -1
- package/lib/typescript/utils/bounds/flatten-styles.d.ts.map +0 -1
- package/lib/typescript/utils/bounds/geometry.d.ts.map +0 -1
- package/lib/typescript/utils/bounds/get-bounds.d.ts +0 -4
- package/lib/typescript/utils/bounds/get-bounds.d.ts.map +0 -1
- package/lib/typescript/utils/bounds/style-composers.d.ts.map +0 -1
- package/lib/typescript/utils/gesture/apply-gesture-activation-criteria.d.ts +0 -17
- package/lib/typescript/utils/gesture/apply-gesture-activation-criteria.d.ts.map +0 -1
- package/lib/typescript/utils/gesture/normalize-gesture-translation.d.ts +0 -6
- package/lib/typescript/utils/gesture/normalize-gesture-translation.d.ts.map +0 -1
- package/lib/typescript/utils/index.d.ts +0 -2
- package/lib/typescript/utils/index.d.ts.map +0 -1
- package/src/hooks/gestures/use-scroll-progress.tsx +0 -60
- package/src/utils/bounds/build-bound-styles.ts +0 -184
- package/src/utils/bounds/geometry.ts +0 -113
- package/src/utils/bounds/get-bounds.ts +0 -56
- package/src/utils/bounds/style-composers.ts +0 -172
- package/src/utils/gesture/apply-gesture-activation-criteria.ts +0 -109
- package/src/utils/gesture/normalize-gesture-translation.ts +0 -20
- package/src/utils/index.ts +0 -1
- /package/lib/commonjs/utils/bounds/{flatten-styles.js → _utils/flatten-styles.js} +0 -0
- /package/lib/module/utils/bounds/{flatten-styles.js → _utils/flatten-styles.js} +0 -0
- /package/lib/typescript/utils/bounds/{flatten-styles.d.ts → _utils/flatten-styles.d.ts} +0 -0
- /package/src/utils/bounds/{flatten-styles.ts → _utils/flatten-styles.ts} +0 -0
package/src/configs/presets.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
1
2
|
import {
|
|
2
3
|
Extrapolation,
|
|
3
4
|
interpolate,
|
|
@@ -6,6 +7,8 @@ import {
|
|
|
6
7
|
import type { ScreenTransitionConfig } from "../types/navigator";
|
|
7
8
|
import { DefaultSpec } from "./specs";
|
|
8
9
|
|
|
10
|
+
const platform = Platform.OS;
|
|
11
|
+
|
|
9
12
|
export const SlideFromTop = (
|
|
10
13
|
config: Partial<ScreenTransitionConfig> = {},
|
|
11
14
|
): ScreenTransitionConfig => {
|
|
@@ -181,9 +184,7 @@ export const ElasticCard = (
|
|
|
181
184
|
|
|
182
185
|
const scale = interpolate(progress, [0, 1, 2], [0, 1, 0.8]);
|
|
183
186
|
|
|
184
|
-
|
|
185
|
-
* Applies to current screen
|
|
186
|
-
*/
|
|
187
|
+
// applies to current screen
|
|
187
188
|
const maxElasticityX = screen.width * (config.elasticFactor ?? 0.5);
|
|
188
189
|
const maxElasticityY = screen.height * (config.elasticFactor ?? 0.5);
|
|
189
190
|
const translateX = interpolate(
|
|
@@ -200,9 +201,7 @@ export const ElasticCard = (
|
|
|
200
201
|
"clamp",
|
|
201
202
|
);
|
|
202
203
|
|
|
203
|
-
|
|
204
|
-
* Applies to unfocused screen ( previous screen )
|
|
205
|
-
*/
|
|
204
|
+
// applies to unfocused screen ( previous screen )
|
|
206
205
|
const overlayColor = interpolateColor(
|
|
207
206
|
progress,
|
|
208
207
|
[0, 1],
|
|
@@ -225,3 +224,399 @@ export const ElasticCard = (
|
|
|
225
224
|
...config,
|
|
226
225
|
};
|
|
227
226
|
};
|
|
227
|
+
|
|
228
|
+
export const SharedIGImage = (
|
|
229
|
+
config: Partial<ScreenTransitionConfig> = {},
|
|
230
|
+
): ScreenTransitionConfig => {
|
|
231
|
+
return {
|
|
232
|
+
gestureEnabled: true,
|
|
233
|
+
gestureDirection: ["vertical", "horizontal"],
|
|
234
|
+
enableTransitions: true,
|
|
235
|
+
gestureDrivesProgress: false,
|
|
236
|
+
screenStyleInterpolator: ({
|
|
237
|
+
current,
|
|
238
|
+
layouts: {
|
|
239
|
+
screen: { height, width },
|
|
240
|
+
},
|
|
241
|
+
bounds,
|
|
242
|
+
progress,
|
|
243
|
+
focused,
|
|
244
|
+
activeBoundId,
|
|
245
|
+
next,
|
|
246
|
+
}) => {
|
|
247
|
+
"worklet";
|
|
248
|
+
|
|
249
|
+
const normX = focused
|
|
250
|
+
? current.gesture.normalizedX
|
|
251
|
+
: (next?.gesture.normalizedX ?? 0);
|
|
252
|
+
const normY = focused
|
|
253
|
+
? current.gesture.normalizedY
|
|
254
|
+
: (next?.gesture.normalizedY ?? 0);
|
|
255
|
+
|
|
256
|
+
// animations for both bounds
|
|
257
|
+
const dragX = interpolate(
|
|
258
|
+
normX,
|
|
259
|
+
[-1, 0, 1],
|
|
260
|
+
[-width * 0.7, 0, width * 0.7],
|
|
261
|
+
);
|
|
262
|
+
const dragY = interpolate(
|
|
263
|
+
normY,
|
|
264
|
+
[-1, 0, 1],
|
|
265
|
+
[-height * 0.4, 0, height * 0.4],
|
|
266
|
+
);
|
|
267
|
+
const dragXScale = interpolate(normX, [0, 1], [1, 0.8]);
|
|
268
|
+
const dragYScale = interpolate(normY, [0, 1], [1, 0.8]);
|
|
269
|
+
|
|
270
|
+
const boundValues = bounds({
|
|
271
|
+
method: focused ? "content" : "transform",
|
|
272
|
+
scaleMode: "uniform",
|
|
273
|
+
raw: true,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// focused specific animations
|
|
277
|
+
if (focused) {
|
|
278
|
+
const maskedValues = bounds({
|
|
279
|
+
space: "absolute",
|
|
280
|
+
target: "fullscreen",
|
|
281
|
+
method: "size",
|
|
282
|
+
raw: true,
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
return {
|
|
286
|
+
overlayStyle: {
|
|
287
|
+
backgroundColor: "black",
|
|
288
|
+
opacity: interpolate(progress, [0, 1], [0, 0.5]),
|
|
289
|
+
},
|
|
290
|
+
contentStyle: {
|
|
291
|
+
transform: [
|
|
292
|
+
{ translateX: dragX },
|
|
293
|
+
{ translateY: dragY },
|
|
294
|
+
{ scale: dragXScale },
|
|
295
|
+
{ scale: dragYScale },
|
|
296
|
+
],
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
_ROOT_CONTAINER: {
|
|
300
|
+
transform: [
|
|
301
|
+
{ translateX: boundValues.translateX || 0 },
|
|
302
|
+
{ translateY: boundValues.translateY || 0 },
|
|
303
|
+
//@ts-expect-error
|
|
304
|
+
{ scale: boundValues.scale || 1 },
|
|
305
|
+
],
|
|
306
|
+
},
|
|
307
|
+
_ROOT_MASKED: {
|
|
308
|
+
width: maskedValues.width,
|
|
309
|
+
height: maskedValues.height,
|
|
310
|
+
transform: [
|
|
311
|
+
{ translateX: maskedValues.translateX || 0 },
|
|
312
|
+
{ translateY: maskedValues.translateY || 0 },
|
|
313
|
+
],
|
|
314
|
+
borderRadius: interpolate(progress, [0, 1], [0, 24]),
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return {
|
|
320
|
+
contentStyle: {
|
|
321
|
+
pointerEvents: current.gesture.isDismissing ? "none" : "auto",
|
|
322
|
+
},
|
|
323
|
+
[activeBoundId]: {
|
|
324
|
+
transform: [
|
|
325
|
+
{ translateX: dragX || 0 },
|
|
326
|
+
{ translateY: dragY || 0 },
|
|
327
|
+
{ translateX: boundValues.translateX || 0 },
|
|
328
|
+
{ translateY: boundValues.translateY || 0 },
|
|
329
|
+
{ scaleX: boundValues.scaleX || 1 },
|
|
330
|
+
{ scaleY: boundValues.scaleY || 1 },
|
|
331
|
+
{ scale: dragXScale },
|
|
332
|
+
{ scale: dragYScale },
|
|
333
|
+
],
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
},
|
|
337
|
+
transitionSpec: {
|
|
338
|
+
open: {
|
|
339
|
+
stiffness: 1500,
|
|
340
|
+
damping: 1000,
|
|
341
|
+
mass: 3,
|
|
342
|
+
overshootClamping: true,
|
|
343
|
+
restSpeedThreshold: 0.02,
|
|
344
|
+
},
|
|
345
|
+
close: {
|
|
346
|
+
stiffness: 1500,
|
|
347
|
+
damping: 1000,
|
|
348
|
+
mass: 3,
|
|
349
|
+
overshootClamping: true,
|
|
350
|
+
restSpeedThreshold: 0.02,
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
...config,
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export const SharedAppleMusic = (
|
|
358
|
+
config: Partial<ScreenTransitionConfig> = {},
|
|
359
|
+
): ScreenTransitionConfig => {
|
|
360
|
+
return {
|
|
361
|
+
enableTransitions: true,
|
|
362
|
+
gestureEnabled: true,
|
|
363
|
+
gestureDirection: ["vertical", "horizontal"],
|
|
364
|
+
gestureDrivesProgress: false,
|
|
365
|
+
screenStyleInterpolator: ({
|
|
366
|
+
bounds,
|
|
367
|
+
activeBoundId,
|
|
368
|
+
focused,
|
|
369
|
+
progress,
|
|
370
|
+
layouts: { screen },
|
|
371
|
+
current,
|
|
372
|
+
next,
|
|
373
|
+
}) => {
|
|
374
|
+
"worklet";
|
|
375
|
+
|
|
376
|
+
const normX = focused
|
|
377
|
+
? current.gesture.normalizedX
|
|
378
|
+
: (next?.gesture.normalizedX ?? 0);
|
|
379
|
+
const normY = focused
|
|
380
|
+
? current.gesture.normalizedY
|
|
381
|
+
: (next?.gesture.normalizedY ?? 0);
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* ===============================
|
|
385
|
+
* Animations for both bounds
|
|
386
|
+
* ===============================
|
|
387
|
+
*/
|
|
388
|
+
const dragX = interpolate(normX, [0, 1], [0, screen.width * 0.8]);
|
|
389
|
+
const dragY = interpolate(normY, [0, 1], [0, screen.height * 0.8]);
|
|
390
|
+
const dragXScale = interpolate(normX, [0, 1], [1, 0.75]);
|
|
391
|
+
const dragYScale = interpolate(normY, [0, 1], [1, 0.75]);
|
|
392
|
+
|
|
393
|
+
const boundValues = bounds({
|
|
394
|
+
method: focused ? "content" : "transform",
|
|
395
|
+
anchor: "top",
|
|
396
|
+
scaleMode: "uniform",
|
|
397
|
+
raw: true,
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
const opacity = interpolate(
|
|
401
|
+
progress,
|
|
402
|
+
[0, 0.35, 1, 1.25, 2],
|
|
403
|
+
[0, 1, 1, 1, 0],
|
|
404
|
+
"clamp",
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* ===============================
|
|
409
|
+
* Focused specific animations
|
|
410
|
+
* ===============================
|
|
411
|
+
*/
|
|
412
|
+
if (focused) {
|
|
413
|
+
const maskedValues = bounds({
|
|
414
|
+
space: "absolute",
|
|
415
|
+
method: "size",
|
|
416
|
+
target: "fullscreen",
|
|
417
|
+
raw: true,
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
// Apple Music style drop shadow that increases with drag magnitude
|
|
421
|
+
const dragMagnitude = Math.max(Math.abs(normX), Math.abs(normY));
|
|
422
|
+
const shadowOpacity = interpolate(
|
|
423
|
+
dragMagnitude,
|
|
424
|
+
[0, 1],
|
|
425
|
+
[0, 0.25],
|
|
426
|
+
"clamp",
|
|
427
|
+
);
|
|
428
|
+
const shadowRadius = interpolate(
|
|
429
|
+
dragMagnitude,
|
|
430
|
+
[0, 1],
|
|
431
|
+
[0, 24],
|
|
432
|
+
"clamp",
|
|
433
|
+
);
|
|
434
|
+
const shadowOffsetY = interpolate(
|
|
435
|
+
dragMagnitude,
|
|
436
|
+
[0, 1],
|
|
437
|
+
[0, 20],
|
|
438
|
+
"clamp",
|
|
439
|
+
);
|
|
440
|
+
const elevation = interpolate(dragMagnitude, [0, 1], [0, 24], "clamp");
|
|
441
|
+
|
|
442
|
+
const IOSShadowStyle = {
|
|
443
|
+
shadowColor: "#000",
|
|
444
|
+
shadowOpacity,
|
|
445
|
+
shadowRadius,
|
|
446
|
+
shadowOffset: { width: 0, height: shadowOffsetY },
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
const AndroidShadowStyle = {
|
|
450
|
+
elevation,
|
|
451
|
+
shadowColor: "#000",
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
return {
|
|
455
|
+
contentStyle: {
|
|
456
|
+
pointerEvents: current.animating ? "none" : "auto",
|
|
457
|
+
transform: [
|
|
458
|
+
{ translateX: dragX || 0 },
|
|
459
|
+
{ translateY: dragY || 0 },
|
|
460
|
+
{ scale: dragXScale },
|
|
461
|
+
{ scale: dragYScale },
|
|
462
|
+
],
|
|
463
|
+
opacity,
|
|
464
|
+
...(platform === "ios" ? IOSShadowStyle : AndroidShadowStyle),
|
|
465
|
+
},
|
|
466
|
+
_ROOT_CONTAINER: {
|
|
467
|
+
transform: [
|
|
468
|
+
{ translateX: boundValues.translateX || 0 },
|
|
469
|
+
{ translateY: boundValues.translateY || 0 },
|
|
470
|
+
//@ts-expect-error
|
|
471
|
+
{ scale: boundValues.scale || 1 },
|
|
472
|
+
],
|
|
473
|
+
},
|
|
474
|
+
_ROOT_MASKED: {
|
|
475
|
+
width: maskedValues.width,
|
|
476
|
+
height: maskedValues.height,
|
|
477
|
+
transform: [
|
|
478
|
+
{ translateX: maskedValues.translateX || 0 },
|
|
479
|
+
{ translateY: maskedValues.translateY || 0 },
|
|
480
|
+
],
|
|
481
|
+
borderRadius: interpolate(progress, [0, 1], [0, 24]),
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* ===============================
|
|
488
|
+
* Unfocused specific animations
|
|
489
|
+
* ===============================
|
|
490
|
+
*/
|
|
491
|
+
|
|
492
|
+
const scaledBoundTranslateX = (boundValues.translateX || 0) * dragXScale;
|
|
493
|
+
const scaledBoundTranslateY = (boundValues.translateY || 0) * dragYScale;
|
|
494
|
+
const scaledBoundScaleX = (boundValues.scaleX || 1) * dragXScale;
|
|
495
|
+
const scaledBoundScaleY = (boundValues.scaleY || 1) * dragYScale;
|
|
496
|
+
|
|
497
|
+
const contentScale = interpolate(progress, [1, 2], [1, 0.9], "clamp");
|
|
498
|
+
|
|
499
|
+
return {
|
|
500
|
+
[activeBoundId]: {
|
|
501
|
+
transform: [
|
|
502
|
+
{ translateX: dragX || 0 },
|
|
503
|
+
{ translateY: dragY || 0 },
|
|
504
|
+
{ translateX: scaledBoundTranslateX },
|
|
505
|
+
{ translateY: scaledBoundTranslateY },
|
|
506
|
+
{ scale: dragXScale },
|
|
507
|
+
{ scale: dragYScale },
|
|
508
|
+
{ scaleX: scaledBoundScaleX },
|
|
509
|
+
{ scaleY: scaledBoundScaleY },
|
|
510
|
+
],
|
|
511
|
+
opacity,
|
|
512
|
+
zIndex: current.animating ? 999 : -1,
|
|
513
|
+
position: "relative",
|
|
514
|
+
},
|
|
515
|
+
contentStyle: {
|
|
516
|
+
transform: [{ scale: contentScale }],
|
|
517
|
+
},
|
|
518
|
+
};
|
|
519
|
+
},
|
|
520
|
+
transitionSpec: {
|
|
521
|
+
open: {
|
|
522
|
+
stiffness: 1000,
|
|
523
|
+
damping: 500,
|
|
524
|
+
mass: 3,
|
|
525
|
+
overshootClamping: true,
|
|
526
|
+
restSpeedThreshold: 0.02,
|
|
527
|
+
},
|
|
528
|
+
close: {
|
|
529
|
+
stiffness: 600,
|
|
530
|
+
damping: 60,
|
|
531
|
+
mass: 3,
|
|
532
|
+
overshootClamping: false,
|
|
533
|
+
restSpeedThreshold: 0.02,
|
|
534
|
+
restDisplacementThreshold: 0.002,
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
...config,
|
|
538
|
+
};
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
export const SharedXImage = (
|
|
542
|
+
config: Partial<ScreenTransitionConfig> = {},
|
|
543
|
+
): ScreenTransitionConfig => {
|
|
544
|
+
return {
|
|
545
|
+
enableTransitions: true,
|
|
546
|
+
gestureEnabled: true,
|
|
547
|
+
gestureDirection: ["vertical", "vertical-inverted"],
|
|
548
|
+
gestureDrivesProgress: false,
|
|
549
|
+
screenStyleInterpolator: ({
|
|
550
|
+
focused,
|
|
551
|
+
activeBoundId,
|
|
552
|
+
bounds,
|
|
553
|
+
current,
|
|
554
|
+
layouts: { screen },
|
|
555
|
+
progress,
|
|
556
|
+
}) => {
|
|
557
|
+
"worklet";
|
|
558
|
+
|
|
559
|
+
// twitter doesn't animate the unfocused screen
|
|
560
|
+
if (!focused) return {};
|
|
561
|
+
|
|
562
|
+
const boundValues = bounds({ method: "transform", raw: true });
|
|
563
|
+
|
|
564
|
+
// content styles
|
|
565
|
+
const dragY = interpolate(
|
|
566
|
+
current.gesture.normalizedY,
|
|
567
|
+
[-1, 0, 1],
|
|
568
|
+
[-screen.height, 0, screen.height],
|
|
569
|
+
);
|
|
570
|
+
|
|
571
|
+
// dynamically changes direction based on the drag direction
|
|
572
|
+
const contentY = interpolate(
|
|
573
|
+
progress,
|
|
574
|
+
[0, 1],
|
|
575
|
+
[dragY >= 0 ? screen.height : -screen.height, 0],
|
|
576
|
+
);
|
|
577
|
+
|
|
578
|
+
const overlayClr = interpolateColor(
|
|
579
|
+
current.progress - Math.abs(current.gesture.normalizedY),
|
|
580
|
+
[0, 1],
|
|
581
|
+
["rgba(0,0,0,0)", "rgba(0,0,0,1)"],
|
|
582
|
+
);
|
|
583
|
+
|
|
584
|
+
const borderRadius = interpolate(current.progress, [0, 1], [12, 0]);
|
|
585
|
+
|
|
586
|
+
// bound styles - only enter animation
|
|
587
|
+
const x = !current.closing ? boundValues.translateX : 0;
|
|
588
|
+
const y = !current.closing ? boundValues.translateY : 0;
|
|
589
|
+
const scaleX = !current.closing ? boundValues.scaleX : 1;
|
|
590
|
+
const scaleY = !current.closing ? boundValues.scaleY : 1;
|
|
591
|
+
|
|
592
|
+
return {
|
|
593
|
+
[activeBoundId]: {
|
|
594
|
+
transform: [
|
|
595
|
+
{
|
|
596
|
+
translateX: x,
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
translateY: y,
|
|
600
|
+
},
|
|
601
|
+
{ scaleX: scaleX },
|
|
602
|
+
{ scaleY: scaleY },
|
|
603
|
+
],
|
|
604
|
+
borderRadius,
|
|
605
|
+
overflow: "hidden",
|
|
606
|
+
},
|
|
607
|
+
contentStyle: {
|
|
608
|
+
transform: [{ translateY: contentY }, { translateY: dragY }],
|
|
609
|
+
pointerEvents: current.animating ? "none" : "auto",
|
|
610
|
+
},
|
|
611
|
+
overlayStyle: {
|
|
612
|
+
backgroundColor: overlayClr,
|
|
613
|
+
},
|
|
614
|
+
};
|
|
615
|
+
},
|
|
616
|
+
transitionSpec: {
|
|
617
|
+
open: DefaultSpec,
|
|
618
|
+
close: DefaultSpec,
|
|
619
|
+
},
|
|
620
|
+
...config,
|
|
621
|
+
};
|
|
622
|
+
};
|
package/src/configs/specs.ts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { useAnimatedStyle } from "react-native-reanimated";
|
|
2
|
-
import {
|
|
2
|
+
import { useTransitionStyles } from "../../providers/transition-styles";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
id?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const EMPTY_STYLE = Object.freeze({});
|
|
3
9
|
|
|
4
10
|
/**
|
|
5
11
|
* This hook is used to get the associated styles for a given styleId.
|
|
6
12
|
* It is used to get the associated styles for a given styleId.
|
|
7
13
|
* It is used to get the associated styles for a given styleId.
|
|
8
14
|
*/
|
|
9
|
-
export const useAssociatedStyles = ({ id }:
|
|
10
|
-
const
|
|
11
|
-
_useScreenAnimation();
|
|
15
|
+
export const useAssociatedStyles = ({ id }: Props = {}) => {
|
|
16
|
+
const stylesMap = useTransitionStyles();
|
|
12
17
|
|
|
13
18
|
const associatedStyles = useAnimatedStyle(() => {
|
|
14
19
|
"worklet";
|
|
15
20
|
|
|
16
|
-
if (!id || !
|
|
17
|
-
return
|
|
21
|
+
if (!id || !stylesMap) {
|
|
22
|
+
return EMPTY_STYLE;
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
return
|
|
21
|
-
screenStyleInterpolator(screenInterpolatorProps.value)[id] || {
|
|
22
|
-
opacity: 1, // <-- This fixes flickering?? We'll have to deep dive this?? wtf
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
+
return stylesMap.value[id] || EMPTY_STYLE;
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
return { associatedStyles };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ParamListBase, RouteProp } from "@react-navigation/native";
|
|
2
|
+
import { useMemo } from "react";
|
|
2
3
|
import { useWindowDimensions } from "react-native";
|
|
3
4
|
import { type SharedValue, useDerivedValue } from "react-native-reanimated";
|
|
4
5
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
@@ -12,7 +13,7 @@ import type {
|
|
|
12
13
|
} from "../../types/animation";
|
|
13
14
|
import type { BoundEntry } from "../../types/bounds";
|
|
14
15
|
import type { NativeStackDescriptor } from "../../types/navigator";
|
|
15
|
-
import {
|
|
16
|
+
import { derivations } from "../../utils/animation/derivations";
|
|
16
17
|
|
|
17
18
|
type BuiltState = {
|
|
18
19
|
progress: SharedValue<number>;
|
|
@@ -22,7 +23,9 @@ type BuiltState = {
|
|
|
22
23
|
route: RouteProp<ParamListBase>;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
+
const EMPTY_BOUNDS = Object.freeze({}) as Record<string, BoundEntry>;
|
|
27
|
+
|
|
28
|
+
const FALLBACK: ScreenTransitionState = Object.freeze({
|
|
26
29
|
progress: 0,
|
|
27
30
|
closing: 0,
|
|
28
31
|
animating: 0,
|
|
@@ -38,62 +41,64 @@ const FALLBACK = Object.freeze({
|
|
|
38
41
|
route: {} as RouteProp<ParamListBase>,
|
|
39
42
|
});
|
|
40
43
|
|
|
41
|
-
const useBuildScreenTransitionState = (
|
|
42
|
-
descriptor: NativeStackDescriptor | undefined,
|
|
43
|
-
): BuiltState | undefined => {
|
|
44
|
-
const key = descriptor?.route.key;
|
|
45
|
-
if (!key) return undefined;
|
|
46
|
-
const progress = Animations.getAnimation(key, "progress");
|
|
47
|
-
const closing = Animations.getAnimation(key, "closing");
|
|
48
|
-
const animating = Animations.getAnimation(key, "animating");
|
|
49
|
-
const gesture = Gestures.getRouteGestures(key);
|
|
50
|
-
const route = descriptor?.route;
|
|
51
|
-
|
|
52
|
-
return { progress, closing, animating, gesture, route };
|
|
53
|
-
};
|
|
54
|
-
|
|
55
44
|
const unwrap = (
|
|
56
45
|
s: BuiltState | undefined,
|
|
57
46
|
key: string | undefined,
|
|
58
47
|
): ScreenTransitionState | undefined => {
|
|
59
48
|
"worklet";
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
49
|
+
if (!s || !key) return undefined;
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
progress: s.progress.value,
|
|
53
|
+
closing: s.closing.value,
|
|
54
|
+
animating: s.animating.value,
|
|
55
|
+
gesture: {
|
|
56
|
+
x: s.gesture.x.value,
|
|
57
|
+
y: s.gesture.y.value,
|
|
58
|
+
normalizedX: s.gesture.normalizedX.value,
|
|
59
|
+
normalizedY: s.gesture.normalizedY.value,
|
|
60
|
+
isDismissing: s.gesture.isDismissing.value,
|
|
61
|
+
isDragging: s.gesture.isDragging.value,
|
|
62
|
+
},
|
|
63
|
+
bounds: Bounds.getBounds(key) || EMPTY_BOUNDS,
|
|
64
|
+
route: s.route,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const useBuildScreenTransitionState = (
|
|
69
|
+
descriptor: NativeStackDescriptor | undefined,
|
|
70
|
+
): BuiltState | undefined => {
|
|
71
|
+
const key = descriptor?.route.key;
|
|
72
|
+
|
|
73
|
+
return useMemo(() => {
|
|
74
|
+
if (!key) return undefined;
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
progress: Animations.getAnimation(key, "progress"),
|
|
78
|
+
closing: Animations.getAnimation(key, "closing"),
|
|
79
|
+
animating: Animations.getAnimation(key, "animating"),
|
|
80
|
+
gesture: Gestures.getRouteGestures(key),
|
|
81
|
+
route: descriptor.route,
|
|
82
|
+
};
|
|
83
|
+
}, [key, descriptor?.route]);
|
|
77
84
|
};
|
|
78
85
|
|
|
79
86
|
export function _useScreenAnimation() {
|
|
87
|
+
const dimensions = useWindowDimensions();
|
|
88
|
+
const insets = useSafeAreaInsets();
|
|
89
|
+
|
|
80
90
|
const {
|
|
81
91
|
current: currentDescriptor,
|
|
82
92
|
next: nextDescriptor,
|
|
83
93
|
previous: previousDescriptor,
|
|
84
94
|
} = useKeys();
|
|
85
95
|
|
|
86
|
-
const dimensions = useWindowDimensions();
|
|
87
|
-
|
|
88
96
|
const currentAnimation = useBuildScreenTransitionState(currentDescriptor);
|
|
89
|
-
|
|
90
97
|
const nextAnimation = useBuildScreenTransitionState(nextDescriptor);
|
|
91
98
|
const prevAnimation = useBuildScreenTransitionState(previousDescriptor);
|
|
92
99
|
|
|
93
|
-
const insets = useSafeAreaInsets();
|
|
94
|
-
|
|
95
100
|
const screenInterpolatorProps = useDerivedValue<ScreenInterpolationProps>(
|
|
96
|
-
() => {
|
|
101
|
+
(): ScreenInterpolationProps => {
|
|
97
102
|
"worklet";
|
|
98
103
|
|
|
99
104
|
const previous = unwrap(prevAnimation, previousDescriptor?.route.key);
|
|
@@ -101,17 +106,10 @@ export function _useScreenAnimation() {
|
|
|
101
106
|
const current =
|
|
102
107
|
unwrap(currentAnimation, currentDescriptor?.route.key) ?? FALLBACK;
|
|
103
108
|
|
|
104
|
-
const progress
|
|
105
|
-
|
|
106
|
-
const focused = !next;
|
|
107
|
-
const activeBoundId = Bounds.getActiveBoundId() || "";
|
|
108
|
-
|
|
109
|
-
const bounds = buildBoundsAccessor({
|
|
110
|
-
activeBoundId,
|
|
109
|
+
const { progress, focused, activeBoundId, bounds } = derivations({
|
|
111
110
|
current,
|
|
112
|
-
previous,
|
|
113
111
|
next,
|
|
114
|
-
|
|
112
|
+
previous,
|
|
115
113
|
dimensions,
|
|
116
114
|
});
|
|
117
115
|
|
|
@@ -125,7 +123,7 @@ export function _useScreenAnimation() {
|
|
|
125
123
|
activeBoundId,
|
|
126
124
|
progress,
|
|
127
125
|
bounds,
|
|
128
|
-
}
|
|
126
|
+
};
|
|
129
127
|
},
|
|
130
128
|
);
|
|
131
129
|
|
|
@@ -135,6 +133,7 @@ export function _useScreenAnimation() {
|
|
|
135
133
|
|
|
136
134
|
return { screenInterpolatorProps, screenStyleInterpolator };
|
|
137
135
|
}
|
|
136
|
+
|
|
138
137
|
export function useScreenAnimation() {
|
|
139
138
|
const { screenInterpolatorProps } = _useScreenAnimation();
|
|
140
139
|
|