react-native-screen-transitions 3.6.0-alpha.3 → 3.6.0-beta.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/lib/commonjs/shared/components/screen-container/layers/content.js +1 -11
- package/lib/commonjs/shared/components/screen-container/layers/content.js.map +1 -1
- package/lib/commonjs/shared/constants.js +2 -1
- package/lib/commonjs/shared/constants.js.map +1 -1
- package/lib/commonjs/shared/hooks/navigation/use-stack.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/build-screen-transition-options.js +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/build-screen-transition-options.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/hydrate-transition-state/index.js +10 -3
- package/lib/commonjs/shared/providers/screen/animation/helpers/hydrate-transition-state/index.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/hydrate-transition-state/snap-points.js +2 -2
- package/lib/commonjs/shared/providers/screen/animation/helpers/hydrate-transition-state/snap-points.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/pipeline.js +7 -2
- package/lib/commonjs/shared/providers/screen/animation/helpers/pipeline.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/selected-interpolator-options.js +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/selected-interpolator-options.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/stack-progress.js +25 -0
- package/lib/commonjs/shared/providers/screen/animation/helpers/stack-progress.js.map +1 -0
- package/lib/commonjs/shared/providers/screen/animation/helpers/use-build-transition-state.js +1 -0
- package/lib/commonjs/shared/providers/screen/animation/helpers/use-build-transition-state.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/gestures/shared/policy.js +13 -4
- package/lib/commonjs/shared/providers/screen/gestures/shared/policy.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/options/helpers.js +9 -4
- package/lib/commonjs/shared/providers/screen/options/helpers.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/styles/helpers/resolve-slot-styles/index.js +94 -13
- package/lib/commonjs/shared/providers/screen/styles/helpers/resolve-slot-styles/index.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/styles/helpers/resolve-slot-styles/materialize-slot.js +4 -1
- package/lib/commonjs/shared/providers/screen/styles/helpers/resolve-slot-styles/materialize-slot.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/styles/helpers/resolve-slot-styles/types.js +4 -0
- package/lib/commonjs/shared/providers/screen/styles/hooks/use-interpolated-style-maps.js +85 -28
- package/lib/commonjs/shared/providers/screen/styles/hooks/use-interpolated-style-maps.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/styles/hooks/use-resolved-slot-style-map.js +5 -4
- package/lib/commonjs/shared/providers/screen/styles/hooks/use-resolved-slot-style-map.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/styles/styles.provider.js +2 -2
- package/lib/commonjs/shared/providers/screen/styles/styles.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/stack/direct.provider.js +1 -3
- package/lib/commonjs/shared/providers/stack/direct.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/stack/helpers/use-stack-derived.js +2 -12
- package/lib/commonjs/shared/providers/stack/helpers/use-stack-derived.js.map +1 -1
- package/lib/commonjs/shared/providers/stack/managed.provider.js +1 -3
- package/lib/commonjs/shared/providers/stack/managed.provider.js.map +1 -1
- package/lib/commonjs/shared/stores/animation.store.js +5 -3
- package/lib/commonjs/shared/stores/animation.store.js.map +1 -1
- package/lib/commonjs/shared/stores/bounds/internals/links.js +18 -3
- package/lib/commonjs/shared/stores/bounds/internals/links.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/navigation/reveal/build.js +0 -2
- package/lib/commonjs/shared/utils/bounds/navigation/reveal/build.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/navigation/zoom/build.js +5 -2
- package/lib/commonjs/shared/utils/bounds/navigation/zoom/build.js.map +1 -1
- package/lib/module/shared/components/screen-container/layers/content.js +3 -13
- package/lib/module/shared/components/screen-container/layers/content.js.map +1 -1
- package/lib/module/shared/constants.js +1 -0
- package/lib/module/shared/constants.js.map +1 -1
- package/lib/module/shared/hooks/navigation/use-stack.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/build-screen-transition-options.js +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/build-screen-transition-options.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/hydrate-transition-state/index.js +10 -3
- package/lib/module/shared/providers/screen/animation/helpers/hydrate-transition-state/index.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/hydrate-transition-state/snap-points.js +2 -2
- package/lib/module/shared/providers/screen/animation/helpers/hydrate-transition-state/snap-points.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/pipeline.js +7 -2
- package/lib/module/shared/providers/screen/animation/helpers/pipeline.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/selected-interpolator-options.js +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/selected-interpolator-options.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/stack-progress.js +20 -0
- package/lib/module/shared/providers/screen/animation/helpers/stack-progress.js.map +1 -0
- package/lib/module/shared/providers/screen/animation/helpers/use-build-transition-state.js +1 -0
- package/lib/module/shared/providers/screen/animation/helpers/use-build-transition-state.js.map +1 -1
- package/lib/module/shared/providers/screen/gestures/shared/policy.js +14 -5
- package/lib/module/shared/providers/screen/gestures/shared/policy.js.map +1 -1
- package/lib/module/shared/providers/screen/options/helpers.js +10 -5
- package/lib/module/shared/providers/screen/options/helpers.js.map +1 -1
- package/lib/module/shared/providers/screen/styles/helpers/resolve-slot-styles/index.js +95 -14
- package/lib/module/shared/providers/screen/styles/helpers/resolve-slot-styles/index.js.map +1 -1
- package/lib/module/shared/providers/screen/styles/helpers/resolve-slot-styles/materialize-slot.js +4 -1
- package/lib/module/shared/providers/screen/styles/helpers/resolve-slot-styles/materialize-slot.js.map +1 -1
- package/lib/module/shared/providers/screen/styles/helpers/resolve-slot-styles/types.js +2 -0
- package/lib/module/shared/providers/screen/styles/hooks/use-interpolated-style-maps.js +84 -28
- package/lib/module/shared/providers/screen/styles/hooks/use-interpolated-style-maps.js.map +1 -1
- package/lib/module/shared/providers/screen/styles/hooks/use-resolved-slot-style-map.js +5 -4
- package/lib/module/shared/providers/screen/styles/hooks/use-resolved-slot-style-map.js.map +1 -1
- package/lib/module/shared/providers/screen/styles/styles.provider.js +2 -2
- package/lib/module/shared/providers/screen/styles/styles.provider.js.map +1 -1
- package/lib/module/shared/providers/stack/direct.provider.js +1 -3
- package/lib/module/shared/providers/stack/direct.provider.js.map +1 -1
- package/lib/module/shared/providers/stack/helpers/use-stack-derived.js +2 -12
- package/lib/module/shared/providers/stack/helpers/use-stack-derived.js.map +1 -1
- package/lib/module/shared/providers/stack/managed.provider.js +1 -3
- package/lib/module/shared/providers/stack/managed.provider.js.map +1 -1
- package/lib/module/shared/stores/animation.store.js +5 -3
- package/lib/module/shared/stores/animation.store.js.map +1 -1
- package/lib/module/shared/stores/bounds/internals/links.js +18 -3
- package/lib/module/shared/stores/bounds/internals/links.js.map +1 -1
- package/lib/module/shared/types/animation.types.js +2 -1
- package/lib/module/shared/types/animation.types.js.map +1 -1
- package/lib/module/shared/utils/bounds/navigation/reveal/build.js +0 -2
- package/lib/module/shared/utils/bounds/navigation/reveal/build.js.map +1 -1
- package/lib/module/shared/utils/bounds/navigation/zoom/build.js +5 -2
- package/lib/module/shared/utils/bounds/navigation/zoom/build.js.map +1 -1
- package/lib/typescript/shared/components/screen-container/layers/content.d.ts.map +1 -1
- package/lib/typescript/shared/constants.d.ts +2 -1
- package/lib/typescript/shared/constants.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/navigation/use-stack.d.ts +0 -1
- package/lib/typescript/shared/hooks/navigation/use-stack.d.ts.map +1 -1
- package/lib/typescript/shared/index.d.ts +12 -12
- package/lib/typescript/shared/providers/screen/animation/helpers/build-screen-transition-options.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/hydrate-transition-state/index.d.ts +2 -2
- package/lib/typescript/shared/providers/screen/animation/helpers/hydrate-transition-state/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/hydrate-transition-state/snap-points.d.ts +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/hydrate-transition-state/snap-points.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/hydrate-transition-state/types.d.ts +1 -0
- package/lib/typescript/shared/providers/screen/animation/helpers/hydrate-transition-state/types.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/pipeline.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/selected-interpolator-options.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/stack-progress.d.ts +3 -0
- package/lib/typescript/shared/providers/screen/animation/helpers/stack-progress.d.ts.map +1 -0
- package/lib/typescript/shared/providers/screen/animation/helpers/use-build-transition-state.d.ts +1 -0
- package/lib/typescript/shared/providers/screen/animation/helpers/use-build-transition-state.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/gestures/shared/policy.d.ts +4 -4
- package/lib/typescript/shared/providers/screen/gestures/shared/policy.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/options/helpers.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/options/types.d.ts +1 -1
- package/lib/typescript/shared/providers/screen/options/types.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/styles/helpers/resolve-slot-styles/index.d.ts +4 -4
- package/lib/typescript/shared/providers/screen/styles/helpers/resolve-slot-styles/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/styles/helpers/resolve-slot-styles/materialize-slot.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/styles/helpers/resolve-slot-styles/types.d.ts +2 -0
- package/lib/typescript/shared/providers/screen/styles/helpers/resolve-slot-styles/types.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/styles/hooks/use-interpolated-style-maps.d.ts +6 -6
- package/lib/typescript/shared/providers/screen/styles/hooks/use-interpolated-style-maps.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/styles/hooks/use-resolved-slot-style-map.d.ts +3 -2
- package/lib/typescript/shared/providers/screen/styles/hooks/use-resolved-slot-style-map.d.ts.map +1 -1
- package/lib/typescript/shared/providers/stack/direct.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/stack/helpers/use-stack-derived.d.ts +5 -5
- package/lib/typescript/shared/providers/stack/helpers/use-stack-derived.d.ts.map +1 -1
- package/lib/typescript/shared/providers/stack/managed.provider.d.ts.map +1 -1
- package/lib/typescript/shared/stores/animation.store.d.ts +4 -3
- package/lib/typescript/shared/stores/animation.store.d.ts.map +1 -1
- package/lib/typescript/shared/stores/bounds/internals/links.d.ts.map +1 -1
- package/lib/typescript/shared/types/animation.types.d.ts +4 -3
- package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/index.d.ts +1 -1
- package/lib/typescript/shared/types/index.d.ts.map +1 -1
- package/lib/typescript/shared/types/screen.types.d.ts +9 -12
- package/lib/typescript/shared/types/screen.types.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/navigation/reveal/build.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/navigation/zoom/build.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/shared/components/screen-container/layers/content.tsx +2 -21
- package/src/shared/constants.ts +6 -1
- package/src/shared/hooks/navigation/use-stack.tsx +0 -1
- package/src/shared/providers/screen/animation/helpers/build-screen-transition-options.ts +1 -2
- package/src/shared/providers/screen/animation/helpers/hydrate-transition-state/index.ts +16 -8
- package/src/shared/providers/screen/animation/helpers/hydrate-transition-state/snap-points.ts +2 -1
- package/src/shared/providers/screen/animation/helpers/hydrate-transition-state/types.ts +1 -0
- package/src/shared/providers/screen/animation/helpers/pipeline.ts +19 -5
- package/src/shared/providers/screen/animation/helpers/selected-interpolator-options.ts +0 -3
- package/src/shared/providers/screen/animation/helpers/stack-progress.ts +29 -0
- package/src/shared/providers/screen/animation/helpers/use-build-transition-state.ts +2 -0
- package/src/shared/providers/screen/gestures/shared/policy.ts +20 -7
- package/src/shared/providers/screen/options/helpers.ts +17 -13
- package/src/shared/providers/screen/options/types.ts +1 -1
- package/src/shared/providers/screen/styles/helpers/resolve-slot-styles/index.ts +140 -19
- package/src/shared/providers/screen/styles/helpers/resolve-slot-styles/materialize-slot.ts +5 -1
- package/src/shared/providers/screen/styles/helpers/resolve-slot-styles/types.ts +4 -0
- package/src/shared/providers/screen/styles/hooks/use-interpolated-style-maps.tsx +132 -44
- package/src/shared/providers/screen/styles/hooks/use-resolved-slot-style-map.tsx +7 -5
- package/src/shared/providers/screen/styles/styles.provider.tsx +2 -2
- package/src/shared/providers/stack/direct.provider.tsx +2 -12
- package/src/shared/providers/stack/helpers/use-stack-derived.ts +6 -15
- package/src/shared/providers/stack/managed.provider.tsx +1 -5
- package/src/shared/stores/animation.store.ts +6 -3
- package/src/shared/stores/bounds/internals/links.ts +27 -3
- package/src/shared/types/animation.types.ts +7 -3
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/screen.types.ts +9 -12
- package/src/shared/utils/bounds/navigation/reveal/build.ts +0 -2
- package/src/shared/utils/bounds/navigation/zoom/build.ts +6 -2
|
@@ -3,11 +3,13 @@ import { NO_STYLES } from "../../../../constants";
|
|
|
3
3
|
import { SystemStore } from "../../../../stores/system.store";
|
|
4
4
|
import type {
|
|
5
5
|
NormalizedTransitionInterpolatedStyle,
|
|
6
|
+
ScreenStyleInterpolator,
|
|
6
7
|
TransitionInterpolatedStyle,
|
|
7
8
|
} from "../../../../types/animation.types";
|
|
8
9
|
import { logger } from "../../../../utils/logger";
|
|
9
10
|
import { useScreenAnimationContext } from "../../animation";
|
|
10
11
|
import { useBuildBoundsAccessor } from "../../animation/helpers/accessors/use-build-bounds-accessor";
|
|
12
|
+
import type { ScreenInterpolatorFrame } from "../../animation/helpers/pipeline";
|
|
11
13
|
import { syncSelectedInterpolatorOptions } from "../../animation/helpers/selected-interpolator-options";
|
|
12
14
|
import { useDescriptorDerivations } from "../../descriptors";
|
|
13
15
|
import {
|
|
@@ -16,10 +18,93 @@ import {
|
|
|
16
18
|
} from "../../options";
|
|
17
19
|
import { normalizeSlots } from "../helpers/normalize-slots";
|
|
18
20
|
import { preserveAnimatedPropsOnly } from "../helpers/preserve-animated-props-only";
|
|
21
|
+
import type { LocalStyleLayers } from "../helpers/resolve-slot-styles";
|
|
19
22
|
import { stripInterpolatorOptions } from "../helpers/strip-interpolator-options";
|
|
20
23
|
|
|
24
|
+
const NO_STYLE_LAYERS: LocalStyleLayers = [];
|
|
25
|
+
|
|
26
|
+
type InterpolatorResult = {
|
|
27
|
+
stylesMap: NormalizedTransitionInterpolatedStyle;
|
|
28
|
+
rawStyleMap: TransitionInterpolatedStyle | undefined;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type RunInterpolatorParams = {
|
|
32
|
+
interpolator: ScreenStyleInterpolator | undefined;
|
|
33
|
+
props: ScreenInterpolatorFrame;
|
|
34
|
+
progress: ScreenInterpolatorFrame["progress"];
|
|
35
|
+
next: ScreenInterpolatorFrame["next"];
|
|
36
|
+
bounds: Parameters<ScreenStyleInterpolator>[0]["bounds"];
|
|
37
|
+
shouldDeferStyleBuckets: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const normalizeRawStyleMap = (
|
|
41
|
+
rawStyleMap: TransitionInterpolatedStyle | undefined,
|
|
42
|
+
shouldDeferStyleBuckets: boolean,
|
|
43
|
+
) => {
|
|
44
|
+
"worklet";
|
|
45
|
+
|
|
46
|
+
if (!rawStyleMap) {
|
|
47
|
+
return NO_STYLES;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const stylesMap = normalizeSlots(stripInterpolatorOptions(rawStyleMap));
|
|
51
|
+
|
|
52
|
+
return shouldDeferStyleBuckets
|
|
53
|
+
? preserveAnimatedPropsOnly(stylesMap)
|
|
54
|
+
: stylesMap;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const runInterpolator = ({
|
|
58
|
+
interpolator,
|
|
59
|
+
props,
|
|
60
|
+
progress,
|
|
61
|
+
next,
|
|
62
|
+
bounds,
|
|
63
|
+
shouldDeferStyleBuckets,
|
|
64
|
+
}: RunInterpolatorParams): InterpolatorResult | undefined => {
|
|
65
|
+
"worklet";
|
|
66
|
+
|
|
67
|
+
if (!interpolator) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const raw = interpolator({
|
|
73
|
+
...props,
|
|
74
|
+
progress,
|
|
75
|
+
next,
|
|
76
|
+
bounds,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const rawStyleMap: TransitionInterpolatedStyle | undefined =
|
|
80
|
+
typeof raw === "object" && raw != null ? raw : undefined;
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
rawStyleMap,
|
|
84
|
+
stylesMap: normalizeRawStyleMap(rawStyleMap, shouldDeferStyleBuckets),
|
|
85
|
+
};
|
|
86
|
+
} catch (_) {
|
|
87
|
+
if (__DEV__) {
|
|
88
|
+
logger.warn("screenStyleInterpolator must be a worklet");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const appendLayer = (
|
|
96
|
+
layers: LocalStyleLayers,
|
|
97
|
+
result: InterpolatorResult | undefined,
|
|
98
|
+
) => {
|
|
99
|
+
"worklet";
|
|
100
|
+
|
|
101
|
+
if (result) {
|
|
102
|
+
layers.push(result.stylesMap);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
21
106
|
/**
|
|
22
|
-
* Builds the raw interpolated
|
|
107
|
+
* Builds the raw interpolated style layers for the current screen pass.
|
|
23
108
|
*
|
|
24
109
|
* This hook exists to stabilize style ownership during rapid navigation,
|
|
25
110
|
* especially when an interactive close gesture overlaps with a new navigation
|
|
@@ -39,9 +124,9 @@ import { stripInterpolatorOptions } from "../helpers/strip-interpolator-options"
|
|
|
39
124
|
* hidden window so animated props and runtime options stay warm, but defer style
|
|
40
125
|
* buckets so measurement sees the final untransformed layout.
|
|
41
126
|
*
|
|
42
|
-
* The result
|
|
43
|
-
* slot ids determine whether
|
|
44
|
-
*
|
|
127
|
+
* The result is ordered from lowest to highest priority. Resolution happens
|
|
128
|
+
* downstream, where slot ids determine whether slots inherit from ancestors and
|
|
129
|
+
* where higher owner layers override lower owner layers per key.
|
|
45
130
|
*/
|
|
46
131
|
export const useInterpolatedStylesMap = () => {
|
|
47
132
|
const { currentScreenKey } = useDescriptorDerivations();
|
|
@@ -61,7 +146,7 @@ export const useInterpolatedStylesMap = () => {
|
|
|
61
146
|
|
|
62
147
|
const isGesturingDuringCloseAnimation = useSharedValue(false);
|
|
63
148
|
|
|
64
|
-
return useDerivedValue<
|
|
149
|
+
return useDerivedValue<LocalStyleLayers>(() => {
|
|
65
150
|
"worklet";
|
|
66
151
|
screenInterpolatorPropsRevision.get();
|
|
67
152
|
const props = screenInterpolatorProps.get();
|
|
@@ -99,16 +184,6 @@ export const useInterpolatedStylesMap = () => {
|
|
|
99
184
|
|
|
100
185
|
const interpolatorOptionsOwner =
|
|
101
186
|
isInGestureMode || !nextInterpolator ? "current" : "next";
|
|
102
|
-
const interpolator =
|
|
103
|
-
interpolatorOptionsOwner === "current"
|
|
104
|
-
? currentInterpolator
|
|
105
|
-
: nextInterpolator;
|
|
106
|
-
|
|
107
|
-
if (!interpolator) {
|
|
108
|
-
syncSelectedInterpolatorOptions(selectedInterpolatorOptions, "current");
|
|
109
|
-
syncScreenOptionsOverrides(undefined, screenOptions);
|
|
110
|
-
return NO_STYLES;
|
|
111
|
-
}
|
|
112
187
|
|
|
113
188
|
let effectiveProgress = progress;
|
|
114
189
|
let effectiveNext = next;
|
|
@@ -118,42 +193,55 @@ export const useInterpolatedStylesMap = () => {
|
|
|
118
193
|
effectiveNext = undefined;
|
|
119
194
|
}
|
|
120
195
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const rawStyleMap: TransitionInterpolatedStyle | undefined =
|
|
130
|
-
typeof raw === "object" && raw != null ? raw : undefined;
|
|
196
|
+
const currentResult = runInterpolator({
|
|
197
|
+
interpolator: currentInterpolator,
|
|
198
|
+
props,
|
|
199
|
+
progress: effectiveProgress,
|
|
200
|
+
next: effectiveNext,
|
|
201
|
+
bounds: boundsAccessor,
|
|
202
|
+
shouldDeferStyleBuckets,
|
|
203
|
+
});
|
|
131
204
|
|
|
205
|
+
if (interpolatorOptionsOwner === "current") {
|
|
132
206
|
syncSelectedInterpolatorOptions(
|
|
133
207
|
selectedInterpolatorOptions,
|
|
134
|
-
|
|
135
|
-
rawStyleMap?.options,
|
|
136
|
-
);
|
|
137
|
-
syncScreenOptionsOverrides(
|
|
138
|
-
interpolatorOptionsOwner === "current" ? rawStyleMap : undefined,
|
|
139
|
-
screenOptions,
|
|
208
|
+
"current",
|
|
209
|
+
currentResult?.rawStyleMap?.options,
|
|
140
210
|
);
|
|
211
|
+
syncScreenOptionsOverrides(currentResult?.rawStyleMap, screenOptions);
|
|
141
212
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
: normalizeSlots(stripInterpolatorOptions(rawStyleMap));
|
|
145
|
-
|
|
146
|
-
return shouldDeferStyleBuckets
|
|
147
|
-
? preserveAnimatedPropsOnly(stylesMap)
|
|
148
|
-
: stylesMap;
|
|
149
|
-
} catch (_) {
|
|
150
|
-
if (__DEV__) {
|
|
151
|
-
logger.warn("screenStyleInterpolator must be a worklet");
|
|
213
|
+
if (!currentResult) {
|
|
214
|
+
return NO_STYLE_LAYERS;
|
|
152
215
|
}
|
|
153
216
|
|
|
154
|
-
|
|
155
|
-
syncScreenOptionsOverrides(undefined, screenOptions);
|
|
156
|
-
return NO_STYLES;
|
|
217
|
+
return [currentResult.stylesMap];
|
|
157
218
|
}
|
|
219
|
+
|
|
220
|
+
const nextResult = runInterpolator({
|
|
221
|
+
interpolator: nextInterpolator,
|
|
222
|
+
props,
|
|
223
|
+
progress: effectiveProgress,
|
|
224
|
+
next: effectiveNext,
|
|
225
|
+
bounds: boundsAccessor,
|
|
226
|
+
shouldDeferStyleBuckets,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
syncSelectedInterpolatorOptions(
|
|
230
|
+
selectedInterpolatorOptions,
|
|
231
|
+
"next",
|
|
232
|
+
nextResult?.rawStyleMap?.options,
|
|
233
|
+
);
|
|
234
|
+
syncScreenOptionsOverrides(undefined, screenOptions);
|
|
235
|
+
|
|
236
|
+
const layers: LocalStyleLayers = [];
|
|
237
|
+
|
|
238
|
+
appendLayer(layers, currentResult);
|
|
239
|
+
appendLayer(layers, nextResult);
|
|
240
|
+
|
|
241
|
+
if (layers.length === 0) {
|
|
242
|
+
return NO_STYLE_LAYERS;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return layers;
|
|
158
246
|
});
|
|
159
247
|
};
|
|
@@ -7,18 +7,19 @@ import { NO_STYLES } from "../../../../constants";
|
|
|
7
7
|
import type { NormalizedTransitionInterpolatedStyle } from "../../../../types/animation.types";
|
|
8
8
|
import { useScreenAnimationContext } from "../../animation";
|
|
9
9
|
import {
|
|
10
|
+
type LocalStyleLayers,
|
|
10
11
|
type ResettableStyleStatesBySlot,
|
|
11
12
|
resolveSlotStyles,
|
|
12
13
|
reuseEqualResolvedSlots,
|
|
13
14
|
} from "../helpers/resolve-slot-styles";
|
|
14
15
|
|
|
15
16
|
interface UseResolvedStylesMapParams {
|
|
16
|
-
|
|
17
|
+
localStylesMaps: SharedValue<LocalStyleLayers>;
|
|
17
18
|
ancestorStylesMap?: SharedValue<NormalizedTransitionInterpolatedStyle>;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export const useResolvedStylesMap = ({
|
|
21
|
-
|
|
22
|
+
localStylesMaps,
|
|
22
23
|
ancestorStylesMap,
|
|
23
24
|
}: UseResolvedStylesMapParams) => {
|
|
24
25
|
const { screenInterpolatorProps, screenInterpolatorPropsRevision } =
|
|
@@ -34,13 +35,14 @@ export const useResolvedStylesMap = ({
|
|
|
34
35
|
screenInterpolatorPropsRevision.get();
|
|
35
36
|
|
|
36
37
|
const props = screenInterpolatorProps.get();
|
|
37
|
-
// Keep missing local slots alive
|
|
38
|
-
//
|
|
38
|
+
// Keep missing local slots alive only when another route drives this screen
|
|
39
|
+
// and no active local style layer is available. Once a current/next layer
|
|
40
|
+
// runs, omitted local slots and dropped keys are intentional reset signals.
|
|
39
41
|
const deferLocalSlotResets = !props.focused && !props.current.closing;
|
|
40
42
|
|
|
41
43
|
const { resolvedStylesMap, nextPreviousStyleStatesBySlot } =
|
|
42
44
|
resolveSlotStyles({
|
|
43
|
-
|
|
45
|
+
localStylesMaps: localStylesMaps.get(),
|
|
44
46
|
ancestorStylesMap: ancestorStylesMap?.get() ?? NO_STYLES,
|
|
45
47
|
previousStyleStatesBySlot: previousStyleStatesBySlot.get(),
|
|
46
48
|
deferLocalSlotResets,
|
|
@@ -26,10 +26,10 @@ export const {
|
|
|
26
26
|
})<Props, ScreenStylesContextValue>(({ children, isFloatingOverlay }) => {
|
|
27
27
|
const parentContext = useContext(ScreenStylesContext);
|
|
28
28
|
|
|
29
|
-
const
|
|
29
|
+
const rawStylesMaps = useInterpolatedStylesMap();
|
|
30
30
|
|
|
31
31
|
const stylesMap = useResolvedStylesMap({
|
|
32
|
-
|
|
32
|
+
localStylesMaps: rawStylesMaps,
|
|
33
33
|
ancestorStylesMap: parentContext?.stylesMap,
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -79,8 +79,7 @@ function useDirectStackValue(
|
|
|
79
79
|
};
|
|
80
80
|
}, [state.routes, state.preloadedRoutes, preloadedDescriptors, descriptors]);
|
|
81
81
|
|
|
82
|
-
const {
|
|
83
|
-
useStackDerived(animationMaps);
|
|
82
|
+
const { optimisticFocusedIndex } = useStackDerived(animationMaps);
|
|
84
83
|
|
|
85
84
|
const focusedIndex = state.index;
|
|
86
85
|
|
|
@@ -91,18 +90,9 @@ function useDirectStackValue(
|
|
|
91
90
|
routeKeys,
|
|
92
91
|
routes: allRoutes,
|
|
93
92
|
scenes,
|
|
94
|
-
stackProgress,
|
|
95
93
|
optimisticFocusedIndex,
|
|
96
94
|
}),
|
|
97
|
-
[
|
|
98
|
-
flags,
|
|
99
|
-
navigatorKey,
|
|
100
|
-
routeKeys,
|
|
101
|
-
allRoutes,
|
|
102
|
-
scenes,
|
|
103
|
-
stackProgress,
|
|
104
|
-
optimisticFocusedIndex,
|
|
105
|
-
],
|
|
95
|
+
[flags, navigatorKey, routeKeys, allRoutes, scenes, optimisticFocusedIndex],
|
|
106
96
|
);
|
|
107
97
|
|
|
108
98
|
// DirectStack context value
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type DerivedValue, useDerivedValue } from "react-native-reanimated";
|
|
2
2
|
import type { AnimationStoreMap } from "../../../stores/animation.store";
|
|
3
3
|
|
|
4
|
+
type StackDerivedAnimationMap = Pick<AnimationStoreMap, "closing">;
|
|
5
|
+
|
|
4
6
|
export interface StackDerived {
|
|
5
|
-
/** Sum of all individual screen progress values. */
|
|
6
|
-
stackProgress: DerivedValue<number>;
|
|
7
7
|
/**
|
|
8
8
|
* Focused index that accounts for closing screens.
|
|
9
9
|
* Counts consecutive closing screens from the top so that
|
|
@@ -13,21 +13,12 @@ export interface StackDerived {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Derives
|
|
17
|
-
*
|
|
16
|
+
* Derives an optimistic focused index from animation store maps.
|
|
17
|
+
* Shared between managed and direct providers.
|
|
18
18
|
*/
|
|
19
19
|
export function useStackDerived(
|
|
20
|
-
animationMaps:
|
|
20
|
+
animationMaps: StackDerivedAnimationMap[],
|
|
21
21
|
): StackDerived {
|
|
22
|
-
const stackProgress = useDerivedValue(() => {
|
|
23
|
-
"worklet";
|
|
24
|
-
let total = 0;
|
|
25
|
-
for (let i = 0; i < animationMaps.length; i++) {
|
|
26
|
-
total += animationMaps[i].progress.get();
|
|
27
|
-
}
|
|
28
|
-
return total;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
22
|
const optimisticFocusedIndex = useDerivedValue(() => {
|
|
32
23
|
"worklet";
|
|
33
24
|
const lastIndex = animationMaps.length - 1;
|
|
@@ -39,5 +30,5 @@ export function useStackDerived(
|
|
|
39
30
|
return lastIndex - closingFromTop;
|
|
40
31
|
});
|
|
41
32
|
|
|
42
|
-
return {
|
|
33
|
+
return { optimisticFocusedIndex };
|
|
43
34
|
}
|
|
@@ -47,9 +47,7 @@ function useManagedStackValue<
|
|
|
47
47
|
const navigatorKey = props.state.key;
|
|
48
48
|
|
|
49
49
|
const processed = useProcessedRoutes(state.routes, state.descriptors);
|
|
50
|
-
const {
|
|
51
|
-
processed.animationMaps,
|
|
52
|
-
);
|
|
50
|
+
const { optimisticFocusedIndex } = useStackDerived(processed.animationMaps);
|
|
53
51
|
const closingRouteMap = useClosingRouteMap(
|
|
54
52
|
processed.routeKeys,
|
|
55
53
|
processed.animationMaps,
|
|
@@ -65,7 +63,6 @@ function useManagedStackValue<
|
|
|
65
63
|
routeKeys: processed.routeKeys,
|
|
66
64
|
routes: state.routes as Route<string>[],
|
|
67
65
|
scenes: processed.scenes as BaseStackScene[],
|
|
68
|
-
stackProgress,
|
|
69
66
|
optimisticFocusedIndex,
|
|
70
67
|
}),
|
|
71
68
|
[
|
|
@@ -74,7 +71,6 @@ function useManagedStackValue<
|
|
|
74
71
|
processed.routeKeys,
|
|
75
72
|
state.routes,
|
|
76
73
|
processed.scenes,
|
|
77
|
-
stackProgress,
|
|
78
74
|
optimisticFocusedIndex,
|
|
79
75
|
],
|
|
80
76
|
);
|
|
@@ -7,6 +7,7 @@ import { createStore } from "../utils/create-store";
|
|
|
7
7
|
|
|
8
8
|
export type AnimationStoreMap = {
|
|
9
9
|
progress: SharedValue<number>;
|
|
10
|
+
effectiveProgress: SharedValue<number>;
|
|
10
11
|
willAnimate: SharedValue<number>;
|
|
11
12
|
progressAnimating: SharedValue<number>;
|
|
12
13
|
closing: SharedValue<number>;
|
|
@@ -16,6 +17,7 @@ export type AnimationStoreMap = {
|
|
|
16
17
|
function createAnimationBag(): AnimationStoreMap {
|
|
17
18
|
return {
|
|
18
19
|
progress: makeMutable(0),
|
|
20
|
+
effectiveProgress: makeMutable(0),
|
|
19
21
|
willAnimate: makeMutable(0),
|
|
20
22
|
closing: makeMutable(0),
|
|
21
23
|
progressAnimating: makeMutable(0),
|
|
@@ -24,14 +26,15 @@ function createAnimationBag(): AnimationStoreMap {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
|
-
* Route-keyed screen transition state for the public animation lifecycle.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
29
|
+
* Route-keyed screen transition state for the public animation lifecycle.
|
|
30
|
+
* `progress` tracks committed transition progress; `effectiveProgress` tracks
|
|
31
|
+
* the hydrated progress after live gesture policy is applied.
|
|
30
32
|
*/
|
|
31
33
|
export const AnimationStore = createStore<AnimationStoreMap>({
|
|
32
34
|
createBag: createAnimationBag,
|
|
33
35
|
disposeBag: (bag) => {
|
|
34
36
|
cancelAnimation(bag.progress);
|
|
37
|
+
cancelAnimation(bag.effectiveProgress);
|
|
35
38
|
cancelAnimation(bag.willAnimate);
|
|
36
39
|
cancelAnimation(bag.progressAnimating);
|
|
37
40
|
cancelAnimation(bag.closing);
|
|
@@ -216,6 +216,20 @@ const isCompletedLink = (link: TagLink | null): link is TagLink => {
|
|
|
216
216
|
return !!link?.destination;
|
|
217
217
|
};
|
|
218
218
|
|
|
219
|
+
const getPendingSourceLink = (
|
|
220
|
+
state: LinkPairsState,
|
|
221
|
+
pairKey: ScreenPairKey,
|
|
222
|
+
linkKey: LinkKey,
|
|
223
|
+
): TagLink | null => {
|
|
224
|
+
"worklet";
|
|
225
|
+
const sourceScreenKey = getSourceScreenKeyFromPairKey(pairKey);
|
|
226
|
+
const pendingPairKey = createPendingPairKey(sourceScreenKey);
|
|
227
|
+
|
|
228
|
+
if (pendingPairKey === pairKey) return null;
|
|
229
|
+
|
|
230
|
+
return getPairLink(state, pendingPairKey, linkKey);
|
|
231
|
+
};
|
|
232
|
+
|
|
219
233
|
function getResolvedLink(
|
|
220
234
|
pairKey: ScreenPairKey,
|
|
221
235
|
tag: TagID,
|
|
@@ -226,12 +240,22 @@ function getResolvedLink(
|
|
|
226
240
|
const group = getGroupKeyFromTag(tag);
|
|
227
241
|
const requestedLink = getPairLink(state, pairKey, linkKey);
|
|
228
242
|
|
|
243
|
+
// Press-triggered zoom captures the source before navigation under a pending
|
|
244
|
+
// source<> pair. If the destination screen has no Boundary.View, nothing
|
|
245
|
+
// promotes that source into source<>destination, but zoom can still animate to
|
|
246
|
+
// its default top target from the pending source bounds.
|
|
247
|
+
const fallbackPendingLink = requestedLink
|
|
248
|
+
? null
|
|
249
|
+
: getPendingSourceLink(state, pairKey, linkKey);
|
|
250
|
+
|
|
251
|
+
const link = requestedLink ?? fallbackPendingLink;
|
|
252
|
+
|
|
229
253
|
// Group active ids can update before the new member has a full source/destination
|
|
230
254
|
// link, so unresolved grouped links fall back to the initial id's measurements.
|
|
231
|
-
if (!group || isCompletedLink(
|
|
255
|
+
if (!group || isCompletedLink(link)) {
|
|
232
256
|
return {
|
|
233
257
|
tag,
|
|
234
|
-
link
|
|
258
|
+
link,
|
|
235
259
|
};
|
|
236
260
|
}
|
|
237
261
|
|
|
@@ -248,7 +272,7 @@ function getResolvedLink(
|
|
|
248
272
|
|
|
249
273
|
return {
|
|
250
274
|
tag,
|
|
251
|
-
link
|
|
275
|
+
link,
|
|
252
276
|
};
|
|
253
277
|
}
|
|
254
278
|
|
|
@@ -25,7 +25,7 @@ export type ScreenTransitionOptions = Pick<
|
|
|
25
25
|
ScreenTransitionConfig,
|
|
26
26
|
| "navigationMaskEnabled"
|
|
27
27
|
| "gestureEnabled"
|
|
28
|
-
| "
|
|
28
|
+
| "gestureTracking"
|
|
29
29
|
| "gestureDirection"
|
|
30
30
|
| "gestureSensitivity"
|
|
31
31
|
| "gestureVelocityImpact"
|
|
@@ -287,13 +287,17 @@ export type TransitionSlotStyle = AnimatedViewStyle | TransitionSlotDefinition;
|
|
|
287
287
|
* Runtime options returned by `screenStyleInterpolator`.
|
|
288
288
|
*
|
|
289
289
|
* These values are not style slots. They are derived per frame and consumed by
|
|
290
|
-
* the transition runtime.
|
|
290
|
+
* the transition runtime. Structural options that change the React tree, such
|
|
291
|
+
* as `navigationMaskEnabled`, must be configured statically on the screen.
|
|
291
292
|
*
|
|
292
293
|
* If `gestureSensitivity` is derived from the current gesture, prefer
|
|
293
294
|
* `active.gesture.raw` so the sensitivity calculation does not feed back into
|
|
294
295
|
* itself.
|
|
295
296
|
*/
|
|
296
|
-
export type TransitionInterpolatorOptions =
|
|
297
|
+
export type TransitionInterpolatorOptions = Omit<
|
|
298
|
+
ScreenTransitionOptions,
|
|
299
|
+
"navigationMaskEnabled" | "gestureTracking"
|
|
300
|
+
>;
|
|
297
301
|
|
|
298
302
|
/**
|
|
299
303
|
* Internal normalized slot format.
|
|
@@ -33,6 +33,7 @@ export type ScreenKey = string;
|
|
|
33
33
|
export type SheetScrollGestureBehavior =
|
|
34
34
|
| "expand-and-collapse"
|
|
35
35
|
| "collapse-only";
|
|
36
|
+
export type GestureTracking = "auto" | "never" | "always";
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* A single snap point value. Either a fraction of screen height (0–1) or
|
|
@@ -130,21 +131,17 @@ export type ScreenTransitionConfig = {
|
|
|
130
131
|
gestureEnabled?: boolean;
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
|
-
*
|
|
134
|
-
* live gesture values while preventing gesture dismissal.
|
|
134
|
+
* Controls whether the screen tracks live gesture values.
|
|
135
135
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
136
|
+
* - `"auto"` tracks gestures when dismissal is enabled, or when snap points
|
|
137
|
+
* can move without dismissal.
|
|
138
|
+
* - `"never"` disables gesture tracking for the screen.
|
|
139
|
+
* - `"always"` keeps tracking live gesture values even when
|
|
140
|
+
* `gestureEnabled` is `false`, without allowing dismiss.
|
|
139
141
|
*
|
|
140
|
-
*
|
|
141
|
-
* `gestureEnabled={false}`; this flag mainly affects disabled non-snap
|
|
142
|
-
* gestures.
|
|
143
|
-
*
|
|
144
|
-
* @experimental This API may change in future versions.
|
|
145
|
-
* @default false
|
|
142
|
+
* @default "auto"
|
|
146
143
|
*/
|
|
147
|
-
|
|
144
|
+
gestureTracking?: GestureTracking;
|
|
148
145
|
|
|
149
146
|
/**
|
|
150
147
|
* The direction(s) of the screen gesture used to dismiss the screen.
|
|
@@ -328,7 +328,6 @@ export function buildRevealStyles({
|
|
|
328
328
|
|
|
329
329
|
return {
|
|
330
330
|
options: {
|
|
331
|
-
navigationMaskEnabled: true,
|
|
332
331
|
gestureProgressMode,
|
|
333
332
|
gestureSensitivity,
|
|
334
333
|
gestureReleaseVelocityScale,
|
|
@@ -424,7 +423,6 @@ export function buildRevealStyles({
|
|
|
424
423
|
|
|
425
424
|
return {
|
|
426
425
|
options: {
|
|
427
|
-
navigationMaskEnabled: true,
|
|
428
426
|
gestureProgressMode,
|
|
429
427
|
},
|
|
430
428
|
content: {
|
|
@@ -416,6 +416,10 @@ export function buildZoomStyles({
|
|
|
416
416
|
Math.abs(unfocusedContentScale),
|
|
417
417
|
EPSILON,
|
|
418
418
|
);
|
|
419
|
+
// A naturally settled close can leave this as the last emitted style frame,
|
|
420
|
+
// so drop temporary stacking here instead of waiting for a later reset pass.
|
|
421
|
+
const shouldElevateUnfocusedElement =
|
|
422
|
+
!props.active.closing || !props.active.logicallySettled;
|
|
419
423
|
|
|
420
424
|
const scaleShiftX = computeCenterScaleShift({
|
|
421
425
|
center: elementCenterX,
|
|
@@ -480,8 +484,8 @@ export function buildZoomStyles({
|
|
|
480
484
|
},
|
|
481
485
|
],
|
|
482
486
|
opacity: zoomOptions?.debug ? 1 : unfocusedFade,
|
|
483
|
-
zIndex: 9999,
|
|
484
|
-
elevation: 9999,
|
|
487
|
+
zIndex: shouldElevateUnfocusedElement ? 9999 : 0,
|
|
488
|
+
elevation: shouldElevateUnfocusedElement ? 9999 : 0,
|
|
485
489
|
};
|
|
486
490
|
|
|
487
491
|
return {
|