react-native-screen-transitions 3.6.0-alpha.3 → 3.6.0-alpha.4
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/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/utils/bounds/navigation/reveal/build.js +0 -2
- package/lib/commonjs/shared/utils/bounds/navigation/reveal/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/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/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/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/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/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/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/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/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
|
@@ -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);
|
|
@@ -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: {
|