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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ScaledSize } from "react-native";
|
|
2
|
+
import type { MeasuredDimensions, StyleProps } from "react-native-reanimated";
|
|
2
3
|
import type { ScreenTransitionState } from "../../../types/animation";
|
|
3
4
|
import type { BoundsMethod } from "../../../types/bounds";
|
|
4
5
|
|
|
@@ -14,22 +15,137 @@ export type BoundsBuilderInitParams = {
|
|
|
14
15
|
dimensions: ScaledSize;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export type BoundsAnchor =
|
|
19
|
+
| "topLeading"
|
|
20
|
+
| "top"
|
|
21
|
+
| "topTrailing"
|
|
22
|
+
| "leading"
|
|
23
|
+
| "center"
|
|
24
|
+
| "trailing"
|
|
25
|
+
| "bottomLeading"
|
|
26
|
+
| "bottom"
|
|
27
|
+
| "bottomTrailing";
|
|
28
|
+
|
|
29
|
+
export type BoundsScaleMode = "match" | "none" | "uniform";
|
|
30
|
+
|
|
31
|
+
export type BoundsTarget = "bound" | "fullscreen" | MeasuredDimensions;
|
|
32
|
+
|
|
33
|
+
export type BoundsSpace = "relative" | "absolute";
|
|
34
|
+
|
|
35
|
+
export type BoundsComputeParams = BoundsBuilderInitParams;
|
|
36
|
+
|
|
37
|
+
export type RawSizeAbsoluteReturn = {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
translateX: number;
|
|
41
|
+
translateY: number;
|
|
22
42
|
};
|
|
23
43
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
44
|
+
export type RawSizeRelativeReturn = {
|
|
45
|
+
translateX: number;
|
|
46
|
+
translateY: number;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type RawTransformAbsoluteReturn = {
|
|
52
|
+
translateX: number;
|
|
53
|
+
translateY: number;
|
|
54
|
+
scaleX: number;
|
|
55
|
+
scaleY: number;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type RawTransformRelativeReturn = {
|
|
59
|
+
translateX: number;
|
|
60
|
+
translateY: number;
|
|
61
|
+
scaleX: number;
|
|
62
|
+
scaleY: number;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type RawContentReturn = {
|
|
66
|
+
translateX: number;
|
|
67
|
+
translateY: number;
|
|
68
|
+
scale: number;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Conditional return type based on options
|
|
72
|
+
export type BoundsReturnType<T extends BoundsBuilderOptions> =
|
|
73
|
+
T["raw"] extends true
|
|
74
|
+
? T["method"] extends "size"
|
|
75
|
+
? T["space"] extends "absolute"
|
|
76
|
+
? RawSizeAbsoluteReturn
|
|
77
|
+
: RawSizeRelativeReturn
|
|
78
|
+
: T["method"] extends "content"
|
|
79
|
+
? RawContentReturn
|
|
80
|
+
: T["space"] extends "absolute"
|
|
81
|
+
? RawTransformAbsoluteReturn
|
|
82
|
+
: RawTransformRelativeReturn
|
|
83
|
+
: StyleProps;
|
|
84
|
+
|
|
28
85
|
export type BoundsBuilderOptions = {
|
|
29
|
-
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Use `content.scaleMode` instead.
|
|
88
|
+
*/
|
|
30
89
|
toFullscreen?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use `content.anchor` instead.
|
|
92
|
+
*/
|
|
31
93
|
absolute?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* @deprecated Use `content.anchor` instead.
|
|
96
|
+
*/
|
|
32
97
|
relative?: boolean;
|
|
33
|
-
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated Use `scaleMode` instead.
|
|
100
|
+
*/
|
|
34
101
|
contentScaleMode?: "aspectFill" | "aspectFit" | "auto";
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The ID of the bound to compute bounds for. If not provided, uses the active bound ID.
|
|
105
|
+
*/
|
|
106
|
+
id?: string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The method to use to compute the bounds.
|
|
110
|
+
*
|
|
111
|
+
* - "transform": translates and scales (scaleX/scaleY), no width/height size
|
|
112
|
+
* - "size": translates and sizes (width/height), no scaleX/scaleY
|
|
113
|
+
* - "content": screen-level content transform that aligns the destination screen
|
|
114
|
+
* so the target bound matches the source at progress start
|
|
115
|
+
* @default "transform"
|
|
116
|
+
*/
|
|
117
|
+
method?: BoundsMethod;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The space to use to compute the bounds.
|
|
121
|
+
*
|
|
122
|
+
* - "relative": the bounds are computed with relative deltas, constrained by parent layout
|
|
123
|
+
* - "absolute": the bounds are computed with absolute coordinates, unconstrained by parent layout
|
|
124
|
+
* @default "relative"
|
|
125
|
+
*/
|
|
126
|
+
space?: BoundsSpace;
|
|
127
|
+
/**
|
|
128
|
+
* Whether the bound should target the screen or the bound.
|
|
129
|
+
* @default "bound"
|
|
130
|
+
*/
|
|
131
|
+
target?: BoundsTarget;
|
|
132
|
+
/**
|
|
133
|
+
* The gesture offsets to apply to the bounds.
|
|
134
|
+
*/
|
|
135
|
+
gestures?: { x?: number; y?: number };
|
|
136
|
+
/**
|
|
137
|
+
* How the bounds should be scaled between each other.
|
|
138
|
+
* @default "match"
|
|
139
|
+
*/
|
|
140
|
+
scaleMode?: BoundsScaleMode;
|
|
141
|
+
/**
|
|
142
|
+
* Where the bounds should be anchored between each other.
|
|
143
|
+
* @default "center"
|
|
144
|
+
*/
|
|
145
|
+
anchor?: BoundsAnchor;
|
|
146
|
+
/**
|
|
147
|
+
* If true, the raw values will be returned instead of the computed values.
|
|
148
|
+
* @default false
|
|
149
|
+
*/
|
|
150
|
+
raw?: boolean;
|
|
35
151
|
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { ScaledSize } from "react-native";
|
|
2
|
+
import type { MeasuredDimensions } from "react-native-reanimated";
|
|
3
|
+
import type { BoundsAnchor, BoundsScaleMode } from "../_types/builder";
|
|
4
|
+
import type {
|
|
5
|
+
ContentTransformGeometry,
|
|
6
|
+
RelativeGeometry,
|
|
7
|
+
} from "../_types/geometry";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get the anchor point coordinates for a given bound
|
|
11
|
+
*/
|
|
12
|
+
function getAnchorPoint(
|
|
13
|
+
bounds: MeasuredDimensions,
|
|
14
|
+
anchor: BoundsAnchor = "center",
|
|
15
|
+
): { x: number; y: number } {
|
|
16
|
+
"worklet";
|
|
17
|
+
|
|
18
|
+
const { pageX, pageY, width, height } = bounds;
|
|
19
|
+
|
|
20
|
+
switch (anchor) {
|
|
21
|
+
case "topLeading":
|
|
22
|
+
return { x: pageX, y: pageY };
|
|
23
|
+
case "top":
|
|
24
|
+
return { x: pageX + width / 2, y: pageY };
|
|
25
|
+
case "topTrailing":
|
|
26
|
+
return { x: pageX + width, y: pageY };
|
|
27
|
+
case "leading":
|
|
28
|
+
return { x: pageX, y: pageY + height / 2 };
|
|
29
|
+
case "center":
|
|
30
|
+
return { x: pageX + width / 2, y: pageY + height / 2 };
|
|
31
|
+
case "trailing":
|
|
32
|
+
return { x: pageX + width, y: pageY + height / 2 };
|
|
33
|
+
case "bottomLeading":
|
|
34
|
+
return { x: pageX, y: pageY + height };
|
|
35
|
+
case "bottom":
|
|
36
|
+
return { x: pageX + width / 2, y: pageY + height };
|
|
37
|
+
case "bottomTrailing":
|
|
38
|
+
return { x: pageX + width, y: pageY + height };
|
|
39
|
+
default:
|
|
40
|
+
// Default to center
|
|
41
|
+
return { x: pageX + width / 2, y: pageY + height / 2 };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Relative geometry between start/end bounds.
|
|
47
|
+
*/
|
|
48
|
+
export function computeRelativeGeometry({
|
|
49
|
+
start,
|
|
50
|
+
end,
|
|
51
|
+
entering,
|
|
52
|
+
anchor = "center",
|
|
53
|
+
scaleMode = "match",
|
|
54
|
+
}: {
|
|
55
|
+
start: MeasuredDimensions;
|
|
56
|
+
end: MeasuredDimensions;
|
|
57
|
+
entering: boolean;
|
|
58
|
+
anchor?: BoundsAnchor;
|
|
59
|
+
scaleMode?: BoundsScaleMode;
|
|
60
|
+
}): RelativeGeometry {
|
|
61
|
+
"worklet";
|
|
62
|
+
|
|
63
|
+
let scaleX: number;
|
|
64
|
+
let scaleY: number;
|
|
65
|
+
|
|
66
|
+
if (scaleMode === "none") {
|
|
67
|
+
scaleX = 1;
|
|
68
|
+
scaleY = 1;
|
|
69
|
+
} else if (scaleMode === "uniform") {
|
|
70
|
+
const sx = start.width / end.width;
|
|
71
|
+
const sy = start.height / end.height;
|
|
72
|
+
|
|
73
|
+
const startAspect = start.width / start.height;
|
|
74
|
+
const endAspect = end.width / end.height;
|
|
75
|
+
const aspectDifference = Math.abs(startAspect - endAspect);
|
|
76
|
+
|
|
77
|
+
const scale = aspectDifference < 0.1 ? Math.max(sx, sy) : Math.min(sx, sy);
|
|
78
|
+
scaleX = scale;
|
|
79
|
+
scaleY = scale;
|
|
80
|
+
} else {
|
|
81
|
+
scaleX = start.width / end.width;
|
|
82
|
+
scaleY = start.height / end.height;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const startAnchor = getAnchorPoint(start, anchor);
|
|
86
|
+
const endAnchor = getAnchorPoint(end, anchor);
|
|
87
|
+
|
|
88
|
+
const endCenter = getAnchorPoint(end, "center");
|
|
89
|
+
const anchorOffsetX = endAnchor.x - endCenter.x;
|
|
90
|
+
const anchorOffsetY = endAnchor.y - endCenter.y;
|
|
91
|
+
|
|
92
|
+
const dx = startAnchor.x - endCenter.x - anchorOffsetX * scaleX;
|
|
93
|
+
const dy = startAnchor.y - endCenter.y - anchorOffsetY * scaleY;
|
|
94
|
+
|
|
95
|
+
return { dx, dy, scaleX, scaleY, entering };
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Computes the transform to apply to the entire destination screen so that
|
|
99
|
+
* its bound (end) matches the source bound (start) at progress start.
|
|
100
|
+
*/
|
|
101
|
+
export function computeContentTransformGeometry({
|
|
102
|
+
start,
|
|
103
|
+
end,
|
|
104
|
+
entering,
|
|
105
|
+
dimensions,
|
|
106
|
+
anchor = "center",
|
|
107
|
+
scaleMode = "uniform",
|
|
108
|
+
}: {
|
|
109
|
+
start: MeasuredDimensions;
|
|
110
|
+
end: MeasuredDimensions;
|
|
111
|
+
entering: boolean;
|
|
112
|
+
dimensions: ScaledSize;
|
|
113
|
+
anchor?: BoundsAnchor;
|
|
114
|
+
scaleMode?: BoundsScaleMode;
|
|
115
|
+
}): ContentTransformGeometry {
|
|
116
|
+
"worklet";
|
|
117
|
+
|
|
118
|
+
// Calculate scale based on how much we need to scale the screen
|
|
119
|
+
// so that the end element matches the start element's size
|
|
120
|
+
let s: number;
|
|
121
|
+
|
|
122
|
+
if (scaleMode === "none") {
|
|
123
|
+
s = 1;
|
|
124
|
+
} else if (scaleMode === "uniform") {
|
|
125
|
+
const sx = start.width / end.width;
|
|
126
|
+
const sy = start.height / end.height;
|
|
127
|
+
|
|
128
|
+
const startAspect = start.width / start.height;
|
|
129
|
+
const endAspect = end.width / end.height;
|
|
130
|
+
const aspectDifference = Math.abs(startAspect - endAspect);
|
|
131
|
+
|
|
132
|
+
s = aspectDifference < 0.1 ? Math.max(sx, sy) : Math.min(sx, sy);
|
|
133
|
+
} else {
|
|
134
|
+
// For "match" mode on full screen, we need uniform scale
|
|
135
|
+
const sx = start.width / end.width;
|
|
136
|
+
const sy = start.height / end.height;
|
|
137
|
+
s = (sx + sy) / 2;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Get anchor points
|
|
141
|
+
const startAnchor = getAnchorPoint(start, anchor);
|
|
142
|
+
const endAnchor = getAnchorPoint(end, anchor);
|
|
143
|
+
|
|
144
|
+
// Screen center (scaling origin)
|
|
145
|
+
const screenCenterX = dimensions.width / 2;
|
|
146
|
+
const screenCenterY = dimensions.height / 2;
|
|
147
|
+
|
|
148
|
+
// How far the end anchor is from screen center
|
|
149
|
+
const endOffsetFromScreenCenterX = endAnchor.x - screenCenterX;
|
|
150
|
+
const endOffsetFromScreenCenterY = endAnchor.y - screenCenterY;
|
|
151
|
+
|
|
152
|
+
// After scaling the screen from its center, the end anchor moves to:
|
|
153
|
+
const scaledEndAnchorX = screenCenterX + endOffsetFromScreenCenterX * s;
|
|
154
|
+
const scaledEndAnchorY = screenCenterY + endOffsetFromScreenCenterY * s;
|
|
155
|
+
|
|
156
|
+
// Translation to align scaled end anchor with start anchor
|
|
157
|
+
const tx = startAnchor.x - scaledEndAnchorX;
|
|
158
|
+
const ty = startAnchor.y - scaledEndAnchorY;
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
tx,
|
|
162
|
+
ty,
|
|
163
|
+
s,
|
|
164
|
+
entering,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { BoundEntry } from "../../../types/bounds";
|
|
2
|
+
|
|
3
|
+
import type { GetBoundsParams } from "../_types/get-bounds";
|
|
4
|
+
|
|
5
|
+
const fallbackBounds = {
|
|
6
|
+
bounds: {
|
|
7
|
+
width: 0,
|
|
8
|
+
height: 0,
|
|
9
|
+
x: 0,
|
|
10
|
+
y: 0,
|
|
11
|
+
pageX: 0,
|
|
12
|
+
pageY: 0,
|
|
13
|
+
},
|
|
14
|
+
styles: {},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const getBounds = (props: GetBoundsParams): BoundEntry => {
|
|
18
|
+
"worklet";
|
|
19
|
+
const boundId = props.id;
|
|
20
|
+
const phase = props.phase;
|
|
21
|
+
|
|
22
|
+
if (phase && boundId) {
|
|
23
|
+
const phaseMap = {
|
|
24
|
+
current: props.current?.bounds[boundId],
|
|
25
|
+
next: props.next?.bounds[boundId],
|
|
26
|
+
previous: props.previous?.bounds[boundId],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const phaseBounds = phaseMap[phase];
|
|
30
|
+
|
|
31
|
+
if (!phaseBounds) {
|
|
32
|
+
return fallbackBounds;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
bounds: phaseBounds.bounds,
|
|
37
|
+
styles: phaseBounds?.styles,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!props.next && boundId) {
|
|
42
|
+
const previousBounds = props.previous?.bounds[boundId];
|
|
43
|
+
|
|
44
|
+
return previousBounds || fallbackBounds;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (boundId) {
|
|
48
|
+
const nextBounds = props.next?.bounds[boundId];
|
|
49
|
+
|
|
50
|
+
return nextBounds || fallbackBounds;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return fallbackBounds;
|
|
54
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MeasuredDimensions } from "react-native-reanimated";
|
|
2
|
+
import { Bounds } from "../../../stores/bounds";
|
|
3
|
+
|
|
4
|
+
export const isBoundsEqual = ({
|
|
5
|
+
measured,
|
|
6
|
+
key,
|
|
7
|
+
sharedBoundTag,
|
|
8
|
+
}: {
|
|
9
|
+
measured: MeasuredDimensions;
|
|
10
|
+
key: string;
|
|
11
|
+
sharedBoundTag: string;
|
|
12
|
+
}) => {
|
|
13
|
+
"worklet";
|
|
14
|
+
const existing = Bounds.getBounds(key)?.[sharedBoundTag]?.bounds;
|
|
15
|
+
return (
|
|
16
|
+
existing &&
|
|
17
|
+
existing.width === measured.width &&
|
|
18
|
+
existing.height === measured.height &&
|
|
19
|
+
existing.pageX === measured.pageX &&
|
|
20
|
+
existing.pageY === measured.pageY &&
|
|
21
|
+
existing.x === measured.x &&
|
|
22
|
+
existing.y === measured.y
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
interpolate,
|
|
3
|
+
type MeasuredDimensions,
|
|
4
|
+
type StyleProps,
|
|
5
|
+
} from "react-native-reanimated";
|
|
6
|
+
import type { BoundsBuilderOptions } from "../_types/builder";
|
|
7
|
+
import type {
|
|
8
|
+
ContentTransformGeometry,
|
|
9
|
+
RelativeGeometry,
|
|
10
|
+
} from "../_types/geometry";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Element-level (relative) params shared by size/transform composers.
|
|
14
|
+
* - start/end: absolute window bounds of the element in previous/next phases
|
|
15
|
+
* - geometry: relative deltas and scales between start/end (dx, dy, scaleX, scaleY, ...)
|
|
16
|
+
* - interp: function to interpolate between numbers using the correct progress range
|
|
17
|
+
*/
|
|
18
|
+
export type ElementComposeParams = {
|
|
19
|
+
start: MeasuredDimensions;
|
|
20
|
+
end: MeasuredDimensions;
|
|
21
|
+
geometry: RelativeGeometry;
|
|
22
|
+
progress: number;
|
|
23
|
+
ranges: readonly [number, number];
|
|
24
|
+
computeOptions: BoundsBuilderOptions;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Screen-level content transform params (for aligning destination bound to source).
|
|
29
|
+
* - start/end: absolute window bounds for the shared id (source/destination)
|
|
30
|
+
* - geometry: precomputed screen-level tx/ty/sx/sy plus ranges/entering
|
|
31
|
+
* - interp: function to interpolate between numbers using the correct progress range
|
|
32
|
+
*/
|
|
33
|
+
export type ContentComposeParams = {
|
|
34
|
+
start: MeasuredDimensions;
|
|
35
|
+
end: MeasuredDimensions;
|
|
36
|
+
geometry: ContentTransformGeometry;
|
|
37
|
+
progress: number;
|
|
38
|
+
ranges: readonly [number, number];
|
|
39
|
+
computeOptions: BoundsBuilderOptions;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export function composeSizeAbsolute(params: ElementComposeParams): StyleProps {
|
|
43
|
+
"worklet";
|
|
44
|
+
const { start, end, geometry, progress, ranges, computeOptions } = params;
|
|
45
|
+
|
|
46
|
+
const width = geometry.entering
|
|
47
|
+
? interpolate(progress, ranges, [start.width, end.width])
|
|
48
|
+
: interpolate(progress, ranges, [end.width, start.width]);
|
|
49
|
+
const height = geometry.entering
|
|
50
|
+
? interpolate(progress, ranges, [start.height, end.height])
|
|
51
|
+
: interpolate(progress, ranges, [end.height, start.height]);
|
|
52
|
+
|
|
53
|
+
const translateX = geometry.entering
|
|
54
|
+
? interpolate(progress, ranges, [start.pageX, end.pageX])
|
|
55
|
+
: interpolate(progress, ranges, [end.pageX, start.pageX]);
|
|
56
|
+
const translateY = geometry.entering
|
|
57
|
+
? interpolate(progress, ranges, [start.pageY, end.pageY])
|
|
58
|
+
: interpolate(progress, ranges, [end.pageY, start.pageY]);
|
|
59
|
+
|
|
60
|
+
if (computeOptions.raw) {
|
|
61
|
+
return {
|
|
62
|
+
width,
|
|
63
|
+
height,
|
|
64
|
+
translateX,
|
|
65
|
+
translateY,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
width,
|
|
71
|
+
height,
|
|
72
|
+
transform: [{ translateX }, { translateY }],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function composeSizeRelative(params: ElementComposeParams): StyleProps {
|
|
77
|
+
"worklet";
|
|
78
|
+
const { start, end, geometry, progress, ranges, computeOptions } = params;
|
|
79
|
+
|
|
80
|
+
const translateX = geometry.entering
|
|
81
|
+
? interpolate(progress, ranges, [geometry.dx, 0])
|
|
82
|
+
: interpolate(progress, ranges, [0, -geometry.dx]);
|
|
83
|
+
|
|
84
|
+
const translateY = geometry.entering
|
|
85
|
+
? interpolate(progress, ranges, [geometry.dy, 0])
|
|
86
|
+
: interpolate(progress, ranges, [0, -geometry.dy]);
|
|
87
|
+
|
|
88
|
+
const width = geometry.entering
|
|
89
|
+
? interpolate(progress, ranges, [start.width, end.width])
|
|
90
|
+
: interpolate(progress, ranges, [end.width, start.width]);
|
|
91
|
+
|
|
92
|
+
const height = geometry.entering
|
|
93
|
+
? interpolate(progress, ranges, [start.height, end.height])
|
|
94
|
+
: interpolate(progress, ranges, [end.height, start.height]);
|
|
95
|
+
|
|
96
|
+
if (computeOptions.raw) {
|
|
97
|
+
return {
|
|
98
|
+
translateX,
|
|
99
|
+
translateY,
|
|
100
|
+
width,
|
|
101
|
+
height,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
transform: [{ translateX }, { translateY }],
|
|
107
|
+
width,
|
|
108
|
+
height,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function composeTransformAbsolute(
|
|
113
|
+
params: ElementComposeParams,
|
|
114
|
+
): StyleProps {
|
|
115
|
+
"worklet";
|
|
116
|
+
const { start, end, geometry, progress, ranges, computeOptions } = params;
|
|
117
|
+
|
|
118
|
+
const translateX = geometry.entering
|
|
119
|
+
? interpolate(progress, ranges, [start.pageX, end.pageX])
|
|
120
|
+
: interpolate(progress, ranges, [end.pageX, start.pageX]);
|
|
121
|
+
const translateY = geometry.entering
|
|
122
|
+
? interpolate(progress, ranges, [start.pageY, end.pageY])
|
|
123
|
+
: interpolate(progress, ranges, [end.pageY, start.pageY]);
|
|
124
|
+
const scaleX = geometry.entering
|
|
125
|
+
? interpolate(progress, ranges, [geometry.scaleX, 1])
|
|
126
|
+
: interpolate(progress, ranges, [1, 1 / geometry.scaleX]);
|
|
127
|
+
const scaleY = geometry.entering
|
|
128
|
+
? interpolate(progress, ranges, [geometry.scaleY, 1])
|
|
129
|
+
: interpolate(progress, ranges, [1, 1 / geometry.scaleY]);
|
|
130
|
+
|
|
131
|
+
if (computeOptions.raw) {
|
|
132
|
+
return {
|
|
133
|
+
translateX,
|
|
134
|
+
translateY,
|
|
135
|
+
scaleX,
|
|
136
|
+
scaleY,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
transform: [{ translateX }, { translateY }, { scaleX }, { scaleY }],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function composeTransformRelative(
|
|
146
|
+
params: ElementComposeParams,
|
|
147
|
+
): StyleProps {
|
|
148
|
+
"worklet";
|
|
149
|
+
const { geometry, computeOptions, progress, ranges } = params;
|
|
150
|
+
|
|
151
|
+
const translateX = geometry.entering
|
|
152
|
+
? interpolate(progress, ranges, [geometry.dx, 0])
|
|
153
|
+
: interpolate(progress, ranges, [0, -geometry.dx]);
|
|
154
|
+
const translateY = geometry.entering
|
|
155
|
+
? interpolate(progress, ranges, [geometry.dy, 0])
|
|
156
|
+
: interpolate(progress, ranges, [0, -geometry.dy]);
|
|
157
|
+
const scaleX = geometry.entering
|
|
158
|
+
? interpolate(progress, ranges, [geometry.scaleX, 1])
|
|
159
|
+
: interpolate(progress, ranges, [1, 1 / geometry.scaleX]);
|
|
160
|
+
const scaleY = geometry.entering
|
|
161
|
+
? interpolate(progress, ranges, [geometry.scaleY, 1])
|
|
162
|
+
: interpolate(progress, ranges, [1, 1 / geometry.scaleY]);
|
|
163
|
+
|
|
164
|
+
if (computeOptions.raw) {
|
|
165
|
+
return {
|
|
166
|
+
translateX,
|
|
167
|
+
translateY,
|
|
168
|
+
scaleX,
|
|
169
|
+
scaleY,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
transform: [
|
|
175
|
+
{ translateX: computeOptions.gestures?.x ?? 0 },
|
|
176
|
+
{ translateY: computeOptions.gestures?.y ?? 0 },
|
|
177
|
+
{ translateX },
|
|
178
|
+
{ translateY },
|
|
179
|
+
{ scaleX },
|
|
180
|
+
{ scaleY },
|
|
181
|
+
],
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function composeContentStyle(params: ContentComposeParams): StyleProps {
|
|
186
|
+
"worklet";
|
|
187
|
+
const {
|
|
188
|
+
geometry,
|
|
189
|
+
progress,
|
|
190
|
+
ranges,
|
|
191
|
+
computeOptions: { raw },
|
|
192
|
+
} = params;
|
|
193
|
+
const { s, tx, ty, entering } = geometry;
|
|
194
|
+
|
|
195
|
+
const translateX = entering
|
|
196
|
+
? interpolate(progress, ranges, [tx, 0])
|
|
197
|
+
: interpolate(progress, ranges, [0, tx]);
|
|
198
|
+
const translateY = entering
|
|
199
|
+
? interpolate(progress, ranges, [ty, 0])
|
|
200
|
+
: interpolate(progress, ranges, [0, ty]);
|
|
201
|
+
const scale = entering
|
|
202
|
+
? interpolate(progress, ranges, [s, 1])
|
|
203
|
+
: interpolate(progress, ranges, [1, s]);
|
|
204
|
+
|
|
205
|
+
if (raw) {
|
|
206
|
+
return {
|
|
207
|
+
translateX,
|
|
208
|
+
translateY,
|
|
209
|
+
scale,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
transform: [{ translateX }, { translateY }, { scale }],
|
|
215
|
+
};
|
|
216
|
+
}
|
|
@@ -1,25 +1,40 @@
|
|
|
1
|
-
import type { ScaledSize } from
|
|
2
|
-
import type { MeasuredDimensions } from
|
|
3
|
-
import type { Complete } from
|
|
4
|
-
import type { BoundsBuilderOptions } from
|
|
1
|
+
import type { ScaledSize } from "react-native";
|
|
2
|
+
import type { MeasuredDimensions } from "react-native-reanimated";
|
|
3
|
+
import type { Complete } from "../../types/utils";
|
|
4
|
+
import type { BoundsBuilderOptions } from "./_types/builder";
|
|
5
5
|
|
|
6
|
-
export const FULLSCREEN_DIMENSIONS = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
export const FULLSCREEN_DIMENSIONS = (
|
|
7
|
+
dimensions: ScaledSize,
|
|
8
|
+
): MeasuredDimensions => {
|
|
9
|
+
"worklet";
|
|
10
|
+
return {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0,
|
|
13
|
+
pageX: 0,
|
|
14
|
+
pageY: 0,
|
|
15
|
+
width: dimensions.width,
|
|
16
|
+
height: dimensions.height,
|
|
17
|
+
};
|
|
16
18
|
};
|
|
17
19
|
|
|
18
|
-
export const DEFAULT_BUILDER_OPTIONS: Complete<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
export const DEFAULT_BUILDER_OPTIONS: Complete<
|
|
21
|
+
Omit<BoundsBuilderOptions, "id">
|
|
22
|
+
> = Object.freeze({
|
|
23
|
+
gestures: { x: 0, y: 0 },
|
|
24
|
+
toFullscreen: false,
|
|
25
|
+
absolute: false,
|
|
26
|
+
relative: true,
|
|
27
|
+
method: "transform",
|
|
28
|
+
contentScaleMode: "auto",
|
|
29
|
+
space: "relative",
|
|
30
|
+
target: "bound",
|
|
31
|
+
/**
|
|
32
|
+
* Controls how elements scale during transitions
|
|
33
|
+
* - "match": Scale to match destination bounds (default for center anchor)
|
|
34
|
+
* - "none": No scaling, maintain original size (default for non-center anchors)
|
|
35
|
+
* - "uniform": Scale uniformly (maintain aspect ratio)
|
|
36
|
+
*/
|
|
37
|
+
scaleMode: "match",
|
|
38
|
+
anchor: "center",
|
|
39
|
+
raw: false,
|
|
40
|
+
} as const);
|