react-native-screen-transitions 3.4.0-alpha.7 → 3.4.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/create-boundary-component/components/boundary-target.js +6 -4
- package/lib/commonjs/shared/components/create-boundary-component/components/boundary-target.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/create-boundary-component.js +20 -59
- package/lib/commonjs/shared/components/create-boundary-component/create-boundary-component.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/helpers/resolve-pending-source-key.js +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/helpers/resolve-pending-source-key.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js +53 -41
- package/lib/commonjs/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-auto-source-measurement.js +7 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-auto-source-measurement.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js +4 -23
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-pending-destination-measurement.js +84 -2
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-pending-destination-measurement.js.map +1 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-prepare-transition-measurement.js +67 -0
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-prepare-transition-measurement.js.map +1 -0
- package/lib/commonjs/shared/components/create-boundary-component/index.js +10 -5
- package/lib/commonjs/shared/components/create-boundary-component/index.js.map +1 -1
- package/lib/commonjs/shared/components/create-transition-aware-component.js +8 -32
- package/lib/commonjs/shared/components/create-transition-aware-component.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container/hooks/use-content-layout.js +11 -9
- package/lib/commonjs/shared/components/screen-container/hooks/use-content-layout.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container/layers/backdrop.js +7 -5
- package/lib/commonjs/shared/components/screen-container/layers/backdrop.js.map +1 -1
- package/lib/commonjs/shared/components/screen-lifecycle/index.js +3 -1
- package/lib/commonjs/shared/components/screen-lifecycle/index.js.map +1 -1
- package/lib/commonjs/shared/constants.js +16 -1
- package/lib/commonjs/shared/constants.js.map +1 -1
- package/lib/commonjs/shared/hooks/reanimated/use-animated-debounce.js +43 -0
- package/lib/commonjs/shared/hooks/reanimated/use-animated-debounce.js.map +1 -0
- package/lib/commonjs/shared/index.js +6 -0
- package/lib/commonjs/shared/index.js.map +1 -1
- package/lib/commonjs/shared/providers/gestures/handlers/use-handlers.js +7 -0
- package/lib/commonjs/shared/providers/gestures/handlers/use-handlers.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/hydrate-transition-state.js +23 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/hydrate-transition-state.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/animation/helpers/use-build-transition-state.js +3 -0
- package/lib/commonjs/shared/providers/screen/animation/helpers/use-build-transition-state.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/styles/styles.provider.js +1 -11
- package/lib/commonjs/shared/providers/screen/styles/styles.provider.js.map +1 -1
- package/lib/commonjs/shared/stores/animation.store.js +9 -3
- package/lib/commonjs/shared/stores/animation.store.js.map +1 -1
- package/lib/commonjs/shared/stores/bounds/internals/registry.js +18 -2
- package/lib/commonjs/shared/stores/bounds/internals/registry.js.map +1 -1
- package/lib/commonjs/shared/stores/bounds/internals/resolver.js +7 -48
- package/lib/commonjs/shared/stores/bounds/internals/resolver.js.map +1 -1
- package/lib/commonjs/shared/utils/animation/animate-to-progress.js +10 -0
- package/lib/commonjs/shared/utils/animation/animate-to-progress.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/helpers/compute-bounds-styles.js +5 -11
- package/lib/commonjs/shared/utils/bounds/helpers/compute-bounds-styles.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/zoom/build.js +108 -28
- package/lib/commonjs/shared/utils/bounds/zoom/build.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/zoom/config.js +3 -1
- package/lib/commonjs/shared/utils/bounds/zoom/config.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/components/boundary-target.js +6 -4
- package/lib/module/shared/components/create-boundary-component/components/boundary-target.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/create-boundary-component.js +21 -60
- package/lib/module/shared/components/create-boundary-component/create-boundary-component.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/helpers/resolve-pending-source-key.js +1 -1
- package/lib/module/shared/components/create-boundary-component/helpers/resolve-pending-source-key.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js +51 -39
- package/lib/module/shared/components/create-boundary-component/hooks/helpers/measurement-rules.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-auto-source-measurement.js +7 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-auto-source-measurement.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js +4 -23
- package/lib/module/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-pending-destination-measurement.js +86 -4
- package/lib/module/shared/components/create-boundary-component/hooks/use-pending-destination-measurement.js.map +1 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-prepare-transition-measurement.js +62 -0
- package/lib/module/shared/components/create-boundary-component/hooks/use-prepare-transition-measurement.js.map +1 -0
- package/lib/module/shared/components/create-boundary-component/index.js +10 -5
- package/lib/module/shared/components/create-boundary-component/index.js.map +1 -1
- package/lib/module/shared/components/create-transition-aware-component.js +10 -34
- package/lib/module/shared/components/create-transition-aware-component.js.map +1 -1
- package/lib/module/shared/components/screen-container/hooks/use-content-layout.js +11 -9
- package/lib/module/shared/components/screen-container/hooks/use-content-layout.js.map +1 -1
- package/lib/module/shared/components/screen-container/layers/backdrop.js +7 -5
- package/lib/module/shared/components/screen-container/layers/backdrop.js.map +1 -1
- package/lib/module/shared/components/screen-lifecycle/index.js +3 -1
- package/lib/module/shared/components/screen-lifecycle/index.js.map +1 -1
- package/lib/module/shared/constants.js +15 -0
- package/lib/module/shared/constants.js.map +1 -1
- package/lib/module/shared/hooks/reanimated/use-animated-debounce.js +39 -0
- package/lib/module/shared/hooks/reanimated/use-animated-debounce.js.map +1 -0
- package/lib/module/shared/index.js +1 -1
- package/lib/module/shared/index.js.map +1 -1
- package/lib/module/shared/providers/gestures/handlers/use-handlers.js +7 -0
- package/lib/module/shared/providers/gestures/handlers/use-handlers.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/hydrate-transition-state.js +23 -1
- package/lib/module/shared/providers/screen/animation/helpers/hydrate-transition-state.js.map +1 -1
- package/lib/module/shared/providers/screen/animation/helpers/use-build-transition-state.js +3 -0
- package/lib/module/shared/providers/screen/animation/helpers/use-build-transition-state.js.map +1 -1
- package/lib/module/shared/providers/screen/styles/styles.provider.js +1 -11
- package/lib/module/shared/providers/screen/styles/styles.provider.js.map +1 -1
- package/lib/module/shared/stores/animation.store.js +9 -3
- package/lib/module/shared/stores/animation.store.js.map +1 -1
- package/lib/module/shared/stores/bounds/internals/registry.js +18 -2
- package/lib/module/shared/stores/bounds/internals/registry.js.map +1 -1
- package/lib/module/shared/stores/bounds/internals/resolver.js +7 -48
- package/lib/module/shared/stores/bounds/internals/resolver.js.map +1 -1
- package/lib/module/shared/utils/animation/animate-to-progress.js +10 -0
- package/lib/module/shared/utils/animation/animate-to-progress.js.map +1 -1
- package/lib/module/shared/utils/bounds/helpers/compute-bounds-styles.js +5 -11
- package/lib/module/shared/utils/bounds/helpers/compute-bounds-styles.js.map +1 -1
- package/lib/module/shared/utils/bounds/zoom/build.js +110 -30
- package/lib/module/shared/utils/bounds/zoom/build.js.map +1 -1
- package/lib/module/shared/utils/bounds/zoom/config.js +2 -0
- package/lib/module/shared/utils/bounds/zoom/config.js.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/components/boundary-target.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/create-boundary-component.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/helpers/resolve-pending-source-key.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/helpers/measurement-rules.d.ts +16 -11
- package/lib/typescript/shared/components/create-boundary-component/hooks/helpers/measurement-rules.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-auto-source-measurement.d.ts +3 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-auto-source-measurement.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.d.ts +1 -2
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-pending-destination-measurement.d.ts +6 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-pending-destination-measurement.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-prepare-transition-measurement.d.ts +12 -0
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-prepare-transition-measurement.d.ts.map +1 -0
- package/lib/typescript/shared/components/create-boundary-component/index.d.ts +10 -4
- package/lib/typescript/shared/components/create-boundary-component/index.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-boundary-component/types.d.ts +1 -1
- package/lib/typescript/shared/components/create-boundary-component/types.d.ts.map +1 -1
- package/lib/typescript/shared/components/create-transition-aware-component.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-container/hooks/use-content-layout.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-container/layers/backdrop.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-lifecycle/index.d.ts.map +1 -1
- package/lib/typescript/shared/constants.d.ts +33 -0
- package/lib/typescript/shared/constants.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/reanimated/use-animated-debounce.d.ts +13 -0
- package/lib/typescript/shared/hooks/reanimated/use-animated-debounce.d.ts.map +1 -0
- package/lib/typescript/shared/index.d.ts +2 -2
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/gestures/handlers/use-handlers.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/hydrate-transition-state.d.ts +3 -0
- package/lib/typescript/shared/providers/screen/animation/helpers/hydrate-transition-state.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/animation/helpers/use-build-transition-state.d.ts +3 -0
- package/lib/typescript/shared/providers/screen/animation/helpers/use-build-transition-state.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/styles/styles.provider.d.ts.map +1 -1
- package/lib/typescript/shared/stores/animation.store.d.ts +5 -2
- package/lib/typescript/shared/stores/animation.store.d.ts.map +1 -1
- package/lib/typescript/shared/stores/bounds/internals/registry.d.ts.map +1 -1
- package/lib/typescript/shared/stores/bounds/internals/resolver.d.ts.map +1 -1
- package/lib/typescript/shared/stores/bounds/types.d.ts +0 -2
- package/lib/typescript/shared/stores/bounds/types.d.ts.map +1 -1
- package/lib/typescript/shared/types/animation.types.d.ts +11 -0
- package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/bounds.types.d.ts +34 -1
- package/lib/typescript/shared/types/bounds.types.d.ts.map +1 -1
- package/lib/typescript/shared/utils/animation/animate-to-progress.d.ts +2 -1
- package/lib/typescript/shared/utils/animation/animate-to-progress.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/helpers/compute-bounds-styles.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/zoom/build.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/zoom/config.d.ts +2 -0
- package/lib/typescript/shared/utils/bounds/zoom/config.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/shared/components/create-boundary-component/components/boundary-target.tsx +6 -4
- package/src/shared/components/create-boundary-component/create-boundary-component.tsx +26 -59
- package/src/shared/components/create-boundary-component/helpers/resolve-pending-source-key.ts +5 -1
- package/src/shared/components/create-boundary-component/hooks/helpers/measurement-rules.ts +68 -54
- package/src/shared/components/create-boundary-component/hooks/use-auto-source-measurement.ts +19 -3
- package/src/shared/components/create-boundary-component/hooks/use-boundary-measure-and-store.ts +5 -34
- package/src/shared/components/create-boundary-component/hooks/use-pending-destination-measurement.ts +165 -6
- package/src/shared/components/create-boundary-component/hooks/use-prepare-transition-measurement.ts +107 -0
- package/src/shared/components/create-boundary-component/index.tsx +10 -5
- package/src/shared/components/create-boundary-component/types.ts +1 -2
- package/src/shared/components/create-transition-aware-component.tsx +10 -47
- package/src/shared/components/screen-container/hooks/use-content-layout.ts +10 -17
- package/src/shared/components/screen-container/layers/backdrop.tsx +6 -9
- package/src/shared/components/screen-lifecycle/index.tsx +1 -4
- package/src/shared/constants.ts +11 -0
- package/src/shared/hooks/reanimated/use-animated-debounce.ts +56 -0
- package/src/shared/index.ts +1 -0
- package/src/shared/providers/gestures/handlers/use-handlers.ts +9 -0
- package/src/shared/providers/screen/animation/helpers/hydrate-transition-state.ts +27 -1
- package/src/shared/providers/screen/animation/helpers/use-build-transition-state.ts +6 -0
- package/src/shared/providers/screen/styles/styles.provider.tsx +1 -12
- package/src/shared/stores/animation.store.ts +11 -2
- package/src/shared/stores/bounds/internals/registry.ts +24 -3
- package/src/shared/stores/bounds/internals/resolver.ts +6 -75
- package/src/shared/stores/bounds/types.ts +0 -2
- package/src/shared/types/animation.types.ts +13 -0
- package/src/shared/types/bounds.types.ts +34 -1
- package/src/shared/utils/animation/animate-to-progress.ts +11 -1
- package/src/shared/utils/bounds/helpers/compute-bounds-styles.ts +1 -11
- package/src/shared/utils/bounds/zoom/build.ts +158 -45
- package/src/shared/utils/bounds/zoom/config.ts +2 -0
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-deferred-measurement-trigger.js +0 -54
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-deferred-measurement-trigger.js.map +0 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-group-active-measurement.js +0 -122
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-group-active-measurement.js.map +0 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-group-active-source-measurement.js +0 -72
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-group-active-source-measurement.js.map +0 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-initial-layout-handler.js +0 -66
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-initial-layout-handler.js.map +0 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js +0 -58
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js.map +0 -1
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-scroll-settled-measurement.js +0 -53
- package/lib/commonjs/shared/components/create-boundary-component/hooks/use-scroll-settled-measurement.js.map +0 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-deferred-measurement-trigger.js +0 -49
- package/lib/module/shared/components/create-boundary-component/hooks/use-deferred-measurement-trigger.js.map +0 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-group-active-measurement.js +0 -118
- package/lib/module/shared/components/create-boundary-component/hooks/use-group-active-measurement.js.map +0 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-group-active-source-measurement.js +0 -67
- package/lib/module/shared/components/create-boundary-component/hooks/use-group-active-source-measurement.js.map +0 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-initial-layout-handler.js +0 -61
- package/lib/module/shared/components/create-boundary-component/hooks/use-initial-layout-handler.js.map +0 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js +0 -53
- package/lib/module/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.js.map +0 -1
- package/lib/module/shared/components/create-boundary-component/hooks/use-scroll-settled-measurement.js +0 -48
- package/lib/module/shared/components/create-boundary-component/hooks/use-scroll-settled-measurement.js.map +0 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-deferred-measurement-trigger.d.ts +0 -11
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-deferred-measurement-trigger.d.ts.map +0 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-group-active-measurement.d.ts +0 -17
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-group-active-measurement.d.ts.map +0 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-group-active-source-measurement.d.ts +0 -11
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-group-active-source-measurement.d.ts.map +0 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-initial-layout-handler.d.ts +0 -10
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-initial-layout-handler.d.ts.map +0 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.d.ts +0 -11
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.d.ts.map +0 -1
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-scroll-settled-measurement.d.ts +0 -10
- package/lib/typescript/shared/components/create-boundary-component/hooks/use-scroll-settled-measurement.d.ts.map +0 -1
- package/src/shared/components/create-boundary-component/hooks/use-deferred-measurement-trigger.ts +0 -58
- package/src/shared/components/create-boundary-component/hooks/use-group-active-measurement.ts +0 -162
- package/src/shared/components/create-boundary-component/hooks/use-group-active-source-measurement.ts +0 -82
- package/src/shared/components/create-boundary-component/hooks/use-initial-layout-handler.ts +0 -92
- package/src/shared/components/create-boundary-component/hooks/use-pending-destination-retry-measurement.ts +0 -87
- package/src/shared/components/create-boundary-component/hooks/use-scroll-settled-measurement.ts +0 -49
package/src/shared/components/create-boundary-component/hooks/use-pending-destination-measurement.ts
CHANGED
|
@@ -1,25 +1,102 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLayoutEffect } from "react";
|
|
2
|
+
import {
|
|
3
|
+
runOnUI,
|
|
4
|
+
type SharedValue,
|
|
5
|
+
useAnimatedReaction,
|
|
6
|
+
useSharedValue,
|
|
7
|
+
} from "react-native-reanimated";
|
|
8
|
+
import { AnimationStore } from "../../../stores/animation.store";
|
|
2
9
|
import { BoundStore } from "../../../stores/bounds";
|
|
3
10
|
import { resolvePendingSourceKey } from "../helpers/resolve-pending-source-key";
|
|
4
|
-
import type { MaybeMeasureAndStoreParams } from "../types";
|
|
5
|
-
import {
|
|
11
|
+
import type { BoundaryId, MaybeMeasureAndStoreParams } from "../types";
|
|
12
|
+
import {
|
|
13
|
+
resolvePendingDestinationCaptureSignal,
|
|
14
|
+
resolvePendingDestinationRetrySignal,
|
|
15
|
+
} from "./helpers/measurement-rules";
|
|
6
16
|
|
|
7
17
|
export const usePendingDestinationMeasurement = (params: {
|
|
8
18
|
sharedBoundTag: string;
|
|
9
19
|
enabled: boolean;
|
|
20
|
+
id: BoundaryId;
|
|
21
|
+
group?: string;
|
|
22
|
+
currentScreenKey: string;
|
|
10
23
|
expectedSourceScreenKey?: string;
|
|
24
|
+
animating: SharedValue<number>;
|
|
11
25
|
maybeMeasureAndStore: (options: MaybeMeasureAndStoreParams) => void;
|
|
12
26
|
}) => {
|
|
13
27
|
const {
|
|
14
28
|
sharedBoundTag,
|
|
15
29
|
enabled,
|
|
30
|
+
id,
|
|
31
|
+
group,
|
|
32
|
+
currentScreenKey,
|
|
16
33
|
expectedSourceScreenKey,
|
|
34
|
+
animating,
|
|
17
35
|
maybeMeasureAndStore,
|
|
18
36
|
} = params;
|
|
19
37
|
|
|
38
|
+
const progress = AnimationStore.getValue(currentScreenKey, "progress");
|
|
39
|
+
const closing = AnimationStore.getValue(currentScreenKey, "closing");
|
|
40
|
+
|
|
41
|
+
const retryCount = useSharedValue(0);
|
|
42
|
+
const MAX_RETRIES = 4;
|
|
43
|
+
const RETRY_PROGRESS_BUCKETS = 8;
|
|
44
|
+
const RETRY_PROGRESS_MAX = 1.05;
|
|
45
|
+
|
|
46
|
+
useLayoutEffect(() => {
|
|
47
|
+
if (!enabled) return;
|
|
48
|
+
|
|
49
|
+
runOnUI(() => {
|
|
50
|
+
"worklet";
|
|
51
|
+
if (closing.get()) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const currentGroupActiveId = group
|
|
56
|
+
? BoundStore.getGroupActiveId(group)
|
|
57
|
+
: null;
|
|
58
|
+
if (group && currentGroupActiveId !== String(id)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const resolvedSourceKey = resolvePendingSourceKey(
|
|
63
|
+
sharedBoundTag,
|
|
64
|
+
expectedSourceScreenKey,
|
|
65
|
+
);
|
|
66
|
+
const hasAttachableSourceLink = resolvedSourceKey
|
|
67
|
+
? BoundStore.hasPendingLinkFromSource(
|
|
68
|
+
sharedBoundTag,
|
|
69
|
+
resolvedSourceKey,
|
|
70
|
+
) || BoundStore.hasSourceLink(sharedBoundTag, resolvedSourceKey)
|
|
71
|
+
: false;
|
|
72
|
+
|
|
73
|
+
if (!hasAttachableSourceLink) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (BoundStore.hasDestinationLink(sharedBoundTag, currentScreenKey)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
maybeMeasureAndStore({ intent: "complete-destination" });
|
|
82
|
+
})();
|
|
83
|
+
}, [
|
|
84
|
+
enabled,
|
|
85
|
+
id,
|
|
86
|
+
group,
|
|
87
|
+
sharedBoundTag,
|
|
88
|
+
currentScreenKey,
|
|
89
|
+
expectedSourceScreenKey,
|
|
90
|
+
closing,
|
|
91
|
+
maybeMeasureAndStore,
|
|
92
|
+
]);
|
|
93
|
+
|
|
20
94
|
useAnimatedReaction(
|
|
21
95
|
() => {
|
|
22
96
|
"worklet";
|
|
97
|
+
if (closing.get()) {
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
23
100
|
const resolvedSourceKey = resolvePendingSourceKey(
|
|
24
101
|
sharedBoundTag,
|
|
25
102
|
expectedSourceScreenKey,
|
|
@@ -27,12 +104,16 @@ export const usePendingDestinationMeasurement = (params: {
|
|
|
27
104
|
return resolvePendingDestinationCaptureSignal({
|
|
28
105
|
enabled,
|
|
29
106
|
resolvedSourceKey,
|
|
30
|
-
|
|
107
|
+
hasAttachableSourceLink: resolvedSourceKey
|
|
31
108
|
? BoundStore.hasPendingLinkFromSource(
|
|
32
109
|
sharedBoundTag,
|
|
33
110
|
resolvedSourceKey,
|
|
34
|
-
)
|
|
111
|
+
) || BoundStore.hasSourceLink(sharedBoundTag, resolvedSourceKey)
|
|
35
112
|
: false,
|
|
113
|
+
hasDestinationLink: BoundStore.hasDestinationLink(
|
|
114
|
+
sharedBoundTag,
|
|
115
|
+
currentScreenKey,
|
|
116
|
+
),
|
|
36
117
|
});
|
|
37
118
|
},
|
|
38
119
|
(captureSignal, previousCaptureSignal) => {
|
|
@@ -41,9 +122,87 @@ export const usePendingDestinationMeasurement = (params: {
|
|
|
41
122
|
if (!captureSignal || captureSignal === previousCaptureSignal) {
|
|
42
123
|
return;
|
|
43
124
|
}
|
|
125
|
+
const currentGroupActiveId = group
|
|
126
|
+
? BoundStore.getGroupActiveId(group)
|
|
127
|
+
: null;
|
|
128
|
+
if (group && currentGroupActiveId !== String(id)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
maybeMeasureAndStore({ intent: "complete-destination" });
|
|
133
|
+
},
|
|
134
|
+
[
|
|
135
|
+
enabled,
|
|
136
|
+
id,
|
|
137
|
+
group,
|
|
138
|
+
sharedBoundTag,
|
|
139
|
+
expectedSourceScreenKey,
|
|
140
|
+
closing,
|
|
141
|
+
maybeMeasureAndStore,
|
|
142
|
+
],
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
useAnimatedReaction(
|
|
146
|
+
() => {
|
|
147
|
+
"worklet";
|
|
148
|
+
if (closing.get()) {
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
const resolvedSourceKey = resolvePendingSourceKey(
|
|
152
|
+
sharedBoundTag,
|
|
153
|
+
expectedSourceScreenKey,
|
|
154
|
+
);
|
|
155
|
+
return resolvePendingDestinationRetrySignal({
|
|
156
|
+
enabled,
|
|
157
|
+
retryCount: retryCount.get(),
|
|
158
|
+
maxRetries: MAX_RETRIES,
|
|
159
|
+
isAnimating: !!animating.get(),
|
|
160
|
+
hasDestinationLink: BoundStore.hasDestinationLink(
|
|
161
|
+
sharedBoundTag,
|
|
162
|
+
currentScreenKey,
|
|
163
|
+
),
|
|
164
|
+
progress: progress.get(),
|
|
165
|
+
retryProgressMax: RETRY_PROGRESS_MAX,
|
|
166
|
+
retryProgressBuckets: RETRY_PROGRESS_BUCKETS,
|
|
167
|
+
resolvedSourceKey,
|
|
168
|
+
hasAttachableSourceLink: resolvedSourceKey
|
|
169
|
+
? BoundStore.hasPendingLinkFromSource(
|
|
170
|
+
sharedBoundTag,
|
|
171
|
+
resolvedSourceKey,
|
|
172
|
+
) || BoundStore.hasSourceLink(sharedBoundTag, resolvedSourceKey)
|
|
173
|
+
: false,
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
(captureSignal) => {
|
|
177
|
+
"worklet";
|
|
178
|
+
if (!enabled) return;
|
|
179
|
+
if (!captureSignal) {
|
|
180
|
+
retryCount.set(0);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const currentGroupActiveId = group
|
|
184
|
+
? BoundStore.getGroupActiveId(group)
|
|
185
|
+
: null;
|
|
186
|
+
if (group && currentGroupActiveId !== String(id)) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
44
189
|
|
|
190
|
+
if (retryCount.get() >= MAX_RETRIES) return;
|
|
191
|
+
retryCount.set(retryCount.get() + 1);
|
|
45
192
|
maybeMeasureAndStore({ intent: "complete-destination" });
|
|
46
193
|
},
|
|
47
|
-
[
|
|
194
|
+
[
|
|
195
|
+
enabled,
|
|
196
|
+
id,
|
|
197
|
+
group,
|
|
198
|
+
sharedBoundTag,
|
|
199
|
+
currentScreenKey,
|
|
200
|
+
expectedSourceScreenKey,
|
|
201
|
+
progress,
|
|
202
|
+
animating,
|
|
203
|
+
closing,
|
|
204
|
+
maybeMeasureAndStore,
|
|
205
|
+
retryCount,
|
|
206
|
+
],
|
|
48
207
|
);
|
|
49
208
|
};
|
package/src/shared/components/create-boundary-component/hooks/use-prepare-transition-measurement.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { useAnimatedReaction } from "react-native-reanimated";
|
|
2
|
+
import { AnimationStore } from "../../../stores/animation.store";
|
|
3
|
+
import { BoundStore } from "../../../stores/bounds";
|
|
4
|
+
import { GestureStore } from "../../../stores/gesture.store";
|
|
5
|
+
import type { BoundaryId, MaybeMeasureAndStoreParams } from "../types";
|
|
6
|
+
import {
|
|
7
|
+
PREPARE_DESTINATION_MEASUREMENT_INTENT,
|
|
8
|
+
resolvePrepareSourceMeasurementIntent,
|
|
9
|
+
} from "./helpers/measurement-rules";
|
|
10
|
+
|
|
11
|
+
export const usePrepareTransitionMeasurement = (params: {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
sharedBoundTag: string;
|
|
14
|
+
id: BoundaryId;
|
|
15
|
+
group?: string;
|
|
16
|
+
currentScreenKey: string;
|
|
17
|
+
nextScreenKey?: string;
|
|
18
|
+
hasNextScreen: boolean;
|
|
19
|
+
maybeMeasureAndStore: (options: MaybeMeasureAndStoreParams) => void;
|
|
20
|
+
}) => {
|
|
21
|
+
const {
|
|
22
|
+
enabled,
|
|
23
|
+
sharedBoundTag,
|
|
24
|
+
id,
|
|
25
|
+
group,
|
|
26
|
+
currentScreenKey,
|
|
27
|
+
nextScreenKey,
|
|
28
|
+
hasNextScreen,
|
|
29
|
+
maybeMeasureAndStore,
|
|
30
|
+
} = params;
|
|
31
|
+
|
|
32
|
+
const currentWillAnimate = AnimationStore.getValue(
|
|
33
|
+
currentScreenKey,
|
|
34
|
+
"willAnimate",
|
|
35
|
+
);
|
|
36
|
+
const currentAnimating = AnimationStore.getValue(
|
|
37
|
+
currentScreenKey,
|
|
38
|
+
"animating",
|
|
39
|
+
);
|
|
40
|
+
const currentDragging = GestureStore.getValue(currentScreenKey, "dragging");
|
|
41
|
+
const nextWillAnimate = nextScreenKey
|
|
42
|
+
? AnimationStore.getValue(nextScreenKey, "willAnimate")
|
|
43
|
+
: null;
|
|
44
|
+
const nextAnimating = nextScreenKey
|
|
45
|
+
? AnimationStore.getValue(nextScreenKey, "animating")
|
|
46
|
+
: null;
|
|
47
|
+
const nextDragging = nextScreenKey
|
|
48
|
+
? GestureStore.getValue(nextScreenKey, "dragging")
|
|
49
|
+
: null;
|
|
50
|
+
|
|
51
|
+
useAnimatedReaction(
|
|
52
|
+
() => (hasNextScreen ? (nextWillAnimate?.get() ?? 0) : 0),
|
|
53
|
+
(nextValue, previousValue) => {
|
|
54
|
+
"worklet";
|
|
55
|
+
if (!enabled || !hasNextScreen) return;
|
|
56
|
+
if (nextValue === 0 || nextValue === previousValue) return;
|
|
57
|
+
|
|
58
|
+
const currentGroupActiveId = group
|
|
59
|
+
? BoundStore.getGroupActiveId(group)
|
|
60
|
+
: null;
|
|
61
|
+
|
|
62
|
+
if (group && currentGroupActiveId !== String(id)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const shouldCancelMeasurement =
|
|
67
|
+
!!nextAnimating?.get() && !!nextDragging?.get();
|
|
68
|
+
if (shouldCancelMeasurement) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const intent = resolvePrepareSourceMeasurementIntent({
|
|
73
|
+
hasSourceLink: BoundStore.hasSourceLink(
|
|
74
|
+
sharedBoundTag,
|
|
75
|
+
currentScreenKey,
|
|
76
|
+
),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (!intent) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
maybeMeasureAndStore({ intent });
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
useAnimatedReaction(
|
|
88
|
+
() => (!hasNextScreen ? currentWillAnimate.get() : 0),
|
|
89
|
+
(nextValue, previousValue) => {
|
|
90
|
+
"worklet";
|
|
91
|
+
if (!enabled || hasNextScreen) return;
|
|
92
|
+
if (nextValue === 0 || nextValue === previousValue) return;
|
|
93
|
+
const currentGroupActiveId = group
|
|
94
|
+
? BoundStore.getGroupActiveId(group)
|
|
95
|
+
: null;
|
|
96
|
+
if (group && currentGroupActiveId !== String(id)) return;
|
|
97
|
+
|
|
98
|
+
const shouldCancelMeasurement =
|
|
99
|
+
!!currentAnimating.get() && !!currentDragging.get();
|
|
100
|
+
if (shouldCancelMeasurement) return;
|
|
101
|
+
|
|
102
|
+
maybeMeasureAndStore({
|
|
103
|
+
intent: PREPARE_DESTINATION_MEASUREMENT_INTENT,
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { View } from "react-native";
|
|
2
|
-
import { Pressable } from "react-native-gesture-handler";
|
|
1
|
+
import { Pressable, View } from "react-native";
|
|
3
2
|
import { BoundaryTarget } from "./components/boundary-target";
|
|
4
3
|
import { createBoundaryComponent } from "./create-boundary-component";
|
|
5
4
|
|
|
@@ -30,10 +29,16 @@ BoundaryTarget.displayName = "Transition.Boundary.Target";
|
|
|
30
29
|
* - `Boundary.Target` to measure a nested descendant instead of the owner.
|
|
31
30
|
*/
|
|
32
31
|
export const Boundary = {
|
|
33
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Passive boundary wrapper (no built-in press semantics).
|
|
34
|
+
*/
|
|
34
35
|
View: BoundaryView,
|
|
35
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Pressable boundary wrapper with press-priority source capture.
|
|
38
|
+
*/
|
|
36
39
|
Trigger: BoundaryTrigger,
|
|
37
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Optional nested measurement override inside a boundary owner.
|
|
42
|
+
*/
|
|
38
43
|
Target: BoundaryTarget,
|
|
39
44
|
};
|
|
@@ -43,8 +43,7 @@ export type MeasurementIntent =
|
|
|
43
43
|
| "capture-source"
|
|
44
44
|
| "complete-destination"
|
|
45
45
|
| "refresh-source"
|
|
46
|
-
| "refresh-destination"
|
|
47
|
-
| "snapshot-only";
|
|
46
|
+
| "refresh-destination";
|
|
48
47
|
|
|
49
48
|
export interface MaybeMeasureAndStoreParams {
|
|
50
49
|
intent?: MeasurementIntent | readonly MeasurementIntent[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** biome-ignore-all lint/style/noNonNullAssertion: <This helper is usually being used inside a transitionable stack> */
|
|
2
2
|
import type React from "react";
|
|
3
|
-
import { type ComponentType, forwardRef, memo
|
|
3
|
+
import { type ComponentType, forwardRef, memo } from "react";
|
|
4
4
|
import type { View } from "react-native";
|
|
5
5
|
import { GestureDetector } from "react-native-gesture-handler";
|
|
6
6
|
import Animated, {
|
|
@@ -9,13 +9,11 @@ import Animated, {
|
|
|
9
9
|
useAnimatedRef,
|
|
10
10
|
useAnimatedStyle,
|
|
11
11
|
useComposedEventHandler,
|
|
12
|
-
useSharedValue,
|
|
13
12
|
} from "react-native-reanimated";
|
|
14
13
|
import { NO_PROPS, NO_STYLES } from "../constants";
|
|
15
14
|
import { useScrollRegistry } from "../hooks/gestures/use-scroll-registry";
|
|
16
15
|
import { RegisterBoundsProvider } from "../providers/register-bounds.provider";
|
|
17
16
|
import { useScreenStyles } from "../providers/screen/styles";
|
|
18
|
-
import { ScrollSettleProvider } from "../providers/scroll-settle.provider";
|
|
19
17
|
import type { TransitionAwareProps } from "../types/screen.types";
|
|
20
18
|
|
|
21
19
|
interface CreateTransitionAwareComponentOptions {
|
|
@@ -45,15 +43,6 @@ export function createTransitionAwareComponent<P extends object>(
|
|
|
45
43
|
...scrollableProps
|
|
46
44
|
} = props;
|
|
47
45
|
|
|
48
|
-
const settledSignal = useSharedValue(0);
|
|
49
|
-
|
|
50
|
-
const emitScrollSettled = useCallback(() => {
|
|
51
|
-
runOnUI(() => {
|
|
52
|
-
"worklet";
|
|
53
|
-
settledSignal.value = settledSignal.value + 1;
|
|
54
|
-
})();
|
|
55
|
-
}, [settledSignal]);
|
|
56
|
-
|
|
57
46
|
// Determine scroll direction from the horizontal prop (standard ScrollView API)
|
|
58
47
|
const scrollDirection = scrollableProps.horizontal
|
|
59
48
|
? "horizontal"
|
|
@@ -72,54 +61,28 @@ export function createTransitionAwareComponent<P extends object>(
|
|
|
72
61
|
userOnScroll ?? null,
|
|
73
62
|
]);
|
|
74
63
|
|
|
75
|
-
const handleMomentumScrollEnd = useCallback(
|
|
76
|
-
(event: unknown) => {
|
|
77
|
-
userOnMomentumScrollEnd?.(event);
|
|
78
|
-
emitScrollSettled();
|
|
79
|
-
},
|
|
80
|
-
[userOnMomentumScrollEnd, emitScrollSettled],
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const handleScrollEndDrag = useCallback(
|
|
84
|
-
(event: any) => {
|
|
85
|
-
userOnScrollEndDrag?.(event);
|
|
86
|
-
|
|
87
|
-
const velocityX = Math.abs(event?.nativeEvent?.velocity?.x ?? 0);
|
|
88
|
-
const velocityY = Math.abs(event?.nativeEvent?.velocity?.y ?? 0);
|
|
89
|
-
|
|
90
|
-
// If there is no momentum, onMomentumScrollEnd may not fire.
|
|
91
|
-
// Emit settled signal here only when velocity is effectively zero.
|
|
92
|
-
if (velocityX < 0.01 && velocityY < 0.01) {
|
|
93
|
-
emitScrollSettled();
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
[userOnScrollEndDrag, emitScrollSettled],
|
|
97
|
-
);
|
|
98
|
-
|
|
99
64
|
const scrollableComponent = (
|
|
100
65
|
<AnimatedComponent
|
|
101
66
|
{...(scrollableProps as any)}
|
|
102
67
|
ref={ref}
|
|
103
68
|
onScroll={composedScrollHandler}
|
|
104
|
-
onMomentumScrollEnd={
|
|
105
|
-
onScrollEndDrag={
|
|
69
|
+
onMomentumScrollEnd={userOnMomentumScrollEnd}
|
|
70
|
+
onScrollEndDrag={userOnScrollEndDrag}
|
|
106
71
|
onContentSizeChange={onContentSizeChange}
|
|
107
72
|
onLayout={onLayout}
|
|
108
73
|
scrollEventThrottle={scrollableProps.scrollEventThrottle || 16}
|
|
109
74
|
/>
|
|
110
75
|
);
|
|
111
76
|
|
|
77
|
+
if (!nativeGesture) {
|
|
78
|
+
return scrollableComponent;
|
|
79
|
+
}
|
|
80
|
+
|
|
112
81
|
// If no gesture owner found for this axis, render without GestureDetector
|
|
113
82
|
return (
|
|
114
|
-
<
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
) : (
|
|
118
|
-
<GestureDetector gesture={nativeGesture}>
|
|
119
|
-
{scrollableComponent}
|
|
120
|
-
</GestureDetector>
|
|
121
|
-
)}
|
|
122
|
-
</ScrollSettleProvider>
|
|
83
|
+
<GestureDetector gesture={nativeGesture}>
|
|
84
|
+
{scrollableComponent}
|
|
85
|
+
</GestureDetector>
|
|
123
86
|
);
|
|
124
87
|
});
|
|
125
88
|
|
|
@@ -15,15 +15,8 @@ export function useContentLayout() {
|
|
|
15
15
|
const { height: screenHeight } = useWindowDimensions();
|
|
16
16
|
const routeKey = current.route.key;
|
|
17
17
|
const animations = AnimationStore.getBag(routeKey);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
routeKey,
|
|
21
|
-
"resolvedAutoSnapPoint",
|
|
22
|
-
);
|
|
23
|
-
const measuredContentLayoutValue = SystemStore.getValue(
|
|
24
|
-
routeKey,
|
|
25
|
-
"measuredContentLayout",
|
|
26
|
-
);
|
|
18
|
+
const { targetProgress, resolvedAutoSnapPoint, measuredContentLayout } =
|
|
19
|
+
SystemStore.getBag(routeKey);
|
|
27
20
|
const experimental_animateOnInitialMount =
|
|
28
21
|
current.options.experimental_animateOnInitialMount;
|
|
29
22
|
const transitionSpec = current.options.transitionSpec;
|
|
@@ -37,13 +30,13 @@ export function useContentLayout() {
|
|
|
37
30
|
|
|
38
31
|
runOnUI((nextWidth: number, nextHeight: number, nextFraction: number) => {
|
|
39
32
|
"worklet";
|
|
40
|
-
|
|
33
|
+
measuredContentLayout.value = {
|
|
41
34
|
width: nextWidth,
|
|
42
35
|
height: nextHeight,
|
|
43
36
|
};
|
|
44
37
|
|
|
45
|
-
const isFirstMeasurement =
|
|
46
|
-
|
|
38
|
+
const isFirstMeasurement = resolvedAutoSnapPoint.value <= 0;
|
|
39
|
+
resolvedAutoSnapPoint.value = nextFraction;
|
|
47
40
|
|
|
48
41
|
if (
|
|
49
42
|
!isFirstMeasurement ||
|
|
@@ -54,7 +47,7 @@ export function useContentLayout() {
|
|
|
54
47
|
}
|
|
55
48
|
|
|
56
49
|
if (isFirstKey && !experimental_animateOnInitialMount) {
|
|
57
|
-
|
|
50
|
+
targetProgress.value = nextFraction;
|
|
58
51
|
animations.progress.value = nextFraction;
|
|
59
52
|
return;
|
|
60
53
|
}
|
|
@@ -63,15 +56,15 @@ export function useContentLayout() {
|
|
|
63
56
|
target: nextFraction,
|
|
64
57
|
spec: transitionSpec,
|
|
65
58
|
animations,
|
|
66
|
-
targetProgress
|
|
59
|
+
targetProgress,
|
|
67
60
|
});
|
|
68
61
|
})(width, height, fraction);
|
|
69
62
|
},
|
|
70
63
|
[
|
|
71
64
|
animations,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
targetProgress,
|
|
66
|
+
resolvedAutoSnapPoint,
|
|
67
|
+
measuredContentLayout,
|
|
75
68
|
isFirstKey,
|
|
76
69
|
screenHeight,
|
|
77
70
|
experimental_animateOnInitialMount,
|
|
@@ -31,11 +31,8 @@ export const BackdropLayer = memo(function BackdropLayer({
|
|
|
31
31
|
const BackdropComponent = current.options.backdropComponent;
|
|
32
32
|
const routeKey = current.route.key;
|
|
33
33
|
const animations = AnimationStore.getBag(routeKey);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
routeKey,
|
|
37
|
-
"resolvedAutoSnapPoint",
|
|
38
|
-
);
|
|
34
|
+
const { targetProgress, resolvedAutoSnapPoint } =
|
|
35
|
+
SystemStore.getBag(routeKey);
|
|
39
36
|
|
|
40
37
|
const AnimatedBackdropComponent = useMemo(
|
|
41
38
|
() =>
|
|
@@ -68,7 +65,7 @@ export const BackdropLayer = memo(function BackdropLayer({
|
|
|
68
65
|
"worklet";
|
|
69
66
|
const resolvedSnaps = rawSnapPoints
|
|
70
67
|
.map((point) =>
|
|
71
|
-
point === "auto" ?
|
|
68
|
+
point === "auto" ? resolvedAutoSnapPoint.value : point,
|
|
72
69
|
)
|
|
73
70
|
.filter((point): point is number => typeof point === "number");
|
|
74
71
|
|
|
@@ -94,15 +91,15 @@ export const BackdropLayer = memo(function BackdropLayer({
|
|
|
94
91
|
target,
|
|
95
92
|
spec,
|
|
96
93
|
animations,
|
|
97
|
-
targetProgress
|
|
94
|
+
targetProgress,
|
|
98
95
|
onAnimationFinish: shouldDismiss ? dismissScreen : undefined,
|
|
99
96
|
});
|
|
100
97
|
})();
|
|
101
98
|
}
|
|
102
99
|
}, [
|
|
103
100
|
animations,
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
targetProgress,
|
|
102
|
+
resolvedAutoSnapPoint,
|
|
106
103
|
backdropBehavior,
|
|
107
104
|
current,
|
|
108
105
|
dismissScreen,
|
|
@@ -20,10 +20,7 @@ export const ScreenLifecycle = ({ children }: Props) => {
|
|
|
20
20
|
const { current, previous } = useDescriptors();
|
|
21
21
|
const { isFirstKey } = useDescriptorDerivations();
|
|
22
22
|
const animations = AnimationStore.getBag(current.route.key);
|
|
23
|
-
const targetProgress = SystemStore.
|
|
24
|
-
current.route.key,
|
|
25
|
-
"targetProgress",
|
|
26
|
-
);
|
|
23
|
+
const { targetProgress } = SystemStore.getBag(current.route.key);
|
|
27
24
|
|
|
28
25
|
const { activateHighRefreshRate, deactivateHighRefreshRate } =
|
|
29
26
|
useOpenTransition(current, animations, targetProgress, isFirstKey);
|
package/src/shared/constants.ts
CHANGED
|
@@ -56,6 +56,7 @@ export const createScreenTransitionState = (
|
|
|
56
56
|
progress: 0,
|
|
57
57
|
closing: 0,
|
|
58
58
|
animating: 0,
|
|
59
|
+
willAnimate: 0,
|
|
59
60
|
settled: 1,
|
|
60
61
|
logicallySettled: 1,
|
|
61
62
|
entering: 0,
|
|
@@ -79,6 +80,7 @@ export const DEFAULT_SCREEN_TRANSITION_STATE: ScreenTransitionState =
|
|
|
79
80
|
progress: 0,
|
|
80
81
|
closing: 0,
|
|
81
82
|
animating: 0,
|
|
83
|
+
willAnimate: 0,
|
|
82
84
|
settled: 1,
|
|
83
85
|
logicallySettled: 1,
|
|
84
86
|
entering: 0,
|
|
@@ -107,6 +109,15 @@ export const EMPTY_BOUND_HELPER_RESULT_RAW = Object.freeze({
|
|
|
107
109
|
height: 0,
|
|
108
110
|
...HIDDEN_STYLE,
|
|
109
111
|
});
|
|
112
|
+
export const TRANSFORM_RESET = Object.freeze({
|
|
113
|
+
transform: [
|
|
114
|
+
{ translateX: 0 },
|
|
115
|
+
{ translateY: 0 },
|
|
116
|
+
{ scale: 1 },
|
|
117
|
+
{ scaleX: 1 },
|
|
118
|
+
{ scaleY: 1 },
|
|
119
|
+
],
|
|
120
|
+
});
|
|
110
121
|
export const ENTER_RANGE = [0, 1] as const;
|
|
111
122
|
export const EXIT_RANGE = [1, 2] as const;
|
|
112
123
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cancelAnimation,
|
|
3
|
+
useAnimatedReaction,
|
|
4
|
+
useSharedValue,
|
|
5
|
+
withDelay,
|
|
6
|
+
withTiming,
|
|
7
|
+
} from "react-native-reanimated";
|
|
8
|
+
|
|
9
|
+
const SCROLL_SETTLE_DELAY_MS = 25;
|
|
10
|
+
|
|
11
|
+
interface AnimatedDebounceControls {
|
|
12
|
+
trigger: () => void;
|
|
13
|
+
cancel: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Debounces a UI-thread callback using Reanimated timing primitives.
|
|
18
|
+
*
|
|
19
|
+
* Call `trigger()` from a worklet to reset the debounce window. When no new
|
|
20
|
+
* trigger arrives within `delayMs`, `onDebounced` fires once on the UI thread.
|
|
21
|
+
*/
|
|
22
|
+
export function useAnimatedDebounce(
|
|
23
|
+
onDebounced: () => void,
|
|
24
|
+
delayMs: number = SCROLL_SETTLE_DELAY_MS,
|
|
25
|
+
): AnimatedDebounceControls {
|
|
26
|
+
const token = useSharedValue(0);
|
|
27
|
+
|
|
28
|
+
const trigger = () => {
|
|
29
|
+
"worklet";
|
|
30
|
+
cancelAnimation(token);
|
|
31
|
+
token.value = withDelay(
|
|
32
|
+
delayMs,
|
|
33
|
+
withTiming(token.value + 1, { duration: 0 }),
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const cancel = () => {
|
|
38
|
+
"worklet";
|
|
39
|
+
cancelAnimation(token);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
useAnimatedReaction(
|
|
43
|
+
() => token.value,
|
|
44
|
+
(nextToken, previousToken) => {
|
|
45
|
+
"worklet";
|
|
46
|
+
if (nextToken === 0 || nextToken === previousToken) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
onDebounced();
|
|
51
|
+
},
|
|
52
|
+
[delayMs, onDebounced],
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return { trigger, cancel };
|
|
56
|
+
}
|