react-native-screen-transitions 2.0.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -77
- package/lib/commonjs/components/{bounds-activator.js → bound-capture.js} +4 -4
- package/lib/commonjs/components/bound-capture.js.map +1 -0
- package/lib/commonjs/components/controllers/screen-lifecycle.js +18 -4
- package/lib/commonjs/components/controllers/screen-lifecycle.js.map +1 -1
- package/lib/commonjs/components/create-transition-aware-component.js +14 -12
- package/lib/commonjs/components/create-transition-aware-component.js.map +1 -1
- package/lib/commonjs/components/integrations/masked-view.js +52 -0
- package/lib/commonjs/components/integrations/masked-view.js.map +1 -0
- package/lib/commonjs/components/root-transition-aware.js +6 -15
- package/lib/commonjs/components/root-transition-aware.js.map +1 -1
- package/lib/commonjs/configs/index.js +15 -5
- package/lib/commonjs/configs/index.js.map +1 -1
- package/lib/commonjs/configs/presets.js +378 -7
- package/lib/commonjs/configs/presets.js.map +1 -1
- package/lib/commonjs/configs/specs.js +1 -1
- package/lib/commonjs/hooks/animation/use-associated-style.js +7 -10
- package/lib/commonjs/hooks/animation/use-associated-style.js.map +1 -1
- package/lib/commonjs/hooks/animation/use-screen-animation.js +37 -37
- package/lib/commonjs/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/hooks/bounds/use-bound-registry.js +73 -0
- package/lib/commonjs/hooks/bounds/use-bound-registry.js.map +1 -0
- package/lib/commonjs/hooks/gestures/use-build-gestures.js +156 -152
- package/lib/commonjs/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/hooks/gestures/use-parent-gesture-registry.js +28 -0
- package/lib/commonjs/hooks/gestures/use-parent-gesture-registry.js.map +1 -0
- package/lib/commonjs/hooks/gestures/use-scroll-registry.js +146 -0
- package/lib/commonjs/hooks/gestures/use-scroll-registry.js.map +1 -0
- package/lib/commonjs/index.js +3 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/integrations/native-stack/views/NativeStackView.native.js +7 -4
- package/lib/commonjs/integrations/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/commonjs/providers/gestures.js +16 -16
- package/lib/commonjs/providers/gestures.js.map +1 -1
- package/lib/commonjs/providers/transition-styles.js +44 -0
- package/lib/commonjs/providers/transition-styles.js.map +1 -0
- package/lib/commonjs/stores/bounds.js +142 -1
- package/lib/commonjs/stores/bounds.js.map +1 -1
- package/lib/commonjs/stores/utils/reset-stores-for-screen.js +4 -2
- package/lib/commonjs/stores/utils/reset-stores-for-screen.js.map +1 -1
- package/lib/commonjs/types/gesture.js +11 -0
- package/lib/commonjs/types/gesture.js.map +1 -1
- package/lib/commonjs/utils/animation/derivations.js +39 -0
- package/lib/commonjs/utils/animation/derivations.js.map +1 -0
- package/lib/commonjs/utils/animation/run-transition.js +6 -2
- package/lib/commonjs/utils/animation/run-transition.js.map +1 -1
- package/lib/commonjs/utils/bounds/_utils/flatten-styles.js.map +1 -0
- package/lib/commonjs/utils/bounds/_utils/geometry.js +179 -0
- package/lib/commonjs/utils/bounds/_utils/geometry.js.map +1 -0
- package/lib/commonjs/utils/bounds/{get-bounds.js → _utils/get-bounds.js} +7 -9
- package/lib/commonjs/utils/bounds/_utils/get-bounds.js.map +1 -0
- package/lib/commonjs/utils/bounds/_utils/is-bounds-equal.js +19 -0
- package/lib/commonjs/utils/bounds/_utils/is-bounds-equal.js.map +1 -0
- package/lib/commonjs/utils/bounds/_utils/style-composers.js +201 -0
- package/lib/commonjs/utils/bounds/_utils/style-composers.js.map +1 -0
- package/lib/commonjs/utils/bounds/constants.js +14 -3
- package/lib/commonjs/utils/bounds/constants.js.map +1 -1
- package/lib/commonjs/utils/bounds/index.js +210 -17
- package/lib/commonjs/utils/bounds/index.js.map +1 -1
- package/lib/commonjs/utils/gesture/apply-offset-rules.js +233 -0
- package/lib/commonjs/utils/gesture/apply-offset-rules.js.map +1 -0
- package/lib/commonjs/utils/gesture/check-gesture-activation.js +231 -0
- package/lib/commonjs/utils/gesture/check-gesture-activation.js.map +1 -0
- package/lib/commonjs/utils/gesture/determine-dismissal.js +98 -0
- package/lib/commonjs/utils/gesture/determine-dismissal.js.map +1 -0
- package/lib/module/components/{bounds-activator.js → bound-capture.js} +2 -2
- package/lib/module/components/bound-capture.js.map +1 -0
- package/lib/module/components/controllers/screen-lifecycle.js +18 -4
- package/lib/module/components/controllers/screen-lifecycle.js.map +1 -1
- package/lib/module/components/create-transition-aware-component.js +14 -12
- package/lib/module/components/create-transition-aware-component.js.map +1 -1
- package/lib/module/components/integrations/masked-view.js +48 -0
- package/lib/module/components/integrations/masked-view.js.map +1 -0
- package/lib/module/components/root-transition-aware.js +7 -16
- package/lib/module/components/root-transition-aware.js.map +1 -1
- package/lib/module/configs/index.js +15 -2
- package/lib/module/configs/index.js.map +1 -1
- package/lib/module/configs/presets.js +374 -6
- package/lib/module/configs/presets.js.map +1 -1
- package/lib/module/configs/specs.js +1 -1
- package/lib/module/hooks/animation/use-associated-style.js +6 -10
- package/lib/module/hooks/animation/use-associated-style.js.map +1 -1
- package/lib/module/hooks/animation/use-screen-animation.js +37 -37
- package/lib/module/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/hooks/bounds/use-bound-registry.js +68 -0
- package/lib/module/hooks/bounds/use-bound-registry.js.map +1 -0
- package/lib/module/hooks/gestures/use-build-gestures.js +156 -153
- package/lib/module/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/hooks/gestures/use-parent-gesture-registry.js +23 -0
- package/lib/module/hooks/gestures/use-parent-gesture-registry.js.map +1 -0
- package/lib/module/hooks/gestures/use-scroll-registry.js +140 -0
- package/lib/module/hooks/gestures/use-scroll-registry.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/integrations/native-stack/views/NativeStackView.native.js +7 -4
- package/lib/module/integrations/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/module/providers/gestures.js +16 -16
- package/lib/module/providers/gestures.js.map +1 -1
- package/lib/module/providers/transition-styles.js +39 -0
- package/lib/module/providers/transition-styles.js.map +1 -0
- package/lib/module/stores/bounds.js +142 -1
- package/lib/module/stores/bounds.js.map +1 -1
- package/lib/module/stores/utils/reset-stores-for-screen.js +4 -2
- package/lib/module/stores/utils/reset-stores-for-screen.js.map +1 -1
- package/lib/module/types/gesture.js +7 -0
- package/lib/module/types/gesture.js.map +1 -1
- package/lib/module/utils/animation/derivations.js +34 -0
- package/lib/module/utils/animation/derivations.js.map +1 -0
- package/lib/module/utils/animation/run-transition.js +6 -2
- package/lib/module/utils/animation/run-transition.js.map +1 -1
- package/lib/module/utils/bounds/_utils/flatten-styles.js.map +1 -0
- package/lib/module/utils/bounds/_utils/geometry.js +174 -0
- package/lib/module/utils/bounds/_utils/geometry.js.map +1 -0
- package/lib/module/utils/bounds/{get-bounds.js → _utils/get-bounds.js} +7 -9
- package/lib/module/utils/bounds/_utils/get-bounds.js.map +1 -0
- package/lib/module/utils/bounds/_utils/is-bounds-equal.js +14 -0
- package/lib/module/utils/bounds/_utils/is-bounds-equal.js.map +1 -0
- package/lib/module/utils/bounds/_utils/style-composers.js +194 -0
- package/lib/module/utils/bounds/_utils/style-composers.js.map +1 -0
- package/lib/module/utils/bounds/constants.js +14 -3
- package/lib/module/utils/bounds/constants.js.map +1 -1
- package/lib/module/utils/bounds/index.js +208 -15
- package/lib/module/utils/bounds/index.js.map +1 -1
- package/lib/module/utils/gesture/apply-offset-rules.js +228 -0
- package/lib/module/utils/gesture/apply-offset-rules.js.map +1 -0
- package/lib/module/utils/gesture/check-gesture-activation.js +226 -0
- package/lib/module/utils/gesture/check-gesture-activation.js.map +1 -0
- package/lib/module/utils/gesture/determine-dismissal.js +93 -0
- package/lib/module/utils/gesture/determine-dismissal.js.map +1 -0
- package/lib/typescript/components/bound-capture.d.ts +8 -0
- package/lib/typescript/components/bound-capture.d.ts.map +1 -0
- package/lib/typescript/components/controllers/screen-lifecycle.d.ts.map +1 -1
- package/lib/typescript/components/create-transition-aware-component.d.ts.map +1 -1
- package/lib/typescript/components/integrations/masked-view.d.ts +6 -0
- package/lib/typescript/components/integrations/masked-view.d.ts.map +1 -0
- package/lib/typescript/components/root-transition-aware.d.ts +3 -3
- package/lib/typescript/components/root-transition-aware.d.ts.map +1 -1
- package/lib/typescript/configs/index.d.ts +15 -2
- package/lib/typescript/configs/index.d.ts.map +1 -1
- package/lib/typescript/configs/presets.d.ts +3 -0
- package/lib/typescript/configs/presets.d.ts.map +1 -1
- package/lib/typescript/hooks/animation/use-associated-style.d.ts +6 -4
- package/lib/typescript/hooks/animation/use-associated-style.d.ts.map +1 -1
- package/lib/typescript/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/hooks/bounds/{use-bound-measurer.d.ts → use-bound-registry.d.ts} +5 -4
- package/lib/typescript/hooks/bounds/{use-bound-measurer.d.ts.map → use-bound-registry.d.ts.map} +1 -1
- package/lib/typescript/hooks/gestures/use-build-gestures.d.ts +6 -5
- package/lib/typescript/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/hooks/gestures/use-parent-gesture-registry.d.ts +6 -0
- package/lib/typescript/hooks/gestures/use-parent-gesture-registry.d.ts.map +1 -0
- package/lib/typescript/hooks/gestures/{use-scroll-progress.d.ts → use-scroll-registry.d.ts} +2 -2
- package/lib/typescript/hooks/gestures/use-scroll-registry.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +25 -11
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/integrations/native-stack/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/providers/gestures.d.ts +4 -2
- package/lib/typescript/providers/gestures.d.ts.map +1 -1
- package/lib/typescript/providers/transition-styles.d.ts +8 -0
- package/lib/typescript/providers/transition-styles.d.ts.map +1 -0
- package/lib/typescript/stores/bounds.d.ts +11 -0
- package/lib/typescript/stores/bounds.d.ts.map +1 -1
- package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts +3 -1
- package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts.map +1 -1
- package/lib/typescript/types/bounds.d.ts +5 -1
- package/lib/typescript/types/bounds.d.ts.map +1 -1
- package/lib/typescript/types/gesture.d.ts +14 -0
- package/lib/typescript/types/gesture.d.ts.map +1 -1
- package/lib/typescript/types/navigator.d.ts +5 -1
- package/lib/typescript/types/navigator.d.ts.map +1 -1
- package/lib/typescript/utils/animation/derivations.d.ts +19 -0
- package/lib/typescript/utils/animation/derivations.d.ts.map +1 -0
- package/lib/typescript/utils/animation/run-transition.d.ts +2 -1
- package/lib/typescript/utils/animation/run-transition.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/_types/builder.d.ts +96 -14
- package/lib/typescript/utils/bounds/_types/builder.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/_types/geometry.d.ts +0 -1
- package/lib/typescript/utils/bounds/_types/geometry.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/_utils/flatten-styles.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/{geometry.d.ts → _utils/geometry.d.ts} +8 -5
- package/lib/typescript/utils/bounds/_utils/geometry.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/_utils/get-bounds.d.ts +4 -0
- package/lib/typescript/utils/bounds/_utils/get-bounds.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/_utils/is-bounds-equal.d.ts +7 -0
- package/lib/typescript/utils/bounds/_utils/is-bounds-equal.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/{style-composers.d.ts → _utils/style-composers.d.ts} +7 -10
- package/lib/typescript/utils/bounds/_utils/style-composers.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/constants.d.ts +5 -5
- package/lib/typescript/utils/bounds/constants.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/index.d.ts +2 -4
- package/lib/typescript/utils/bounds/index.d.ts.map +1 -1
- package/lib/typescript/utils/gesture/apply-offset-rules.d.ts +38 -0
- package/lib/typescript/utils/gesture/apply-offset-rules.d.ts.map +1 -0
- package/lib/typescript/utils/gesture/check-gesture-activation.d.ts +38 -0
- package/lib/typescript/utils/gesture/check-gesture-activation.d.ts.map +1 -0
- package/lib/typescript/utils/gesture/determine-dismissal.d.ts +25 -0
- package/lib/typescript/utils/gesture/determine-dismissal.d.ts.map +1 -0
- package/package.json +2 -3
- package/src/__tests__/geometry.test.ts +15 -12
- package/src/components/{bounds-activator.tsx → bound-capture.tsx} +1 -1
- package/src/components/controllers/screen-lifecycle.tsx +13 -5
- package/src/components/create-transition-aware-component.tsx +17 -11
- package/src/components/integrations/masked-view.tsx +56 -0
- package/src/components/root-transition-aware.tsx +31 -39
- package/src/configs/index.ts +26 -2
- package/src/configs/presets.ts +401 -6
- package/src/configs/specs.ts +1 -1
- package/src/hooks/animation/use-associated-style.tsx +12 -11
- package/src/hooks/animation/use-screen-animation.tsx +48 -49
- package/src/hooks/bounds/{use-bound-measurer.tsx → use-bound-registry.tsx} +32 -20
- package/src/hooks/gestures/use-build-gestures.tsx +193 -228
- package/src/hooks/gestures/use-parent-gesture-registry.tsx +18 -0
- package/src/hooks/gestures/use-scroll-registry.tsx +145 -0
- package/src/index.ts +2 -0
- package/src/integrations/native-stack/views/NativeStackView.native.tsx +8 -5
- package/src/providers/gestures.tsx +19 -22
- package/src/providers/transition-styles.tsx +52 -0
- package/src/stores/bounds.ts +156 -0
- package/src/stores/utils/reset-stores-for-screen.ts +7 -2
- package/src/types/bounds.ts +8 -1
- package/src/types/gesture.ts +19 -0
- package/src/types/navigator.ts +5 -1
- package/src/utils/animation/derivations.ts +38 -0
- package/src/utils/animation/run-transition.ts +4 -1
- package/src/utils/bounds/_types/builder.ts +127 -11
- package/src/utils/bounds/_types/geometry.ts +0 -1
- package/src/utils/bounds/_utils/geometry.ts +166 -0
- package/src/utils/bounds/_utils/get-bounds.ts +54 -0
- package/src/utils/bounds/_utils/is-bounds-equal.ts +24 -0
- package/src/utils/bounds/_utils/style-composers.ts +216 -0
- package/src/utils/bounds/constants.ts +37 -22
- package/src/utils/bounds/index.ts +269 -19
- package/src/utils/gesture/apply-offset-rules.ts +314 -0
- package/src/utils/gesture/check-gesture-activation.ts +310 -0
- package/src/utils/gesture/determine-dismissal.ts +131 -0
- package/lib/commonjs/components/bounds-activator.js.map +0 -1
- package/lib/commonjs/hooks/bounds/use-bound-measurer.js +0 -52
- package/lib/commonjs/hooks/bounds/use-bound-measurer.js.map +0 -1
- package/lib/commonjs/hooks/gestures/use-scroll-progress.js +0 -57
- package/lib/commonjs/hooks/gestures/use-scroll-progress.js.map +0 -1
- package/lib/commonjs/utils/bounds/build-bound-styles.js +0 -145
- package/lib/commonjs/utils/bounds/build-bound-styles.js.map +0 -1
- package/lib/commonjs/utils/bounds/flatten-styles.js.map +0 -1
- package/lib/commonjs/utils/bounds/geometry.js +0 -94
- package/lib/commonjs/utils/bounds/geometry.js.map +0 -1
- package/lib/commonjs/utils/bounds/get-bounds.js.map +0 -1
- package/lib/commonjs/utils/bounds/style-composers.js +0 -199
- package/lib/commonjs/utils/bounds/style-composers.js.map +0 -1
- package/lib/commonjs/utils/gesture/apply-gesture-activation-criteria.js +0 -81
- package/lib/commonjs/utils/gesture/apply-gesture-activation-criteria.js.map +0 -1
- package/lib/commonjs/utils/gesture/normalize-gesture-translation.js +0 -21
- package/lib/commonjs/utils/gesture/normalize-gesture-translation.js.map +0 -1
- package/lib/commonjs/utils/index.js +0 -17
- package/lib/commonjs/utils/index.js.map +0 -1
- package/lib/module/components/bounds-activator.js.map +0 -1
- package/lib/module/hooks/bounds/use-bound-measurer.js +0 -47
- package/lib/module/hooks/bounds/use-bound-measurer.js.map +0 -1
- package/lib/module/hooks/gestures/use-scroll-progress.js +0 -52
- package/lib/module/hooks/gestures/use-scroll-progress.js.map +0 -1
- package/lib/module/utils/bounds/build-bound-styles.js +0 -141
- package/lib/module/utils/bounds/build-bound-styles.js.map +0 -1
- package/lib/module/utils/bounds/flatten-styles.js.map +0 -1
- package/lib/module/utils/bounds/geometry.js +0 -89
- package/lib/module/utils/bounds/geometry.js.map +0 -1
- package/lib/module/utils/bounds/get-bounds.js.map +0 -1
- package/lib/module/utils/bounds/style-composers.js +0 -191
- package/lib/module/utils/bounds/style-composers.js.map +0 -1
- package/lib/module/utils/gesture/apply-gesture-activation-criteria.js +0 -76
- package/lib/module/utils/gesture/apply-gesture-activation-criteria.js.map +0 -1
- package/lib/module/utils/gesture/normalize-gesture-translation.js +0 -16
- package/lib/module/utils/gesture/normalize-gesture-translation.js.map +0 -1
- package/lib/module/utils/index.js +0 -4
- package/lib/module/utils/index.js.map +0 -1
- package/lib/typescript/components/bounds-activator.d.ts +0 -8
- package/lib/typescript/components/bounds-activator.d.ts.map +0 -1
- package/lib/typescript/hooks/gestures/use-scroll-progress.d.ts.map +0 -1
- package/lib/typescript/utils/bounds/build-bound-styles.d.ts +0 -4
- package/lib/typescript/utils/bounds/build-bound-styles.d.ts.map +0 -1
- package/lib/typescript/utils/bounds/flatten-styles.d.ts.map +0 -1
- package/lib/typescript/utils/bounds/geometry.d.ts.map +0 -1
- package/lib/typescript/utils/bounds/get-bounds.d.ts +0 -4
- package/lib/typescript/utils/bounds/get-bounds.d.ts.map +0 -1
- package/lib/typescript/utils/bounds/style-composers.d.ts.map +0 -1
- package/lib/typescript/utils/gesture/apply-gesture-activation-criteria.d.ts +0 -17
- package/lib/typescript/utils/gesture/apply-gesture-activation-criteria.d.ts.map +0 -1
- package/lib/typescript/utils/gesture/normalize-gesture-translation.d.ts +0 -6
- package/lib/typescript/utils/gesture/normalize-gesture-translation.d.ts.map +0 -1
- package/lib/typescript/utils/index.d.ts +0 -2
- package/lib/typescript/utils/index.d.ts.map +0 -1
- package/src/hooks/gestures/use-scroll-progress.tsx +0 -60
- package/src/utils/bounds/build-bound-styles.ts +0 -184
- package/src/utils/bounds/geometry.ts +0 -113
- package/src/utils/bounds/get-bounds.ts +0 -56
- package/src/utils/bounds/style-composers.ts +0 -172
- package/src/utils/gesture/apply-gesture-activation-criteria.ts +0 -109
- package/src/utils/gesture/normalize-gesture-translation.ts +0 -20
- package/src/utils/index.ts +0 -1
- /package/lib/commonjs/utils/bounds/{flatten-styles.js → _utils/flatten-styles.js} +0 -0
- /package/lib/module/utils/bounds/{flatten-styles.js → _utils/flatten-styles.js} +0 -0
- /package/lib/typescript/utils/bounds/{flatten-styles.d.ts → _utils/flatten-styles.d.ts} +0 -0
- /package/src/utils/bounds/{flatten-styles.ts → _utils/flatten-styles.ts} +0 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyOffsetRules = void 0;
|
|
7
|
+
var _gesture = require("../../types/gesture");
|
|
8
|
+
/**
|
|
9
|
+
* 10 seems like the correct threshold for compatability with nested gestures outside of our package.
|
|
10
|
+
*/
|
|
11
|
+
const GESTURE_ACTIVATION_THRESHOLD_X = 10;
|
|
12
|
+
const GESTURE_ACTIVATION_THRESHOLD_Y = 10;
|
|
13
|
+
const GESTURE_FAIL_TOLERANCE_X = 15;
|
|
14
|
+
const GESTURE_FAIL_TOLERANCE_Y = 20;
|
|
15
|
+
const DEFAULT_EDGE_DISTANCE_HORIZONTAL = 50;
|
|
16
|
+
const DEFAULT_EDGE_DISTANCE_VERTICAL = 135;
|
|
17
|
+
const DEFAULT_ACTIVATION_AREA = "screen";
|
|
18
|
+
function normalizeSides(area) {
|
|
19
|
+
"worklet";
|
|
20
|
+
|
|
21
|
+
if (!area || typeof area === "string") {
|
|
22
|
+
const mode = area ?? DEFAULT_ACTIVATION_AREA;
|
|
23
|
+
return {
|
|
24
|
+
left: mode,
|
|
25
|
+
right: mode,
|
|
26
|
+
top: mode,
|
|
27
|
+
bottom: mode
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const s = area;
|
|
31
|
+
return {
|
|
32
|
+
left: s.left ?? DEFAULT_ACTIVATION_AREA,
|
|
33
|
+
right: s.right ?? DEFAULT_ACTIVATION_AREA,
|
|
34
|
+
top: s.top ?? DEFAULT_ACTIVATION_AREA,
|
|
35
|
+
bottom: s.bottom ?? DEFAULT_ACTIVATION_AREA
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function computeEdgeConstraints(initialTouch, dimensions, sides, responseDistance) {
|
|
39
|
+
"worklet";
|
|
40
|
+
|
|
41
|
+
const xDist = responseDistance ?? DEFAULT_EDGE_DISTANCE_HORIZONTAL;
|
|
42
|
+
const yDist = responseDistance ?? DEFAULT_EDGE_DISTANCE_VERTICAL;
|
|
43
|
+
const horizontalRight = sides.left === "screen" || initialTouch.x <= xDist; // right swipe checks left edge
|
|
44
|
+
const horizontalLeft = sides.right === "screen" || initialTouch.x >= dimensions.width - xDist; // left swipe checks right edge
|
|
45
|
+
const verticalDown = sides.top === "screen" || initialTouch.y <= yDist; // down swipe checks top edge
|
|
46
|
+
const verticalUp = sides.bottom === "screen" || initialTouch.y >= dimensions.height - yDist; // up swipe checks bottom edge
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
horizontalRight,
|
|
50
|
+
horizontalLeft,
|
|
51
|
+
verticalDown,
|
|
52
|
+
verticalUp
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function calculateSwipeDirs(deltaX, deltaY) {
|
|
56
|
+
"worklet";
|
|
57
|
+
|
|
58
|
+
const isVerticalSwipe = Math.abs(deltaY) > Math.abs(deltaX);
|
|
59
|
+
const isHorizontalSwipe = Math.abs(deltaX) > Math.abs(deltaY);
|
|
60
|
+
const isSwipingDown = isVerticalSwipe && deltaY > 0;
|
|
61
|
+
const isSwipingUp = isVerticalSwipe && deltaY < 0;
|
|
62
|
+
const isSwipingRight = isHorizontalSwipe && deltaX > 0;
|
|
63
|
+
const isSwipingLeft = isHorizontalSwipe && deltaX < 0;
|
|
64
|
+
return {
|
|
65
|
+
isSwipingDown,
|
|
66
|
+
isSwipingUp,
|
|
67
|
+
isSwipingRight,
|
|
68
|
+
isSwipingLeft,
|
|
69
|
+
isVerticalSwipe,
|
|
70
|
+
isHorizontalSwipe
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function shouldActivateOrFail(params) {
|
|
74
|
+
"worklet";
|
|
75
|
+
|
|
76
|
+
const {
|
|
77
|
+
deltaX,
|
|
78
|
+
deltaY,
|
|
79
|
+
hasHorizontal,
|
|
80
|
+
hasVertical,
|
|
81
|
+
isHorizontalSwipe,
|
|
82
|
+
isVerticalSwipe,
|
|
83
|
+
allowedRight,
|
|
84
|
+
allowedLeft,
|
|
85
|
+
allowedUp,
|
|
86
|
+
allowedDown,
|
|
87
|
+
horizontalGateRight,
|
|
88
|
+
horizontalGateLeft,
|
|
89
|
+
verticalGateUp,
|
|
90
|
+
verticalGateDown,
|
|
91
|
+
isSwipingRight,
|
|
92
|
+
isSwipingLeft,
|
|
93
|
+
isSwipingUp,
|
|
94
|
+
isSwipingDown
|
|
95
|
+
} = params;
|
|
96
|
+
let shouldActivate = false;
|
|
97
|
+
let shouldFail = false;
|
|
98
|
+
if (hasHorizontal && isHorizontalSwipe) {
|
|
99
|
+
const hasEnoughHorizontalMovement = Math.abs(deltaX) >= GESTURE_ACTIVATION_THRESHOLD_X;
|
|
100
|
+
const hasAcceptableVerticalDeviation = Math.abs(deltaY) <= GESTURE_FAIL_TOLERANCE_X;
|
|
101
|
+
if (hasEnoughHorizontalMovement && hasAcceptableVerticalDeviation) {
|
|
102
|
+
const rightOk = isSwipingRight && allowedRight && horizontalGateRight;
|
|
103
|
+
const leftOk = isSwipingLeft && allowedLeft && horizontalGateLeft;
|
|
104
|
+
if (rightOk || leftOk) {
|
|
105
|
+
shouldActivate = true;
|
|
106
|
+
}
|
|
107
|
+
} else if (!hasAcceptableVerticalDeviation) {
|
|
108
|
+
shouldFail = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (hasVertical && isVerticalSwipe) {
|
|
112
|
+
const hasEnoughVerticalMovement = Math.abs(deltaY) >= GESTURE_ACTIVATION_THRESHOLD_Y;
|
|
113
|
+
const hasAcceptableHorizontalDeviation = Math.abs(deltaX) <= GESTURE_FAIL_TOLERANCE_Y;
|
|
114
|
+
if (hasEnoughVerticalMovement && hasAcceptableHorizontalDeviation) {
|
|
115
|
+
const upOk = isSwipingUp && allowedUp && verticalGateUp;
|
|
116
|
+
const downOk = isSwipingDown && allowedDown && verticalGateDown;
|
|
117
|
+
if (upOk || downOk) {
|
|
118
|
+
shouldActivate = true;
|
|
119
|
+
}
|
|
120
|
+
} else if (!hasAcceptableHorizontalDeviation) {
|
|
121
|
+
shouldFail = true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (hasHorizontal && isHorizontalSwipe) {
|
|
125
|
+
if (isSwipingLeft && !allowedLeft || isSwipingRight && !allowedRight) {
|
|
126
|
+
shouldFail = true;
|
|
127
|
+
}
|
|
128
|
+
// If gating prohibits the dominant horizontal swipe, fail early
|
|
129
|
+
if (isSwipingRight && allowedRight && !horizontalGateRight || isSwipingLeft && allowedLeft && !horizontalGateLeft) {
|
|
130
|
+
shouldFail = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (hasVertical && isVerticalSwipe) {
|
|
134
|
+
if (isSwipingUp && !allowedUp || isSwipingDown && !allowedDown) {
|
|
135
|
+
shouldFail = true;
|
|
136
|
+
}
|
|
137
|
+
// If gating prohibits the dominant vertical swipe, fail early
|
|
138
|
+
if (isSwipingUp && allowedUp && !verticalGateUp || isSwipingDown && allowedDown && !verticalGateDown) {
|
|
139
|
+
shouldFail = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
shouldActivate,
|
|
144
|
+
shouldFail
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Since we're using onTouchesMove to activate our pan, faillOffset and activateOffset don't actually work. In that case we'll create this function to use in onTouchesMove which acts simarly to the original functionality.
|
|
150
|
+
*/
|
|
151
|
+
const applyOffsetRules = ({
|
|
152
|
+
initialTouch,
|
|
153
|
+
touch,
|
|
154
|
+
directions,
|
|
155
|
+
manager,
|
|
156
|
+
gestureOffsetState,
|
|
157
|
+
activationArea,
|
|
158
|
+
dimensions,
|
|
159
|
+
responseDistance
|
|
160
|
+
}) => {
|
|
161
|
+
"worklet";
|
|
162
|
+
|
|
163
|
+
const deltaX = touch.x - initialTouch.x;
|
|
164
|
+
const deltaY = touch.y - initialTouch.y;
|
|
165
|
+
const allowedDown = directions.vertical;
|
|
166
|
+
const allowedUp = directions.verticalInverted;
|
|
167
|
+
const allowedRight = directions.horizontal;
|
|
168
|
+
const allowedLeft = directions.horizontalInverted;
|
|
169
|
+
const hasHorizontal = allowedLeft || allowedRight;
|
|
170
|
+
const hasVertical = allowedUp || allowedDown;
|
|
171
|
+
const {
|
|
172
|
+
isSwipingDown,
|
|
173
|
+
isSwipingUp,
|
|
174
|
+
isSwipingRight,
|
|
175
|
+
isSwipingLeft,
|
|
176
|
+
isVerticalSwipe,
|
|
177
|
+
isHorizontalSwipe
|
|
178
|
+
} = calculateSwipeDirs(deltaX, deltaY);
|
|
179
|
+
if (gestureOffsetState.value !== _gesture.GestureOffsetState.PENDING) {
|
|
180
|
+
return {
|
|
181
|
+
isSwipingDown,
|
|
182
|
+
isSwipingUp,
|
|
183
|
+
isSwipingRight,
|
|
184
|
+
isSwipingLeft
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const sides = normalizeSides(activationArea);
|
|
188
|
+
const {
|
|
189
|
+
horizontalRight: horizontalGateRight,
|
|
190
|
+
horizontalLeft: horizontalGateLeft,
|
|
191
|
+
verticalDown: verticalGateDown,
|
|
192
|
+
verticalUp: verticalGateUp
|
|
193
|
+
} = computeEdgeConstraints(initialTouch, dimensions, sides, responseDistance);
|
|
194
|
+
const {
|
|
195
|
+
shouldActivate,
|
|
196
|
+
shouldFail
|
|
197
|
+
} = shouldActivateOrFail({
|
|
198
|
+
deltaX,
|
|
199
|
+
deltaY,
|
|
200
|
+
hasHorizontal,
|
|
201
|
+
hasVertical,
|
|
202
|
+
isHorizontalSwipe,
|
|
203
|
+
isVerticalSwipe,
|
|
204
|
+
allowedRight,
|
|
205
|
+
allowedLeft,
|
|
206
|
+
allowedUp,
|
|
207
|
+
allowedDown,
|
|
208
|
+
horizontalGateRight,
|
|
209
|
+
horizontalGateLeft,
|
|
210
|
+
verticalGateUp,
|
|
211
|
+
verticalGateDown,
|
|
212
|
+
isSwipingRight,
|
|
213
|
+
isSwipingLeft,
|
|
214
|
+
isSwipingUp,
|
|
215
|
+
isSwipingDown
|
|
216
|
+
});
|
|
217
|
+
if (shouldActivate) {
|
|
218
|
+
gestureOffsetState.value = _gesture.GestureOffsetState.PASSED;
|
|
219
|
+
} else if (shouldFail) {
|
|
220
|
+
gestureOffsetState.value = _gesture.GestureOffsetState.FAILED;
|
|
221
|
+
manager?.fail();
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
isSwipingDown,
|
|
225
|
+
isSwipingUp,
|
|
226
|
+
isSwipingRight,
|
|
227
|
+
isSwipingLeft
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
exports.applyOffsetRules = applyOffsetRules;
|
|
231
|
+
//# sourceMappingURL=check-gesture-activation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_gesture","require","GESTURE_ACTIVATION_THRESHOLD_X","GESTURE_ACTIVATION_THRESHOLD_Y","GESTURE_FAIL_TOLERANCE_X","GESTURE_FAIL_TOLERANCE_Y","DEFAULT_EDGE_DISTANCE_HORIZONTAL","DEFAULT_EDGE_DISTANCE_VERTICAL","DEFAULT_ACTIVATION_AREA","normalizeSides","area","mode","left","right","top","bottom","s","computeEdgeConstraints","initialTouch","dimensions","sides","responseDistance","xDist","yDist","horizontalRight","x","horizontalLeft","width","verticalDown","y","verticalUp","height","calculateSwipeDirs","deltaX","deltaY","isVerticalSwipe","Math","abs","isHorizontalSwipe","isSwipingDown","isSwipingUp","isSwipingRight","isSwipingLeft","shouldActivateOrFail","params","hasHorizontal","hasVertical","allowedRight","allowedLeft","allowedUp","allowedDown","horizontalGateRight","horizontalGateLeft","verticalGateUp","verticalGateDown","shouldActivate","shouldFail","hasEnoughHorizontalMovement","hasAcceptableVerticalDeviation","rightOk","leftOk","hasEnoughVerticalMovement","hasAcceptableHorizontalDeviation","upOk","downOk","applyOffsetRules","touch","directions","manager","gestureOffsetState","activationArea","vertical","verticalInverted","horizontal","horizontalInverted","value","GestureOffsetState","PENDING","PASSED","FAILED","fail","exports"],"sourceRoot":"../../../../src","sources":["utils/gesture/check-gesture-activation.ts"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AA4DA;AACA;AACA;AACA,MAAMC,8BAA8B,GAAG,EAAE;AACzC,MAAMC,8BAA8B,GAAG,EAAE;AACzC,MAAMC,wBAAwB,GAAG,EAAE;AACnC,MAAMC,wBAAwB,GAAG,EAAE;AACnC,MAAMC,gCAAgC,GAAG,EAAE;AAC3C,MAAMC,8BAA8B,GAAG,GAAG;AAC1C,MAAMC,uBAAuB,GAAG,QAAiB;AAEjD,SAASC,cAAcA,CAACC,IAA4B,EAAmB;EACtE,SAAS;;EACT,IAAI,CAACA,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACtC,MAAMC,IAAoB,GAAGD,IAAI,IAAIF,uBAAuB;IAC5D,OAAO;MAAEI,IAAI,EAAED,IAAI;MAAEE,KAAK,EAAEF,IAAI;MAAEG,GAAG,EAAEH,IAAI;MAAEI,MAAM,EAAEJ;IAAK,CAAC;EAC5D;EAEA,MAAMK,CAAiB,GAAGN,IAAsB;EAChD,OAAO;IACNE,IAAI,EAAEI,CAAC,CAACJ,IAAI,IAAIJ,uBAAuB;IACvCK,KAAK,EAAEG,CAAC,CAACH,KAAK,IAAIL,uBAAuB;IACzCM,GAAG,EAAEE,CAAC,CAACF,GAAG,IAAIN,uBAAuB;IACrCO,MAAM,EAAEC,CAAC,CAACD,MAAM,IAAIP;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CAAC,CAAC;EAEF,IAAIgB,cAAc,EAAE;IACnBc,kBAAkB,CAACM,KAAK,GAAGC,2BAAkB,CAACE,MAAM;EACrD,CAAC,MAAM,IAAItB,UAAU,EAAE;IACtBa,kBAAkB,CAACM,KAAK,GAAGC,2BAAkB,CAACG,MAAM;IACpDX,OAAO,EAAEY,IAAI,CAAC,CAAC;EAChB;EAEA,OAAO;IACNzC,aAAa;IACbC,WAAW;IACXC,cAAc;IACdC;EACD,CAAC;AACF,CAAC;AAACuC,OAAA,CAAAhB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.determineDismissal = void 0;
|
|
7
|
+
// Note: we normalize velocity by the axis dimension to map px/s to progress/s.
|
|
8
|
+
// This produces consistent behavior across devices and enables realistic bounce.
|
|
9
|
+
|
|
10
|
+
const MAX_PROGRESS_VELOCITY = 3.5; // ~3 progress units/second
|
|
11
|
+
|
|
12
|
+
const getAxisThreshold = ({
|
|
13
|
+
translation,
|
|
14
|
+
velocity,
|
|
15
|
+
screenSize,
|
|
16
|
+
gestureVelocityImpact
|
|
17
|
+
}) => {
|
|
18
|
+
"worklet";
|
|
19
|
+
|
|
20
|
+
const finalTranslation = translation + velocity * gestureVelocityImpact;
|
|
21
|
+
return Math.abs(finalTranslation) > screenSize / 2 && (velocity !== 0 || translation !== 0);
|
|
22
|
+
};
|
|
23
|
+
const getVelocity = (dimensions, velocityX, velocityY, dismissAxis) => {
|
|
24
|
+
"worklet";
|
|
25
|
+
|
|
26
|
+
const axisSize = dismissAxis === "y" ? dimensions.height : dimensions.width;
|
|
27
|
+
const axisVelocityPx = dismissAxis === "y" ? velocityY : velocityX;
|
|
28
|
+
let velocity = axisVelocityPx / Math.max(1, axisSize);
|
|
29
|
+
if (velocity > MAX_PROGRESS_VELOCITY) velocity = MAX_PROGRESS_VELOCITY;
|
|
30
|
+
if (velocity < -MAX_PROGRESS_VELOCITY) velocity = -MAX_PROGRESS_VELOCITY;
|
|
31
|
+
return velocity;
|
|
32
|
+
};
|
|
33
|
+
const determineDismissal = ({
|
|
34
|
+
event,
|
|
35
|
+
directions,
|
|
36
|
+
dimensions,
|
|
37
|
+
gestureVelocityImpact
|
|
38
|
+
}) => {
|
|
39
|
+
"worklet";
|
|
40
|
+
|
|
41
|
+
let shouldDismiss = false;
|
|
42
|
+
let dismissAxis = "x";
|
|
43
|
+
if (directions.vertical && event.translationY > 0) {
|
|
44
|
+
const dismiss = getAxisThreshold({
|
|
45
|
+
translation: event.translationY,
|
|
46
|
+
velocity: event.velocityY,
|
|
47
|
+
screenSize: dimensions.height,
|
|
48
|
+
gestureVelocityImpact
|
|
49
|
+
});
|
|
50
|
+
if (dismiss) {
|
|
51
|
+
dismissAxis = "y";
|
|
52
|
+
shouldDismiss = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (directions.verticalInverted && event.translationY < 0) {
|
|
56
|
+
const dismiss = getAxisThreshold({
|
|
57
|
+
translation: event.translationY,
|
|
58
|
+
velocity: event.velocityY,
|
|
59
|
+
screenSize: dimensions.height,
|
|
60
|
+
gestureVelocityImpact
|
|
61
|
+
});
|
|
62
|
+
if (dismiss) {
|
|
63
|
+
dismissAxis = "y";
|
|
64
|
+
shouldDismiss = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (directions.horizontal && event.translationX > 0) {
|
|
68
|
+
const dismiss = getAxisThreshold({
|
|
69
|
+
translation: event.translationX,
|
|
70
|
+
velocity: event.velocityX,
|
|
71
|
+
screenSize: dimensions.width,
|
|
72
|
+
gestureVelocityImpact
|
|
73
|
+
});
|
|
74
|
+
if (dismiss) {
|
|
75
|
+
dismissAxis = "x";
|
|
76
|
+
shouldDismiss = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (directions.horizontalInverted && event.translationX < 0) {
|
|
80
|
+
const dismiss = getAxisThreshold({
|
|
81
|
+
translation: event.translationX,
|
|
82
|
+
velocity: event.velocityX,
|
|
83
|
+
screenSize: dimensions.width,
|
|
84
|
+
gestureVelocityImpact
|
|
85
|
+
});
|
|
86
|
+
if (dismiss) {
|
|
87
|
+
dismissAxis = "x";
|
|
88
|
+
shouldDismiss = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const velocity = getVelocity(dimensions, event.velocityX, event.velocityY, dismissAxis);
|
|
92
|
+
return {
|
|
93
|
+
shouldDismiss,
|
|
94
|
+
velocity
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
exports.determineDismissal = determineDismissal;
|
|
98
|
+
//# sourceMappingURL=determine-dismissal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MAX_PROGRESS_VELOCITY","getAxisThreshold","translation","velocity","screenSize","gestureVelocityImpact","finalTranslation","Math","abs","getVelocity","dimensions","velocityX","velocityY","dismissAxis","axisSize","height","width","axisVelocityPx","max","determineDismissal","event","directions","shouldDismiss","vertical","translationY","dismiss","verticalInverted","horizontal","translationX","horizontalInverted","exports"],"sourceRoot":"../../../../src","sources":["utils/gesture/determine-dismissal.ts"],"mappings":";;;;;;AAwBA;AACA;;AAEA,MAAMA,qBAAqB,GAAG,GAAG,CAAC,CAAC;;AAEnC,MAAMC,gBAAgB,GAAGA,CAAC;EACzBC,WAAW;EACXC,QAAQ;EACRC,UAAU;EACVC;AACsB,CAAC,KAAK;EAC5B,SAAS;;EACT,MAAMC,gBAAgB,GAAGJ,WAAW,GAAGC,QAAQ,GAAGE,qBAAqB;EAEvE,OACCE,IAAI,CAACC,GAAG,CAACF,gBAAgB,CAAC,GAAGF,UAAU,GAAG,CAAC,KAC1CD,QAAQ,KAAK,CAAC,IAAID,WAAW,KAAK,CAAC,CAAC;AAEvC,CAAC;AAED,MAAMO,WAAW,GAAGA,CACnBC,UAA6C,EAC7CC,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AU,EAAEM,UAAU,CAACK,MAAM;MAC7BV;IACD,CAAC,CAAC;IACF,IAAIoB,OAAO,EAAE;MACZZ,WAAW,GAAG,GAAG;MACjBS,aAAa,GAAG,IAAI;IACrB;EACD;EACA,IAAID,UAAU,CAACM,UAAU,IAAIP,KAAK,CAACQ,YAAY,GAAG,CAAC,EAAE;IACpD,MAAMH,OAAO,GAAGxB,gBAAgB,CAAC;MAChCC,WAAW,EAAEkB,KAAK,CAACQ,YAAY;MAC/BzB,QAAQ,EAAEiB,KAAK,CAACT,SAAS;MACzBP,UAAU,EAAEM,UAAU,CAACM,KAAK;MAC5BX;IACD,CAAC,CAAC;IACF,IAAIoB,OAAO,EAAE;MACZZ,WAAW,GAAG,GAAG;MACjBS,aAAa,GAAG,IAAI;IACrB;EACD;EACA,IAAID,UAAU,CAACQ,kBAAkB,IAAIT,KAAK,CAACQ,YAAY,GAAG,CAAC,EAAE;IAC5D,MAAMH,OAAO,GAAGxB,gBAAgB,CAAC;MAChCC,WAAW,EAAEkB,KAAK,CAACQ,YAAY;MAC/BzB,QAAQ,EAAEiB,KAAK,CAACT,SAAS;MACzBP,UAAU,EAAEM,UAAU,CAACM,KAAK;MAC5BX;IACD,CAAC,CAAC;IAEF,IAAIoB,OAAO,EAAE;MACZZ,WAAW,GAAG,GAAG;MACjBS,aAAa,GAAG,IAAI;IACrB;EACD;EAEA,MAAMnB,QAAQ,GAAGM,WAAW,CAC3BC,UAAU,EACVU,KAAK,CAACT,SAAS,EACfS,KAAK,CAACR,SAAS,EACfC,WACD,CAAC;EAED,OAAO;IAAES,aAAa;IAAEnB;EAAS,CAAC;AACnC,CAAC;AAAC2B,OAAA,CAAAX,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ import { useMemo } from "react";
|
|
|
4
4
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
5
5
|
import { Bounds } from "../stores/bounds";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
export const
|
|
7
|
+
export const BoundCapture = ({
|
|
8
8
|
sharedBoundTag,
|
|
9
9
|
children,
|
|
10
10
|
measure
|
|
@@ -25,4 +25,4 @@ export const BoundActivator = ({
|
|
|
25
25
|
children: children
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=
|
|
28
|
+
//# sourceMappingURL=bound-capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","Gesture","GestureDetector","Bounds","jsx","_jsx","BoundCapture","sharedBoundTag","children","measure","tapGesture","Tap","onStart","setActiveBoundId","gesture"],"sourceRoot":"../../../src","sources":["components/bound-capture.tsx"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,OAAO,EAAEC,eAAe,QAAQ,8BAA8B;AACvE,SAASC,MAAM,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQ1C,OAAO,MAAMC,YAAY,GAAGA,CAAC;EAC5BC,cAAc;EACdC,QAAQ;EACRC;AACoB,CAAC,KAAK;EAC1B,MAAMC,UAAU,GAAGV,OAAO,CAAC,MAAM;IAChC,OAAOC,OAAO,CAACU,GAAG,CAAC,CAAC,CAACC,OAAO,CAAC,MAAM;MAClC,SAAS;;MACT,IAAIL,cAAc,EAAE;QACnBJ,MAAM,CAACU,gBAAgB,CAACN,cAAc,CAAC;QACvCE,OAAO,CAAC,CAAC;MACV;IACD,CAAC,CAAC;EACH,CAAC,EAAE,CAACF,cAAc,EAAEE,OAAO,CAAC,CAAC;EAE7B,IAAI,CAACF,cAAc,EAAE,OAAOC,QAAQ;EAEpC,oBAAOH,IAAA,CAACH,eAAe;IAACY,OAAO,EAAEJ,UAAW;IAAAF,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AAC1E,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useLayoutEffect } from "react";
|
|
4
|
+
import { useParentGestureRegistry } from "../../hooks/gestures/use-parent-gesture-registry";
|
|
4
5
|
import useStableCallback from "../../hooks/use-stable-callback";
|
|
5
6
|
import { useKeys } from "../../providers/keys";
|
|
6
7
|
import { Animations } from "../../stores/animations";
|
|
@@ -20,20 +21,30 @@ export const ScreenLifecycleController = ({
|
|
|
20
21
|
|
|
21
22
|
// Don't run e.preventDefault when the dismissal was on the local root
|
|
22
23
|
if (requestedDismissOnNavigator) {
|
|
23
|
-
resetStoresForScreen(current
|
|
24
|
+
resetStoresForScreen(current, {
|
|
25
|
+
clearActive: true
|
|
26
|
+
});
|
|
24
27
|
return;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
// Don't run e.preventDefault when this is the first screen of the stack
|
|
28
31
|
if (current.navigation.getState().index === 0) {
|
|
29
|
-
resetStoresForScreen(current
|
|
32
|
+
resetStoresForScreen(current, {
|
|
33
|
+
clearActive: true
|
|
34
|
+
});
|
|
30
35
|
return;
|
|
31
36
|
}
|
|
32
37
|
e.preventDefault();
|
|
33
38
|
const onFinish = finished => {
|
|
34
39
|
if (finished) {
|
|
35
|
-
resetStoresForScreen(current);
|
|
36
40
|
current.navigation.dispatch(e.data.action);
|
|
41
|
+
|
|
42
|
+
// we'll ensure the dispatch is complete before resetting stores
|
|
43
|
+
requestAnimationFrame(() => {
|
|
44
|
+
resetStoresForScreen(current, {
|
|
45
|
+
clearActive: false
|
|
46
|
+
});
|
|
47
|
+
});
|
|
37
48
|
}
|
|
38
49
|
};
|
|
39
50
|
runTransition({
|
|
@@ -50,11 +61,14 @@ export const ScreenLifecycleController = ({
|
|
|
50
61
|
animations
|
|
51
62
|
});
|
|
52
63
|
});
|
|
53
|
-
useLayoutEffect(handleInitialize, []);
|
|
54
64
|
useEffect(() => {
|
|
55
65
|
const unsubscribe = current.navigation.addListener("beforeRemove", handleBeforeRemove);
|
|
56
66
|
return unsubscribe;
|
|
57
67
|
}, [current.navigation, handleBeforeRemove]);
|
|
68
|
+
useLayoutEffect(handleInitialize, []);
|
|
69
|
+
|
|
70
|
+
// important for t.a scrollviews inside nested navigators.
|
|
71
|
+
useParentGestureRegistry();
|
|
58
72
|
return children;
|
|
59
73
|
};
|
|
60
74
|
//# sourceMappingURL=screen-lifecycle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","useStableCallback","useKeys","Animations","NavigatorDismissState","resetStoresForScreen","runTransition","ScreenLifecycleController","children","current","animations","getAll","route","key","handleBeforeRemove","e","navigation","getParent","getState","requestedDismissOnNavigator","get","index","preventDefault","onFinish","finished","dispatch","data","action","target","spec","options","transitionSpec","handleInitialize","unsubscribe","addListener"],"sourceRoot":"../../../../src","sources":["components/controllers/screen-lifecycle.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAClD,OAAOC,iBAAiB,MAAM,iCAAiC;AAC/D,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,qBAAqB,QAAQ,sCAAsC;AAC5E,SAASC,oBAAoB,QAAQ,4CAA4C;AACjF,SAASC,aAAa,QAAQ,sCAAsC;AAMpE,OAAO,MAAMC,yBAAyB,GAAGA,CAAC;EACzCC;AACqB,CAAC,KAAK;EAC3B,MAAM;IAAEC;EAAQ,CAAC,GAAGP,OAAO,CAAC,CAAC;EAE7B,MAAMQ,UAAU,GAAGP,UAAU,CAACQ,MAAM,CAACF,OAAO,CAACG,KAAK,CAACC,GAAG,CAAC;EAEvD,MAAMC,kBAAkB,GAAGb,iBAAiB,CAAEc,CAAM,IAAK;IACxD,MAAMF,GAAG,GAAGJ,OAAO,CAACO,UAAU,CAACC,SAAS,CAAC,CAAC,EAAEC,QAAQ,CAAC,CAAC,CAACL,GAAG;IAC1D,MAAMM,2BAA2B,GAAGf,qBAAqB,CAACgB,GAAG,CAACP,GAAG,CAAC;;IAElE;IACA,IAAIM,2BAA2B,EAAE;MAChCd,oBAAoB,CAACI,OAAO,CAAC;
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","useParentGestureRegistry","useStableCallback","useKeys","Animations","NavigatorDismissState","resetStoresForScreen","runTransition","ScreenLifecycleController","children","current","animations","getAll","route","key","handleBeforeRemove","e","navigation","getParent","getState","requestedDismissOnNavigator","get","clearActive","index","preventDefault","onFinish","finished","dispatch","data","action","requestAnimationFrame","target","spec","options","transitionSpec","handleInitialize","unsubscribe","addListener"],"sourceRoot":"../../../../src","sources":["components/controllers/screen-lifecycle.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAClD,SAASC,wBAAwB,QAAQ,kDAAkD;AAC3F,OAAOC,iBAAiB,MAAM,iCAAiC;AAC/D,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,qBAAqB,QAAQ,sCAAsC;AAC5E,SAASC,oBAAoB,QAAQ,4CAA4C;AACjF,SAASC,aAAa,QAAQ,sCAAsC;AAMpE,OAAO,MAAMC,yBAAyB,GAAGA,CAAC;EACzCC;AACqB,CAAC,KAAK;EAC3B,MAAM;IAAEC;EAAQ,CAAC,GAAGP,OAAO,CAAC,CAAC;EAE7B,MAAMQ,UAAU,GAAGP,UAAU,CAACQ,MAAM,CAACF,OAAO,CAACG,KAAK,CAACC,GAAG,CAAC;EAEvD,MAAMC,kBAAkB,GAAGb,iBAAiB,CAAEc,CAAM,IAAK;IACxD,MAAMF,GAAG,GAAGJ,OAAO,CAACO,UAAU,CAACC,SAAS,CAAC,CAAC,EAAEC,QAAQ,CAAC,CAAC,CAACL,GAAG;IAC1D,MAAMM,2BAA2B,GAAGf,qBAAqB,CAACgB,GAAG,CAACP,GAAG,CAAC;;IAElE;IACA,IAAIM,2BAA2B,EAAE;MAChCd,oBAAoB,CAACI,OAAO,EAAE;QAAEY,WAAW,EAAE;MAAK,CAAC,CAAC;MACpD;IACD;;I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|
4
4
|
import { GestureDetector } from "react-native-gesture-handler";
|
|
5
5
|
import Animated, { runOnUI, useAnimatedRef } from "react-native-reanimated";
|
|
6
6
|
import { useAssociatedStyles } from "../hooks/animation/use-associated-style";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { useBoundsRegistry } from "../hooks/bounds/use-bound-registry";
|
|
8
|
+
import { useScrollRegistry } from "../hooks/gestures/use-scroll-registry";
|
|
9
9
|
import { useGestureContext } from "../providers/gestures";
|
|
10
10
|
import { useKeys } from "../providers/keys";
|
|
11
|
-
import {
|
|
11
|
+
import { BoundCapture } from "./bound-capture";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
export function createTransitionAwareComponent(Wrapped, options = {}) {
|
|
14
14
|
const {
|
|
@@ -23,10 +23,10 @@ export function createTransitionAwareComponent(Wrapped, options = {}) {
|
|
|
23
23
|
scrollHandler,
|
|
24
24
|
onContentSizeChange,
|
|
25
25
|
onLayout
|
|
26
|
-
} =
|
|
26
|
+
} = useScrollRegistry({
|
|
27
27
|
onScroll: props.onScroll,
|
|
28
28
|
onContentSizeChange: props.onContentSizeChange,
|
|
29
|
-
onLayout: props.onLayout
|
|
29
|
+
onLayout: props.onLayout
|
|
30
30
|
});
|
|
31
31
|
return /*#__PURE__*/_jsx(GestureDetector, {
|
|
32
32
|
gesture: nativeGesture,
|
|
@@ -59,9 +59,9 @@ export function createTransitionAwareComponent(Wrapped, options = {}) {
|
|
|
59
59
|
id: sharedBoundTag || styleId
|
|
60
60
|
});
|
|
61
61
|
const {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} =
|
|
62
|
+
measureBounds,
|
|
63
|
+
handleLayout
|
|
64
|
+
} = useBoundsRegistry({
|
|
65
65
|
sharedBoundTag,
|
|
66
66
|
animatedRef,
|
|
67
67
|
current,
|
|
@@ -70,18 +70,20 @@ export function createTransitionAwareComponent(Wrapped, options = {}) {
|
|
|
70
70
|
if (isScrollable) {
|
|
71
71
|
return /*#__PURE__*/_jsx(ScrollableInner, {
|
|
72
72
|
...props,
|
|
73
|
-
ref: ref
|
|
73
|
+
ref: ref,
|
|
74
|
+
measureBounds: measureBounds,
|
|
75
|
+
handleLayout: handleLayout
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
|
-
return /*#__PURE__*/_jsx(
|
|
78
|
+
return /*#__PURE__*/_jsx(BoundCapture, {
|
|
77
79
|
sharedBoundTag: sharedBoundTag,
|
|
78
|
-
measure:
|
|
80
|
+
measure: measureBounds,
|
|
79
81
|
children: /*#__PURE__*/_jsx(AnimatedComponent, {
|
|
80
82
|
...rest,
|
|
81
83
|
ref: animatedRef,
|
|
82
84
|
style: [style, associatedStyles],
|
|
83
85
|
onPress: onPress,
|
|
84
|
-
onLayout: runOnUI(
|
|
86
|
+
onLayout: runOnUI(handleLayout),
|
|
85
87
|
children: children
|
|
86
88
|
})
|
|
87
89
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","memo","GestureDetector","Animated","runOnUI","useAnimatedRef","useAssociatedStyles","
|
|
1
|
+
{"version":3,"names":["forwardRef","memo","GestureDetector","Animated","runOnUI","useAnimatedRef","useAssociatedStyles","useBoundsRegistry","useScrollRegistry","useGestureContext","useKeys","BoundCapture","jsx","_jsx","createTransitionAwareComponent","Wrapped","options","isScrollable","AnimatedComponent","createAnimatedComponent","ScrollableInner","props","ref","nativeGesture","scrollHandler","onContentSizeChange","onLayout","onScroll","gesture","children","scrollEventThrottle","Inner","style","sharedBoundTag","styleId","onPress","rest","animatedRef","current","associatedStyles","id","measureBounds","handleLayout","measure"],"sourceRoot":"../../../src","sources":["components/create-transition-aware-component.tsx"],"mappings":";;AACA,SAA6BA,UAAU,EAAEC,IAAI,QAAQ,OAAO;AAE5D,SAASC,eAAe,QAAQ,8BAA8B;AAC9D,OAAOC,QAAQ,IAAIC,OAAO,EAAEC,cAAc,QAAQ,yBAAyB;AAC3E,SAASC,mBAAmB,QAAQ,yC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AAc;MAAEC,OAAO;MAAEC,OAAO;MAAE,GAAGC;IAAK,CAAC,GACnEf,KAAY;IAEb,MAAMgB,WAAW,GAAGhC,cAAc,CAAO,CAAC;IAC1C,MAAM;MAAEiC;IAAQ,CAAC,GAAG5B,OAAO,CAAC,CAAC;IAE7B,MAAM;MAAE6B;IAAiB,CAAC,GAAGjC,mBAAmB,CAAC;MAChDkC,EAAE,EAAEP,cAAc,IAAIC;IACvB,CAAC,CAAC;IAEF,MAAM;MAAEO,aAAa;MAAEC;IAAa,CAAC,GAAGnC,iBAAiB,CAAC;MACzD0B,cAAc;MACdI,WAAW;MACXC,OAAO;MACPN;IACD,CAAC,CAAC;IAEF,IAAIf,YAAY,EAAE;MACjB,oBACCJ,IAAA,CAACO,eAAe;QAAA,GACVC,KAAK;QACVC,GAAG,EAAEA,GAAI;QACTmB,aAAa,EAAEA,aAAc;QAC7BC,YAAY,EAAEA;MAAa,CAC3B,CAAC;IAEJ;IAEA,oBACC7B,IAAA,CAACF,YAAY;MAACsB,cAAc,EAAEA,cAAe;MAACU,OAAO,EAAEF,aAAc;MAAAZ,QAAA,eACpEhB,IAAA,CAACK,iBAAiB;QAAA,GACZkB,IAAI;QACTd,GAAG,EAAEe,WAAY;QACjBL,KAAK,EAAE,CAACA,KAAK,EAAEO,gBAAgB,CAAE;QACjCJ,OAAO,EAAEA,OAAQ;QACjBT,QAAQ,EAAEtB,OAAO,CAACsC,YAAY,CAAE;QAAAb,QAAA,EAE/BA;MAAQ,CACS;IAAC,CACP,CAAC;EAEjB,CAAC,CAAC;EAEF,oBAAO5B,IAAI,CAAC8B,KAAK,CAAC;AAMnB","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { StyleSheet, View } from "react-native";
|
|
4
|
+
import { createTransitionAwareComponent } from "../create-transition-aware-component";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const TransitionView = createTransitionAwareComponent(View);
|
|
7
|
+
let LazyMaskedView = View;
|
|
8
|
+
try {
|
|
9
|
+
LazyMaskedView = require("@react-native-masked-view/masked-view").default;
|
|
10
|
+
} catch (_) {
|
|
11
|
+
// noop
|
|
12
|
+
}
|
|
13
|
+
const MASK_STYLE_ID = "_ROOT_MASKED";
|
|
14
|
+
const CONTAINER_STYLE_ID = "_ROOT_CONTAINER";
|
|
15
|
+
export default function MaskedView({
|
|
16
|
+
children,
|
|
17
|
+
style: userStyles = {}
|
|
18
|
+
}) {
|
|
19
|
+
if (LazyMaskedView === View) {
|
|
20
|
+
return children;
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/_jsx(LazyMaskedView, {
|
|
23
|
+
style: styles.root
|
|
24
|
+
// @ts-expect-error
|
|
25
|
+
,
|
|
26
|
+
maskElement: /*#__PURE__*/_jsx(TransitionView, {
|
|
27
|
+
styleId: MASK_STYLE_ID,
|
|
28
|
+
style: styles.rootMask
|
|
29
|
+
}),
|
|
30
|
+
children: /*#__PURE__*/_jsx(TransitionView, {
|
|
31
|
+
styleId: CONTAINER_STYLE_ID,
|
|
32
|
+
style: [styles.rootContainer, userStyles],
|
|
33
|
+
children: children
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const styles = StyleSheet.create({
|
|
38
|
+
root: {
|
|
39
|
+
flex: 1
|
|
40
|
+
},
|
|
41
|
+
rootMask: {
|
|
42
|
+
backgroundColor: "white"
|
|
43
|
+
},
|
|
44
|
+
rootContainer: {
|
|
45
|
+
flex: 1
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=masked-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StyleSheet","View","createTransitionAwareComponent","jsx","_jsx","TransitionView","LazyMaskedView","require","default","_","MASK_STYLE_ID","CONTAINER_STYLE_ID","MaskedView","children","style","userStyles","styles","root","maskElement","styleId","rootMask","rootContainer","create","flex","backgroundColor"],"sourceRoot":"../../../../src","sources":["components/integrations/masked-view.tsx"],"mappings":";;AAAA,SAAyBA,UAAU,EAAEC,IAAI,QAAwB,cAAc;AAC/E,SAASC,8BAA8B,QAAQ,sCAAsC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEtF,MAAMC,cAAc,GAAGH,8BAA8B,CAACD,IAAI,CAAC;AAE3D,IAAIK,cAAc,GAAGL,IAAI;AAEzB,IAAI;EACHK,cAAc,GAAGC,OAAO,CAAC,uCAAuC,CAAC,CAACC,OAAO;AAC1E,CAAC,CAAC,OAAOC,CAAC,EAAE;EACX;AAAA;AAGD,MAAMC,aAAa,GAAG,cAAc;AACpC,MAAMC,kBAAkB,GAAG,iBAAiB;AAE5C,eAAe,SAASC,UAAUA,CAAC;EAClCC,QAAQ;EACRC,KAAK,EAAEC,UAAU,GAAG,CAAC;AAItB,CAAC,EAAE;EACF,IAAIT,cAAc,KAAKL,IAAI,EAAE;IAC5B,OAAOY,QAAQ;EAChB;EAEA,oBACCT,IAAA,CAACE,cAAc;IACdQ,KAAK,EAAEE,MAAM,CAACC;IACd;IAAA;IACAC,WAAW,eACVd,IAAA,CAACC,cAAc;MAACc,OAAO,EAAET,aAAc;MAACI,KAAK,EAAEE,MAAM,CAACI;IAAS,CAAE,CACjE;IAAAP,QAAA,eAEDT,IAAA,CAACC,cAAc;MACdc,OAAO,EAAER,kBAAmB;MAC5BG,KAAK,EAAE,CAACE,MAAM,CAACK,aAAa,EAAEN,UAAU,CAAE;MAAAF,QAAA,EAEzCA;IAAQ,CACM;EAAC,CACF,CAAC;AAEnB;AAEA,MAAMG,MAAM,GAAGhB,UAAU,CAACsB,MAAM,CAAC;EAChCL,IAAI,EAAE;IACLM,IAAI,EAAE;EACP,CAAC;EACDH,QAAQ,EAAE;IACTI,eAAe,EAAE;EAClB,CAAC;EACDH,aAAa,EAAE;IACdE,IAAI,EAAE;EACP;AACD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { memo } from "react";
|
|
4
|
-
import { StyleSheet } from "react-native";
|
|
4
|
+
import { StyleSheet, View } from "react-native";
|
|
5
5
|
import Animated, { useAnimatedStyle } from "react-native-reanimated";
|
|
6
|
-
import {
|
|
6
|
+
import { useTransitionStyles } from "../providers/transition-styles";
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const EMPTY_STYLE = Object.freeze({});
|
|
8
9
|
export const RootTransitionAware = /*#__PURE__*/memo(({
|
|
9
10
|
children
|
|
10
11
|
}) => {
|
|
11
|
-
const
|
|
12
|
-
screenInterpolatorProps,
|
|
13
|
-
screenStyleInterpolator
|
|
14
|
-
} = _useScreenAnimation();
|
|
12
|
+
const stylesMap = useTransitionStyles();
|
|
15
13
|
const animatedContentStyle = useAnimatedStyle(() => {
|
|
16
14
|
"worklet";
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
const props = screenInterpolatorProps.value;
|
|
22
|
-
return screenStyleInterpolator(props).contentStyle || {};
|
|
16
|
+
return stylesMap.value.contentStyle || EMPTY_STYLE;
|
|
23
17
|
});
|
|
24
18
|
const animatedOverlayStyle = useAnimatedStyle(() => {
|
|
25
19
|
"worklet";
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
return {};
|
|
29
|
-
}
|
|
30
|
-
return screenStyleInterpolator(screenInterpolatorProps.value).overlayStyle || {};
|
|
21
|
+
return stylesMap.value.overlayStyle || EMPTY_STYLE;
|
|
31
22
|
});
|
|
32
|
-
return /*#__PURE__*/_jsxs(
|
|
23
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
33
24
|
style: styles.container,
|
|
34
25
|
children: [/*#__PURE__*/_jsx(Animated.View, {
|
|
35
26
|
style: [StyleSheet.absoluteFillObject, animatedOverlayStyle],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["memo","StyleSheet","Animated","useAnimatedStyle","
|
|
1
|
+
{"version":3,"names":["memo","StyleSheet","View","Animated","useAnimatedStyle","useTransitionStyles","jsx","_jsx","jsxs","_jsxs","EMPTY_STYLE","Object","freeze","RootTransitionAware","children","stylesMap","animatedContentStyle","value","contentStyle","animatedOverlayStyle","overlayStyle","style","styles","container","absoluteFillObject","pointerEvents","content","create","flex"],"sourceRoot":"../../../src","sources":["components/root-transition-aware.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,OAAO;AAC5B,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC/C,OAAOC,QAAQ,IAEdC,gBAAgB,QACV,yBAAyB;AAChC,SAASC,mBAAmB,QAAQ,gCAAgC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAMrE,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAe,CAAC;AAEnD,OAAO,MAAMC,mBAAmB,gBAAGb,IAAI,CAAC,CAAC;EAAEc;AAAgB,CAAC,KAAK;EAChE,MAAMC,SAAS,GAAGV,mBAAmB,CAAC,CAAC;EAEvC,MAAMW,oBAAoB,GAAGZ,gBAAgB,CAAC,MAAM;IACnD,SAAS;;IACT,OAAOW,SAAS,CAACE,KAAK,CAACC,YAAY,IAAIR,WAAW;EACnD,CAAC,CAAC;EAEF,MAAMS,oBAAoB,GAAGf,gBAAgB,CAAC,MAAM;IACnD,SAAS;;IACT,OAAOW,SAAS,CAACE,KAAK,CAACG,YAAY,IAAIV,WAAW;EACnD,CAAC,CAAC;EAEF,oBACCD,KAAA,CAACP,IAAI;IAACmB,KAAK,EAAEC,MAAM,CAACC,SAAU;IAAAT,QAAA,gBAC7BP,IAAA,CAACJ,QAAQ,CAACD,IAAI;MACbmB,KAAK,EAAE,CAACpB,UAAU,CAACuB,kBAAkB,EAAEL,oBAAoB,CAAE;MAC7DM,aAAa,EAAC;IAAM,CACpB,CAAC,eACFlB,IAAA,CAACJ,QA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