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,310 @@
|
|
|
1
|
+
import type { ScaledSize } from "react-native";
|
|
2
|
+
import type { GestureStateManagerType } from "react-native-gesture-handler/lib/typescript/handlers/gestures/gestureStateManager";
|
|
3
|
+
import type { SharedValue } from "react-native-reanimated";
|
|
4
|
+
import {
|
|
5
|
+
type ActivationArea,
|
|
6
|
+
type GestureActivationArea,
|
|
7
|
+
GestureOffsetState,
|
|
8
|
+
type SideActivation,
|
|
9
|
+
} from "../../types/gesture";
|
|
10
|
+
|
|
11
|
+
type Directions = {
|
|
12
|
+
vertical: boolean;
|
|
13
|
+
verticalInverted: boolean;
|
|
14
|
+
horizontal: boolean;
|
|
15
|
+
horizontalInverted: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
interface CheckGestureActivationProps {
|
|
19
|
+
initialTouch: { x: number; y: number };
|
|
20
|
+
touch: { x: number; y: number };
|
|
21
|
+
directions: Directions;
|
|
22
|
+
manager?: GestureStateManagerType;
|
|
23
|
+
gestureOffsetState: SharedValue<GestureOffsetState>;
|
|
24
|
+
activationArea?: GestureActivationArea;
|
|
25
|
+
dimensions: ScaledSize;
|
|
26
|
+
responseDistance?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type NormalizedSides = {
|
|
30
|
+
left: ActivationArea;
|
|
31
|
+
right: ActivationArea;
|
|
32
|
+
top: ActivationArea;
|
|
33
|
+
bottom: ActivationArea;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
interface ShouldActivateOrFailProps {
|
|
37
|
+
deltaX: number;
|
|
38
|
+
deltaY: number;
|
|
39
|
+
hasHorizontal: boolean;
|
|
40
|
+
hasVertical: boolean;
|
|
41
|
+
isHorizontalSwipe: boolean;
|
|
42
|
+
isVerticalSwipe: boolean;
|
|
43
|
+
allowedRight: boolean;
|
|
44
|
+
allowedLeft: boolean;
|
|
45
|
+
allowedUp: boolean;
|
|
46
|
+
allowedDown: boolean;
|
|
47
|
+
horizontalGateRight: boolean;
|
|
48
|
+
horizontalGateLeft: boolean;
|
|
49
|
+
verticalGateUp: boolean;
|
|
50
|
+
verticalGateDown: boolean;
|
|
51
|
+
isSwipingRight: boolean;
|
|
52
|
+
isSwipingLeft: boolean;
|
|
53
|
+
isSwipingUp: boolean;
|
|
54
|
+
isSwipingDown: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface ReturnValues {
|
|
58
|
+
isSwipingDown: boolean;
|
|
59
|
+
isSwipingUp: boolean;
|
|
60
|
+
isSwipingRight: boolean;
|
|
61
|
+
isSwipingLeft: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 10 seems like the correct threshold for compatability with nested gestures outside of our package.
|
|
66
|
+
*/
|
|
67
|
+
const GESTURE_ACTIVATION_THRESHOLD_X = 10;
|
|
68
|
+
const GESTURE_ACTIVATION_THRESHOLD_Y = 10;
|
|
69
|
+
const GESTURE_FAIL_TOLERANCE_X = 15;
|
|
70
|
+
const GESTURE_FAIL_TOLERANCE_Y = 20;
|
|
71
|
+
const DEFAULT_EDGE_DISTANCE_HORIZONTAL = 50;
|
|
72
|
+
const DEFAULT_EDGE_DISTANCE_VERTICAL = 135;
|
|
73
|
+
const DEFAULT_ACTIVATION_AREA = "screen" as const;
|
|
74
|
+
|
|
75
|
+
function normalizeSides(area?: GestureActivationArea): NormalizedSides {
|
|
76
|
+
"worklet";
|
|
77
|
+
if (!area || typeof area === "string") {
|
|
78
|
+
const mode: ActivationArea = area ?? DEFAULT_ACTIVATION_AREA;
|
|
79
|
+
return { left: mode, right: mode, top: mode, bottom: mode };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const s: SideActivation = area as SideActivation;
|
|
83
|
+
return {
|
|
84
|
+
left: s.left ?? DEFAULT_ACTIVATION_AREA,
|
|
85
|
+
right: s.right ?? DEFAULT_ACTIVATION_AREA,
|
|
86
|
+
top: s.top ?? DEFAULT_ACTIVATION_AREA,
|
|
87
|
+
bottom: s.bottom ?? DEFAULT_ACTIVATION_AREA,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function computeEdgeConstraints(
|
|
92
|
+
initialTouch: { x: number; y: number },
|
|
93
|
+
dimensions: ScaledSize,
|
|
94
|
+
sides: NormalizedSides,
|
|
95
|
+
responseDistance?: number,
|
|
96
|
+
) {
|
|
97
|
+
"worklet";
|
|
98
|
+
const xDist = responseDistance ?? DEFAULT_EDGE_DISTANCE_HORIZONTAL;
|
|
99
|
+
const yDist = responseDistance ?? DEFAULT_EDGE_DISTANCE_VERTICAL;
|
|
100
|
+
|
|
101
|
+
const horizontalRight = sides.left === "screen" || initialTouch.x <= xDist; // right swipe checks left edge
|
|
102
|
+
const horizontalLeft =
|
|
103
|
+
sides.right === "screen" || initialTouch.x >= dimensions.width - xDist; // left swipe checks right edge
|
|
104
|
+
const verticalDown = sides.top === "screen" || initialTouch.y <= yDist; // down swipe checks top edge
|
|
105
|
+
const verticalUp =
|
|
106
|
+
sides.bottom === "screen" || initialTouch.y >= dimensions.height - yDist; // up swipe checks bottom edge
|
|
107
|
+
|
|
108
|
+
return { horizontalRight, horizontalLeft, verticalDown, verticalUp } as const;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function calculateSwipeDirs(deltaX: number, deltaY: number) {
|
|
112
|
+
"worklet";
|
|
113
|
+
|
|
114
|
+
const isVerticalSwipe = Math.abs(deltaY) > Math.abs(deltaX);
|
|
115
|
+
const isHorizontalSwipe = Math.abs(deltaX) > Math.abs(deltaY);
|
|
116
|
+
|
|
117
|
+
const isSwipingDown = isVerticalSwipe && deltaY > 0;
|
|
118
|
+
const isSwipingUp = isVerticalSwipe && deltaY < 0;
|
|
119
|
+
const isSwipingRight = isHorizontalSwipe && deltaX > 0;
|
|
120
|
+
const isSwipingLeft = isHorizontalSwipe && deltaX < 0;
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
isSwipingDown,
|
|
124
|
+
isSwipingUp,
|
|
125
|
+
isSwipingRight,
|
|
126
|
+
isSwipingLeft,
|
|
127
|
+
isVerticalSwipe,
|
|
128
|
+
isHorizontalSwipe,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function shouldActivateOrFail(params: ShouldActivateOrFailProps) {
|
|
133
|
+
"worklet";
|
|
134
|
+
|
|
135
|
+
const {
|
|
136
|
+
deltaX,
|
|
137
|
+
deltaY,
|
|
138
|
+
hasHorizontal,
|
|
139
|
+
hasVertical,
|
|
140
|
+
isHorizontalSwipe,
|
|
141
|
+
isVerticalSwipe,
|
|
142
|
+
allowedRight,
|
|
143
|
+
allowedLeft,
|
|
144
|
+
allowedUp,
|
|
145
|
+
allowedDown,
|
|
146
|
+
horizontalGateRight,
|
|
147
|
+
horizontalGateLeft,
|
|
148
|
+
verticalGateUp,
|
|
149
|
+
verticalGateDown,
|
|
150
|
+
isSwipingRight,
|
|
151
|
+
isSwipingLeft,
|
|
152
|
+
isSwipingUp,
|
|
153
|
+
isSwipingDown,
|
|
154
|
+
} = params;
|
|
155
|
+
|
|
156
|
+
let shouldActivate = false;
|
|
157
|
+
let shouldFail = false;
|
|
158
|
+
|
|
159
|
+
if (hasHorizontal && isHorizontalSwipe) {
|
|
160
|
+
const hasEnoughHorizontalMovement =
|
|
161
|
+
Math.abs(deltaX) >= GESTURE_ACTIVATION_THRESHOLD_X;
|
|
162
|
+
|
|
163
|
+
const hasAcceptableVerticalDeviation =
|
|
164
|
+
Math.abs(deltaY) <= GESTURE_FAIL_TOLERANCE_X;
|
|
165
|
+
|
|
166
|
+
if (hasEnoughHorizontalMovement && hasAcceptableVerticalDeviation) {
|
|
167
|
+
const rightOk = isSwipingRight && allowedRight && horizontalGateRight;
|
|
168
|
+
const leftOk = isSwipingLeft && allowedLeft && horizontalGateLeft;
|
|
169
|
+
if (rightOk || leftOk) {
|
|
170
|
+
shouldActivate = true;
|
|
171
|
+
}
|
|
172
|
+
} else if (!hasAcceptableVerticalDeviation) {
|
|
173
|
+
shouldFail = true;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (hasVertical && isVerticalSwipe) {
|
|
178
|
+
const hasEnoughVerticalMovement =
|
|
179
|
+
Math.abs(deltaY) >= GESTURE_ACTIVATION_THRESHOLD_Y;
|
|
180
|
+
const hasAcceptableHorizontalDeviation =
|
|
181
|
+
Math.abs(deltaX) <= GESTURE_FAIL_TOLERANCE_Y;
|
|
182
|
+
|
|
183
|
+
if (hasEnoughVerticalMovement && hasAcceptableHorizontalDeviation) {
|
|
184
|
+
const upOk = isSwipingUp && allowedUp && verticalGateUp;
|
|
185
|
+
const downOk = isSwipingDown && allowedDown && verticalGateDown;
|
|
186
|
+
if (upOk || downOk) {
|
|
187
|
+
shouldActivate = true;
|
|
188
|
+
}
|
|
189
|
+
} else if (!hasAcceptableHorizontalDeviation) {
|
|
190
|
+
shouldFail = true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (hasHorizontal && isHorizontalSwipe) {
|
|
195
|
+
if ((isSwipingLeft && !allowedLeft) || (isSwipingRight && !allowedRight)) {
|
|
196
|
+
shouldFail = true;
|
|
197
|
+
}
|
|
198
|
+
// If gating prohibits the dominant horizontal swipe, fail early
|
|
199
|
+
if (
|
|
200
|
+
(isSwipingRight && allowedRight && !horizontalGateRight) ||
|
|
201
|
+
(isSwipingLeft && allowedLeft && !horizontalGateLeft)
|
|
202
|
+
) {
|
|
203
|
+
shouldFail = true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (hasVertical && isVerticalSwipe) {
|
|
208
|
+
if ((isSwipingUp && !allowedUp) || (isSwipingDown && !allowedDown)) {
|
|
209
|
+
shouldFail = true;
|
|
210
|
+
}
|
|
211
|
+
// If gating prohibits the dominant vertical swipe, fail early
|
|
212
|
+
if (
|
|
213
|
+
(isSwipingUp && allowedUp && !verticalGateUp) ||
|
|
214
|
+
(isSwipingDown && allowedDown && !verticalGateDown)
|
|
215
|
+
) {
|
|
216
|
+
shouldFail = true;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return { shouldActivate, shouldFail };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 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.
|
|
225
|
+
*/
|
|
226
|
+
export const applyOffsetRules = ({
|
|
227
|
+
initialTouch,
|
|
228
|
+
touch,
|
|
229
|
+
directions,
|
|
230
|
+
manager,
|
|
231
|
+
gestureOffsetState,
|
|
232
|
+
activationArea,
|
|
233
|
+
dimensions,
|
|
234
|
+
responseDistance,
|
|
235
|
+
}: CheckGestureActivationProps): ReturnValues => {
|
|
236
|
+
"worklet";
|
|
237
|
+
|
|
238
|
+
const deltaX = touch.x - initialTouch.x;
|
|
239
|
+
const deltaY = touch.y - initialTouch.y;
|
|
240
|
+
|
|
241
|
+
const allowedDown = directions.vertical;
|
|
242
|
+
const allowedUp = directions.verticalInverted;
|
|
243
|
+
const allowedRight = directions.horizontal;
|
|
244
|
+
const allowedLeft = directions.horizontalInverted;
|
|
245
|
+
|
|
246
|
+
const hasHorizontal = allowedLeft || allowedRight;
|
|
247
|
+
const hasVertical = allowedUp || allowedDown;
|
|
248
|
+
|
|
249
|
+
const {
|
|
250
|
+
isSwipingDown,
|
|
251
|
+
isSwipingUp,
|
|
252
|
+
isSwipingRight,
|
|
253
|
+
isSwipingLeft,
|
|
254
|
+
isVerticalSwipe,
|
|
255
|
+
isHorizontalSwipe,
|
|
256
|
+
} = calculateSwipeDirs(deltaX, deltaY);
|
|
257
|
+
|
|
258
|
+
if (gestureOffsetState.value !== GestureOffsetState.PENDING) {
|
|
259
|
+
return {
|
|
260
|
+
isSwipingDown,
|
|
261
|
+
isSwipingUp,
|
|
262
|
+
isSwipingRight,
|
|
263
|
+
isSwipingLeft,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const sides = normalizeSides(activationArea);
|
|
268
|
+
|
|
269
|
+
const {
|
|
270
|
+
horizontalRight: horizontalGateRight,
|
|
271
|
+
horizontalLeft: horizontalGateLeft,
|
|
272
|
+
verticalDown: verticalGateDown,
|
|
273
|
+
verticalUp: verticalGateUp,
|
|
274
|
+
} = computeEdgeConstraints(initialTouch, dimensions, sides, responseDistance);
|
|
275
|
+
|
|
276
|
+
const { shouldActivate, shouldFail } = shouldActivateOrFail({
|
|
277
|
+
deltaX,
|
|
278
|
+
deltaY,
|
|
279
|
+
hasHorizontal,
|
|
280
|
+
hasVertical,
|
|
281
|
+
isHorizontalSwipe,
|
|
282
|
+
isVerticalSwipe,
|
|
283
|
+
allowedRight,
|
|
284
|
+
allowedLeft,
|
|
285
|
+
allowedUp,
|
|
286
|
+
allowedDown,
|
|
287
|
+
horizontalGateRight,
|
|
288
|
+
horizontalGateLeft,
|
|
289
|
+
verticalGateUp,
|
|
290
|
+
verticalGateDown,
|
|
291
|
+
isSwipingRight,
|
|
292
|
+
isSwipingLeft,
|
|
293
|
+
isSwipingUp,
|
|
294
|
+
isSwipingDown,
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
if (shouldActivate) {
|
|
298
|
+
gestureOffsetState.value = GestureOffsetState.PASSED;
|
|
299
|
+
} else if (shouldFail) {
|
|
300
|
+
gestureOffsetState.value = GestureOffsetState.FAILED;
|
|
301
|
+
manager?.fail();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return {
|
|
305
|
+
isSwipingDown,
|
|
306
|
+
isSwipingUp,
|
|
307
|
+
isSwipingRight,
|
|
308
|
+
isSwipingLeft,
|
|
309
|
+
};
|
|
310
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
interface GetAxisThresholdProps {
|
|
2
|
+
translation: number;
|
|
3
|
+
velocity: number;
|
|
4
|
+
screenSize: number;
|
|
5
|
+
gestureVelocityImpact: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface DetermineDismissalProps {
|
|
9
|
+
event: {
|
|
10
|
+
translationX: number;
|
|
11
|
+
translationY: number;
|
|
12
|
+
velocityX: number;
|
|
13
|
+
velocityY: number;
|
|
14
|
+
};
|
|
15
|
+
directions: {
|
|
16
|
+
vertical: boolean;
|
|
17
|
+
verticalInverted: boolean;
|
|
18
|
+
horizontal: boolean;
|
|
19
|
+
horizontalInverted: boolean;
|
|
20
|
+
};
|
|
21
|
+
dimensions: { width: number; height: number };
|
|
22
|
+
gestureVelocityImpact: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Note: we normalize velocity by the axis dimension to map px/s to progress/s.
|
|
26
|
+
// This produces consistent behavior across devices and enables realistic bounce.
|
|
27
|
+
|
|
28
|
+
const MAX_PROGRESS_VELOCITY = 3.5; // ~3 progress units/second
|
|
29
|
+
|
|
30
|
+
const getAxisThreshold = ({
|
|
31
|
+
translation,
|
|
32
|
+
velocity,
|
|
33
|
+
screenSize,
|
|
34
|
+
gestureVelocityImpact,
|
|
35
|
+
}: GetAxisThresholdProps) => {
|
|
36
|
+
"worklet";
|
|
37
|
+
const finalTranslation = translation + velocity * gestureVelocityImpact;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
Math.abs(finalTranslation) > screenSize / 2 &&
|
|
41
|
+
(velocity !== 0 || translation !== 0)
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getVelocity = (
|
|
46
|
+
dimensions: { width: number; height: number },
|
|
47
|
+
velocityX: number,
|
|
48
|
+
velocityY: number,
|
|
49
|
+
dismissAxis: "x" | "y",
|
|
50
|
+
) => {
|
|
51
|
+
"worklet";
|
|
52
|
+
const axisSize = dismissAxis === "y" ? dimensions.height : dimensions.width;
|
|
53
|
+
const axisVelocityPx = dismissAxis === "y" ? velocityY : velocityX;
|
|
54
|
+
let velocity = axisVelocityPx / Math.max(1, axisSize);
|
|
55
|
+
|
|
56
|
+
if (velocity > MAX_PROGRESS_VELOCITY) velocity = MAX_PROGRESS_VELOCITY;
|
|
57
|
+
if (velocity < -MAX_PROGRESS_VELOCITY) velocity = -MAX_PROGRESS_VELOCITY;
|
|
58
|
+
|
|
59
|
+
return velocity;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const determineDismissal = ({
|
|
63
|
+
event,
|
|
64
|
+
directions,
|
|
65
|
+
dimensions,
|
|
66
|
+
gestureVelocityImpact,
|
|
67
|
+
}: DetermineDismissalProps) => {
|
|
68
|
+
"worklet";
|
|
69
|
+
|
|
70
|
+
let shouldDismiss: boolean = false;
|
|
71
|
+
let dismissAxis: "x" | "y" = "x";
|
|
72
|
+
|
|
73
|
+
if (directions.vertical && event.translationY > 0) {
|
|
74
|
+
const dismiss = getAxisThreshold({
|
|
75
|
+
translation: event.translationY,
|
|
76
|
+
velocity: event.velocityY,
|
|
77
|
+
screenSize: dimensions.height,
|
|
78
|
+
gestureVelocityImpact,
|
|
79
|
+
});
|
|
80
|
+
if (dismiss) {
|
|
81
|
+
dismissAxis = "y";
|
|
82
|
+
shouldDismiss = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (directions.verticalInverted && event.translationY < 0) {
|
|
86
|
+
const dismiss = getAxisThreshold({
|
|
87
|
+
translation: event.translationY,
|
|
88
|
+
velocity: event.velocityY,
|
|
89
|
+
screenSize: dimensions.height,
|
|
90
|
+
gestureVelocityImpact,
|
|
91
|
+
});
|
|
92
|
+
if (dismiss) {
|
|
93
|
+
dismissAxis = "y";
|
|
94
|
+
shouldDismiss = true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (directions.horizontal && event.translationX > 0) {
|
|
98
|
+
const dismiss = getAxisThreshold({
|
|
99
|
+
translation: event.translationX,
|
|
100
|
+
velocity: event.velocityX,
|
|
101
|
+
screenSize: dimensions.width,
|
|
102
|
+
gestureVelocityImpact,
|
|
103
|
+
});
|
|
104
|
+
if (dismiss) {
|
|
105
|
+
dismissAxis = "x";
|
|
106
|
+
shouldDismiss = true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (directions.horizontalInverted && event.translationX < 0) {
|
|
110
|
+
const dismiss = getAxisThreshold({
|
|
111
|
+
translation: event.translationX,
|
|
112
|
+
velocity: event.velocityX,
|
|
113
|
+
screenSize: dimensions.width,
|
|
114
|
+
gestureVelocityImpact,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
if (dismiss) {
|
|
118
|
+
dismissAxis = "x";
|
|
119
|
+
shouldDismiss = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const velocity = getVelocity(
|
|
124
|
+
dimensions,
|
|
125
|
+
event.velocityX,
|
|
126
|
+
event.velocityY,
|
|
127
|
+
dismissAxis,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
return { shouldDismiss, velocity };
|
|
131
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNativeGestureHandler","_bounds","_jsxRuntime","BoundActivator","sharedBoundTag","children","measure","tapGesture","useMemo","Gesture","Tap","onStart","Bounds","setActiveBoundId","jsx","GestureDetector","gesture","exports"],"sourceRoot":"../../../src","sources":["components/bounds-activator.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAA0C,IAAAG,WAAA,GAAAH,OAAA;AAQnC,MAAMI,cAAc,GAAGA,CAAC;EAC9BC,cAAc;EACdC,QAAQ;EACRC;AACoB,CAAC,KAAK;EAC1B,MAAMC,UAAU,GAAG,IAAAC,cAAO,EAAC,MAAM;IAChC,OAAOC,kCAAO,CAACC,GAAG,CAAC,CAAC,CAACC,OAAO,CAAC,MAAM;MAClC,SAAS;;MACT,IAAIP,cAAc,EAAE;QACnBQ,cAAM,CAACC,gBAAgB,CAACT,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,oBAAO,IAAAH,WAAA,CAAAY,GAAA,EAACd,0BAAA,CAAAe,eAAe;IAACC,OAAO,EAAET,UAAW;IAAAF,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AAC1E,CAAC;AAACY,OAAA,CAAAd,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useBoundMeasurer = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
-
var _keys = require("../../providers/keys");
|
|
10
|
-
var _bounds = require("../../stores/bounds");
|
|
11
|
-
var _flattenStyles = require("../../utils/bounds/flatten-styles");
|
|
12
|
-
var _useScreenAnimation = require("../animation/use-screen-animation");
|
|
13
|
-
const useBoundMeasurer = ({
|
|
14
|
-
sharedBoundTag,
|
|
15
|
-
animatedRef,
|
|
16
|
-
current,
|
|
17
|
-
style
|
|
18
|
-
}) => {
|
|
19
|
-
const {
|
|
20
|
-
previous
|
|
21
|
-
} = (0, _keys.useKeys)();
|
|
22
|
-
const interpolatorProps = (0, _useScreenAnimation.useScreenAnimation)();
|
|
23
|
-
const hasAlreadyMeasured = (0, _reactNativeReanimated.useSharedValue)(false);
|
|
24
|
-
const measureAndSet = (0, _react.useCallback)(() => {
|
|
25
|
-
"worklet";
|
|
26
|
-
|
|
27
|
-
if (!sharedBoundTag) return;
|
|
28
|
-
const measured = (0, _reactNativeReanimated.measure)(animatedRef);
|
|
29
|
-
if (measured) {
|
|
30
|
-
_bounds.Bounds.setBounds(current.route.key, sharedBoundTag, measured, (0, _flattenStyles.flattenStyle)(style));
|
|
31
|
-
}
|
|
32
|
-
}, [sharedBoundTag, animatedRef, current.route.key, style]);
|
|
33
|
-
const measureOnLayout = (0, _react.useCallback)(() => {
|
|
34
|
-
"worklet";
|
|
35
|
-
|
|
36
|
-
if (!sharedBoundTag || hasAlreadyMeasured.value) return;
|
|
37
|
-
const previousRouteKey = previous?.route.key;
|
|
38
|
-
if (!previousRouteKey) return;
|
|
39
|
-
const previousBounds = _bounds.Bounds.getBounds(previousRouteKey);
|
|
40
|
-
const hasPreviousBoundForTag = previousBounds[sharedBoundTag];
|
|
41
|
-
if (interpolatorProps.value.current.animating && hasPreviousBoundForTag) {
|
|
42
|
-
measureAndSet();
|
|
43
|
-
hasAlreadyMeasured.value = true;
|
|
44
|
-
}
|
|
45
|
-
}, [measureAndSet, interpolatorProps, sharedBoundTag, previous?.route.key, hasAlreadyMeasured]);
|
|
46
|
-
return {
|
|
47
|
-
measureAndSet,
|
|
48
|
-
measureOnLayout
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
exports.useBoundMeasurer = useBoundMeasurer;
|
|
52
|
-
//# sourceMappingURL=use-bound-measurer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNativeReanimated","_keys","_bounds","_flattenStyles","_useScreenAnimation","useBoundMeasurer","sharedBoundTag","animatedRef","current","style","previous","useKeys","interpolatorProps","useScreenAnimation","hasAlreadyMeasured","useSharedValue","measureAndSet","useCallback","measured","measure","Bounds","setBounds","route","key","flattenStyle","measureOnLayout","value","previousRouteKey","previousBounds","getBounds","hasPreviousBoundForTag","animating","exports"],"sourceRoot":"../../../../src","sources":["hooks/bounds/use-bound-measurer.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAL,OAAA;AASO,MAAMM,gBAAgB,GAAGA,CAAC;EAChCC,cAAc;EACdC,WAAW;EACXC,OAAO;EACPC;AACuB,CAAC,KAAK;EAC7B,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,aAAO,EAAC,CAAC;EAC9B,MAAMC,iBAAiB,GAAG,IAAAC,sCAAkB,EAAC,CAAC;EAC9C,MAAMC,kBAAkB,GAAG,IAAAC,qCAAc,EAAC,KAAK,CAAC;EAEhD,MAAMC,aAAa,GAAG,IAAAC,kBAAW,EAAC,MAAM;IACvC,SAAS;;IACT,IAAI,CAACX,cAAc,EAAE;IACrB,MAAMY,QAAQ,GAAG,IAAAC,8BAAO,EAACZ,WAAW,CAAC;IACrC,IAAIW,QAAQ,EAAE;MACbE,cAAM,CAACC,SAAS,CACfb,OAAO,CAACc,KAAK,CAACC,GAAG,EACjBjB,cAAc,EACdY,QAAQ,EACR,IAAAM,2BAAY,EAACf,KAAK,CACnB,CAAC;IACF;EACD,CAAC,EAAE,CAACH,cAAc,EAAEC,WAAW,EAAEC,OAAO,CAACc,KAAK,CAACC,GAAG,EAAEd,KAAK,CAAC,CAAC;EAE3D,MAAMgB,eAAe,GAAG,IAAAR,kBAAW,EAAC,MAAM;IACzC,SAAS;;IACT,IAAI,CAACX,cAAc,IAAIQ,kBAAkB,CAACY,KAAK,EAAE;IAEjD,MAAMC,gBAAgB,GAAGjB,QAAQ,EAAEY,KAAK,CAACC,GAAG;IAC5C,IAAI,CAACI,gBAAgB,EAAE;IAEvB,MAAMC,cAAc,GAAGR,cAAM,CAACS,SAAS,CAACF,gBAAgB,CAAC;IACzD,MAAMG,sBAAsB,GAAGF,cAAc,CAACtB,cAAc,CAAC;IAE7D,IAAIM,iBAAiB,CAACc,KAAK,CAAClB,OAAO,CAACuB,SAAS,IAAID,sBAAsB,EAAE;MACxEd,aAAa,CAAC,CAAC;MACfF,kBAAkB,CAACY,KAAK,GAAG,IAAI;IAChC;EACD,CAAC,EAAE,CACFV,aAAa,EACbJ,iBAAiB,EACjBN,cAAc,EACdI,QAAQ,EAAEY,KAAK,CAACC,GAAG,EACnBT,kBAAkB,CAClB,CAAC;EAEF,OAAO;IACNE,aAAa;IACbS;EACD,CAAC;AACF,CAAC;AAACO,OAAA,CAAA3B,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useScrollProgress = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
-
var _gestures = require("../../providers/gestures");
|
|
10
|
-
const useScrollProgress = props => {
|
|
11
|
-
const {
|
|
12
|
-
scrollProgress
|
|
13
|
-
} = (0, _gestures.useGestureContext)();
|
|
14
|
-
const scrollHandler = (0, _reactNativeReanimated.useAnimatedScrollHandler)({
|
|
15
|
-
onScroll: event => {
|
|
16
|
-
props.onScroll?.(event);
|
|
17
|
-
scrollProgress.modify(v => {
|
|
18
|
-
"worklet";
|
|
19
|
-
|
|
20
|
-
v.x = event.contentOffset.x;
|
|
21
|
-
v.y = event.contentOffset.y;
|
|
22
|
-
return v;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const onContentSizeChange = (0, _react.useCallback)((width, height) => {
|
|
27
|
-
props.onContentSizeChange?.(width, height);
|
|
28
|
-
scrollProgress.modify(v => {
|
|
29
|
-
"worklet";
|
|
30
|
-
|
|
31
|
-
v.contentWidth = width;
|
|
32
|
-
v.contentHeight = height;
|
|
33
|
-
return v;
|
|
34
|
-
});
|
|
35
|
-
}, [scrollProgress, props.onContentSizeChange]);
|
|
36
|
-
const onLayout = (0, _react.useCallback)(event => {
|
|
37
|
-
props.onLayout?.(event);
|
|
38
|
-
const {
|
|
39
|
-
width,
|
|
40
|
-
height
|
|
41
|
-
} = event.nativeEvent.layout;
|
|
42
|
-
scrollProgress.modify(v => {
|
|
43
|
-
"worklet";
|
|
44
|
-
|
|
45
|
-
v.layoutHeight = height;
|
|
46
|
-
v.layoutWidth = width;
|
|
47
|
-
return v;
|
|
48
|
-
});
|
|
49
|
-
}, [scrollProgress, props.onLayout]);
|
|
50
|
-
return {
|
|
51
|
-
scrollHandler,
|
|
52
|
-
onContentSizeChange,
|
|
53
|
-
onLayout
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
exports.useScrollProgress = useScrollProgress;
|
|
57
|
-
//# sourceMappingURL=use-scroll-progress.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNativeReanimated","_gestures","useScrollProgress","props","scrollProgress","useGestureContext","scrollHandler","useAnimatedScrollHandler","onScroll","event","modify","v","x","contentOffset","y","onContentSizeChange","useCallback","width","height","contentWidth","contentHeight","onLayout","nativeEvent","layout","layoutHeight","layoutWidth","exports"],"sourceRoot":"../../../../src","sources":["hooks/gestures/use-scroll-progress.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAQO,MAAMG,iBAAiB,GAAIC,KAA8B,IAAK;EACpE,MAAM;IAAEC;EAAe,CAAC,GAAG,IAAAC,2BAAiB,EAAC,CAAC;EAC9C,MAAMC,aAAa,GAAG,IAAAC,+CAAwB,EAAC;IAC9CC,QAAQ,EAAGC,KAAK,IAAK;MACpBN,KAAK,CAACK,QAAQ,GAAGC,KAAK,CAAC;MACvBL,cAAc,CAACM,MAAM,CAAEC,CAAC,IAAK;QAC5B,SAAS;;QACTA,CAAC,CAACC,CAAC,GAAGH,KAAK,CAACI,aAAa,CAACD,CAAC;QAC3BD,CAAC,CAACG,CAAC,GAAGL,KAAK,CAACI,aAAa,CAACC,CAAC;QAC3B,OAAOH,CAAC;MACT,CAAC,CAAC;IACH;EACD,CAAC,CAAC;EAEF,MAAMI,mBAAmB,GAAG,IAAAC,kBAAW,EACtC,CAACC,KAAa,EAAEC,MAAc,KAAK;IAClCf,KAAK,CAACY,mBAAmB,GAAGE,KAAK,EAAEC,MAAM,CAAC;IAE1Cd,cAAc,CAACM,MAAM,CAAEC,CAAC,IAAK;MAC5B,SAAS;;MACTA,CAAC,CAACQ,YAAY,GAAGF,KAAK;MACtBN,CAAC,CAACS,aAAa,GAAGF,MAAM;MACxB,OAAOP,CAAC;IACT,CAAC,CAAC;EACH,CAAC,EACD,CAACP,cAAc,EAAED,KAAK,CAACY,mBAAmB,CAC3C,CAAC;EAED,MAAMM,QAAQ,GAAG,IAAAL,kBAAW,EAC1BP,KAAwB,IAAK;IAC7BN,KAAK,CAACkB,QAAQ,GAAGZ,KAAK,CAAC;IACvB,MAAM;MAAEQ,KAAK;MAAEC;IAAO,CAAC,GAAGT,KAAK,CAACa,WAAW,CAACC,MAAM;IAClDnB,cAAc,CAACM,MAAM,CAAEC,CAAC,IAAK;MAC5B,SAAS;;MACTA,CAAC,CAACa,YAAY,GAAGN,MAAM;MACvBP,CAAC,CAACc,WAAW,GAAGR,KAAK;MACrB,OAAON,CAAC;IACT,CAAC,CAAC;EACH,CAAC,EACD,CAACP,cAAc,EAAED,KAAK,CAACkB,QAAQ,CAChC,CAAC;EAED,OAAO;IACNf,aAAa;IACbS,mBAAmB;IACnBM;EACD,CAAC;AACF,CAAC;AAACK,OAAA,CAAAxB,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|