react-native-screen-transitions 2.0.6 → 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/LICENSE +21 -0
- 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 +4 -1
- 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 +2 -1
- package/lib/commonjs/configs/specs.js.map +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 +6 -3
- 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 +2 -1
- package/lib/module/configs/specs.js.map +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 +3 -0
- 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/configs/specs.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 +13 -8
- 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 -2
- 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 +20 -8
- package/src/configs/presets.ts +401 -6
- package/src/configs/specs.ts +1 -0
- 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/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/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/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/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
|
@@ -1,33 +1,226 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { getBounds } from "./get-bounds";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { computeContentTransformGeometry, computeRelativeGeometry } from "./_utils/geometry";
|
|
4
|
+
import { getBounds } from "./_utils/get-bounds";
|
|
5
|
+
import { composeContentStyle, composeSizeAbsolute, composeSizeRelative, composeTransformAbsolute, composeTransformRelative } from "./_utils/style-composers";
|
|
6
|
+
import { DEFAULT_BUILDER_OPTIONS, FULLSCREEN_DIMENSIONS } from "./constants";
|
|
7
|
+
const EMPTY_STYLE = Object.freeze({});
|
|
8
|
+
const EMPTY_STYLE_RAW = Object.freeze({
|
|
9
|
+
scaleX: 1,
|
|
10
|
+
scaleY: 1,
|
|
11
|
+
scale: 1,
|
|
12
|
+
translateX: 0,
|
|
13
|
+
translateY: 0,
|
|
14
|
+
width: 0,
|
|
15
|
+
height: 0
|
|
16
|
+
});
|
|
17
|
+
const ENTER_RANGE = [0, 1];
|
|
18
|
+
const EXIT_RANGE = [1, 2];
|
|
19
|
+
const resolveBounds = props => {
|
|
20
|
+
"worklet";
|
|
21
|
+
|
|
22
|
+
const entering = !props.next;
|
|
23
|
+
const fullscreen = FULLSCREEN_DIMENSIONS(props.dimensions);
|
|
24
|
+
const startPhase = entering ? "previous" : "current";
|
|
25
|
+
const endPhase = entering ? "current" : "next";
|
|
26
|
+
const getPhaseBounds = phase => {
|
|
27
|
+
"worklet";
|
|
28
|
+
|
|
29
|
+
switch (phase) {
|
|
30
|
+
case "previous":
|
|
31
|
+
return props.previous?.bounds?.[props.id]?.bounds;
|
|
32
|
+
case "current":
|
|
33
|
+
return props.current?.bounds?.[props.id]?.bounds;
|
|
34
|
+
case "next":
|
|
35
|
+
return props.next?.bounds?.[props.id]?.bounds;
|
|
36
|
+
default:
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const start = getPhaseBounds(startPhase);
|
|
41
|
+
let end = getPhaseBounds(endPhase);
|
|
42
|
+
const isFullscreen = props.computeOptions.target === "fullscreen" || props.computeOptions.toFullscreen;
|
|
43
|
+
if (isFullscreen) {
|
|
44
|
+
end = fullscreen;
|
|
45
|
+
}
|
|
46
|
+
const customTarget = props.computeOptions.target;
|
|
47
|
+
if (typeof customTarget === "object") {
|
|
48
|
+
end = customTarget;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
start,
|
|
52
|
+
end,
|
|
53
|
+
entering
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const computeBoundStyles = ({
|
|
57
|
+
id,
|
|
8
58
|
previous,
|
|
59
|
+
current,
|
|
9
60
|
next,
|
|
10
61
|
progress,
|
|
11
62
|
dimensions
|
|
12
|
-
}) => {
|
|
63
|
+
}, computeOptions = {}) => {
|
|
13
64
|
"worklet";
|
|
14
65
|
|
|
15
|
-
|
|
16
|
-
|
|
66
|
+
if (!id) {
|
|
67
|
+
if (computeOptions.raw) {
|
|
68
|
+
return EMPTY_STYLE_RAW;
|
|
69
|
+
}
|
|
70
|
+
return EMPTY_STYLE;
|
|
71
|
+
}
|
|
72
|
+
const {
|
|
73
|
+
start,
|
|
74
|
+
end,
|
|
75
|
+
entering
|
|
76
|
+
} = resolveBounds({
|
|
77
|
+
id,
|
|
17
78
|
previous,
|
|
18
79
|
current,
|
|
19
80
|
next,
|
|
20
|
-
|
|
81
|
+
computeOptions,
|
|
21
82
|
dimensions
|
|
22
83
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
84
|
+
if (!start || !end) {
|
|
85
|
+
if (computeOptions.raw) {
|
|
86
|
+
return EMPTY_STYLE_RAW;
|
|
87
|
+
}
|
|
88
|
+
return EMPTY_STYLE;
|
|
89
|
+
}
|
|
90
|
+
const ranges = entering ? ENTER_RANGE : EXIT_RANGE;
|
|
91
|
+
if (computeOptions.method === "content") {
|
|
92
|
+
const geometry = computeContentTransformGeometry({
|
|
93
|
+
start,
|
|
94
|
+
end,
|
|
95
|
+
entering,
|
|
96
|
+
dimensions,
|
|
97
|
+
anchor: computeOptions.anchor,
|
|
98
|
+
scaleMode: computeOptions.scaleMode
|
|
99
|
+
});
|
|
100
|
+
return composeContentStyle({
|
|
101
|
+
start,
|
|
102
|
+
progress,
|
|
103
|
+
ranges,
|
|
104
|
+
end,
|
|
105
|
+
geometry,
|
|
106
|
+
computeOptions
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const geometry = computeRelativeGeometry({
|
|
110
|
+
start,
|
|
111
|
+
end,
|
|
112
|
+
entering,
|
|
113
|
+
anchor: computeOptions.anchor,
|
|
114
|
+
scaleMode: computeOptions.scaleMode
|
|
115
|
+
});
|
|
116
|
+
const common = {
|
|
117
|
+
start,
|
|
118
|
+
end,
|
|
119
|
+
progress,
|
|
120
|
+
ranges,
|
|
121
|
+
geometry,
|
|
122
|
+
computeOptions
|
|
123
|
+
};
|
|
124
|
+
const isSize = computeOptions.method === "size";
|
|
125
|
+
const isAbs = computeOptions.space === "absolute" || !!computeOptions.absolute;
|
|
126
|
+
return isSize ? isAbs ? composeSizeAbsolute(common) : composeSizeRelative(common) : isAbs ? composeTransformAbsolute(common) : composeTransformRelative(common);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @deprecated Use `createBounds` instead. We'll avoid using the builder pattern for this type of function.
|
|
131
|
+
*/
|
|
132
|
+
const buildBoundStyles = params => {
|
|
133
|
+
"worklet";
|
|
134
|
+
|
|
135
|
+
const cfg = {
|
|
136
|
+
options: {
|
|
137
|
+
...DEFAULT_BUILDER_OPTIONS
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const builder = () => ({
|
|
141
|
+
gestures: options => {
|
|
142
|
+
cfg.options.gestures = options;
|
|
143
|
+
return builder();
|
|
144
|
+
},
|
|
145
|
+
toFullscreen: () => {
|
|
146
|
+
cfg.options.toFullscreen = true;
|
|
147
|
+
return builder();
|
|
148
|
+
},
|
|
149
|
+
absolute: () => {
|
|
150
|
+
cfg.options.absolute = true;
|
|
151
|
+
cfg.options.relative = false;
|
|
152
|
+
return builder();
|
|
153
|
+
},
|
|
154
|
+
relative: () => {
|
|
155
|
+
cfg.options.relative = true;
|
|
156
|
+
cfg.options.absolute = false;
|
|
157
|
+
return builder();
|
|
158
|
+
},
|
|
159
|
+
transform: () => {
|
|
160
|
+
cfg.options.method = "transform";
|
|
161
|
+
return builder();
|
|
162
|
+
},
|
|
163
|
+
size: () => {
|
|
164
|
+
cfg.options.method = "size";
|
|
165
|
+
return builder();
|
|
166
|
+
},
|
|
167
|
+
content: () => {
|
|
168
|
+
cfg.options.method = "content";
|
|
169
|
+
return builder();
|
|
170
|
+
},
|
|
171
|
+
contentFill: () => {
|
|
172
|
+
cfg.options.contentScaleMode = "aspectFill";
|
|
173
|
+
return builder();
|
|
174
|
+
},
|
|
175
|
+
contentFit: () => {
|
|
176
|
+
cfg.options.contentScaleMode = "aspectFit";
|
|
177
|
+
return builder();
|
|
178
|
+
},
|
|
179
|
+
build: () => {
|
|
180
|
+
return computeBoundStyles(params, cfg.options);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return builder();
|
|
184
|
+
};
|
|
185
|
+
export const createBounds = ({
|
|
186
|
+
activeBoundId,
|
|
187
|
+
current,
|
|
188
|
+
previous,
|
|
189
|
+
next,
|
|
190
|
+
progress,
|
|
191
|
+
dimensions
|
|
192
|
+
}) => {
|
|
193
|
+
"worklet";
|
|
194
|
+
|
|
195
|
+
const bounds = params => {
|
|
196
|
+
if (typeof params === "object") {
|
|
197
|
+
const id = params.id ?? activeBoundId;
|
|
198
|
+
return computeBoundStyles({
|
|
199
|
+
id,
|
|
200
|
+
current,
|
|
201
|
+
previous,
|
|
202
|
+
next,
|
|
203
|
+
progress,
|
|
204
|
+
dimensions
|
|
205
|
+
}, params);
|
|
206
|
+
}
|
|
207
|
+
const id = typeof params === "string" ? params : activeBoundId;
|
|
208
|
+
return buildBoundStyles({
|
|
209
|
+
id,
|
|
27
210
|
current,
|
|
28
211
|
previous,
|
|
29
|
-
next
|
|
30
|
-
|
|
212
|
+
next,
|
|
213
|
+
progress,
|
|
214
|
+
dimensions
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
bounds.get = (id, phase) => getBounds({
|
|
218
|
+
id: id ?? activeBoundId,
|
|
219
|
+
phase,
|
|
220
|
+
current,
|
|
221
|
+
previous,
|
|
222
|
+
next
|
|
31
223
|
});
|
|
224
|
+
return bounds;
|
|
32
225
|
};
|
|
33
226
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["computeContentTransformGeometry","computeRelativeGeometry","getBounds","composeContentStyle","composeSizeAbsolute","composeSizeRelative","composeTransformAbsolute","composeTransformRelative","DEFAULT_BUILDER_OPTIONS","FULLSCREEN_DIMENSIONS","EMPTY_STYLE","Object","freeze","EMPTY_STYLE_RAW","scaleX","scaleY","scale","translateX","translateY","width","height","ENTER_RANGE","EXIT_RANGE","resolveBounds","props","entering","next","fullscreen","dimensions","startPhase","endPhase","getPhaseBounds","phase","previous","bounds","id","current","start","end","isFullscreen","computeOptions","target","toFullscreen","customTarget","computeBoundStyles","progress","raw","ranges","method","geometry","anchor","scaleMode","common","isSize","isAbs","space","absolute","buildBoundStyles","params","cfg","options","builder","gestures","relative","transform","size","content","contentFill","contentScaleMode","contentFit","build","createBounds","activeBoundId","get"],"sourceRoot":"../../../../src","sources":["utils/bounds/index.ts"],"mappings":";;AASA,SACCA,+BAA+B,EAC/BC,uBAAuB,QACjB,mBAAmB;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AO1B,kBAAkB,CAACc,MAAM,EAAEC,GAAG,CAACC,OAAO,CAAC;IAC/C;EACD,CAAC,CAAC;EAEF,OAAOC,OAAO,CAAC,CAAC;AACjB,CAAC;AAED,OAAO,MAAMU,YAAY,GAAGA,CAAC;EAC5BC,aAAa;EACbpC,OAAO;EACPH,QAAQ;EACRP,IAAI;EACJmB,QAAQ;EACRjB;AAC0B,CAAC,KAAqB;EAChD,SAAS;;EAET,MAAMM,MAAsB,GAAKwB,MAAsC,IAAK;IAC3E,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;MAC/B,MAAMvB,EAAE,GAAGuB,MAAM,CAACvB,EAAE,IAAIqC,aAAa;MAErC,OAAO5B,kBAAkB,CACxB;QACCT,EAAE;QACFC,OAAO;QACPH,QAAQ;QACRP,IAAI;QACJmB,QAAQ;QACRjB;MACD,CAAC,EACD8B,MACD,CAAC;IACF;IAEA,MAAMvB,EAAE,GAAG,OAAOuB,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAGc,aAAa;IAC9D,OAAOf,gBAAgB,CAAC;MACvBtB,EAAE;MACFC,OAAO;MACPH,QAAQ;MACRP,IAAI;MACJmB,QAAQ;MACRjB;IACD,CAAC,CAAC;EACH,CAAoB;EAEpBM,MAAM,CAACuC,GAAG,GAAG,CAACtC,EAAW,EAAEH,KAAmB,KAC7C9B,SAAS,CAAC;IACTiC,EAAE,EAAEA,EAAE,IAAIqC,aAAa;IACvBxC,KAAK;IACLI,OAAO;IACPH,QAAQ;IACRP;EACD,CAAC,CAAC;EAEH,OAAOQ,MAAM;AACd,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { GestureOffsetState } from "../../types/gesture";
|
|
4
|
+
/**
|
|
5
|
+
* 10 seems like the correct threshold for compatability with nested gestures outside of our package.
|
|
6
|
+
*/
|
|
7
|
+
const GESTURE_ACTIVATION_THRESHOLD_X = 10;
|
|
8
|
+
const GESTURE_ACTIVATION_THRESHOLD_Y = 10;
|
|
9
|
+
const GESTURE_FAIL_TOLERANCE_X = 15;
|
|
10
|
+
const GESTURE_FAIL_TOLERANCE_Y = 20;
|
|
11
|
+
const DEFAULT_EDGE_DISTANCE_HORIZONTAL = 50;
|
|
12
|
+
const DEFAULT_EDGE_DISTANCE_VERTICAL = 135;
|
|
13
|
+
const DEFAULT_ACTIVATION_AREA = "screen";
|
|
14
|
+
function normalizeSides(area) {
|
|
15
|
+
"worklet";
|
|
16
|
+
|
|
17
|
+
if (!area || typeof area === "string") {
|
|
18
|
+
const mode = area ?? DEFAULT_ACTIVATION_AREA;
|
|
19
|
+
return {
|
|
20
|
+
left: mode,
|
|
21
|
+
right: mode,
|
|
22
|
+
top: mode,
|
|
23
|
+
bottom: mode
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const s = area;
|
|
27
|
+
return {
|
|
28
|
+
left: s.left ?? DEFAULT_ACTIVATION_AREA,
|
|
29
|
+
right: s.right ?? DEFAULT_ACTIVATION_AREA,
|
|
30
|
+
top: s.top ?? DEFAULT_ACTIVATION_AREA,
|
|
31
|
+
bottom: s.bottom ?? DEFAULT_ACTIVATION_AREA
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function computeEdgeConstraints(initialTouch, dimensions, sides, responseDistance) {
|
|
35
|
+
"worklet";
|
|
36
|
+
|
|
37
|
+
const xDist = responseDistance ?? DEFAULT_EDGE_DISTANCE_HORIZONTAL;
|
|
38
|
+
const yDist = responseDistance ?? DEFAULT_EDGE_DISTANCE_VERTICAL;
|
|
39
|
+
const horizontalRight = sides.left === "screen" || initialTouch.x <= xDist; // right swipe checks left edge
|
|
40
|
+
const horizontalLeft = sides.right === "screen" || initialTouch.x >= dimensions.width - xDist; // left swipe checks right edge
|
|
41
|
+
const verticalDown = sides.top === "screen" || initialTouch.y <= yDist; // down swipe checks top edge
|
|
42
|
+
const verticalUp = sides.bottom === "screen" || initialTouch.y >= dimensions.height - yDist; // up swipe checks bottom edge
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
horizontalRight,
|
|
46
|
+
horizontalLeft,
|
|
47
|
+
verticalDown,
|
|
48
|
+
verticalUp
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function calculateSwipeDirs(deltaX, deltaY) {
|
|
52
|
+
"worklet";
|
|
53
|
+
|
|
54
|
+
const isVerticalSwipe = Math.abs(deltaY) > Math.abs(deltaX);
|
|
55
|
+
const isHorizontalSwipe = Math.abs(deltaX) > Math.abs(deltaY);
|
|
56
|
+
const isSwipingDown = isVerticalSwipe && deltaY > 0;
|
|
57
|
+
const isSwipingUp = isVerticalSwipe && deltaY < 0;
|
|
58
|
+
const isSwipingRight = isHorizontalSwipe && deltaX > 0;
|
|
59
|
+
const isSwipingLeft = isHorizontalSwipe && deltaX < 0;
|
|
60
|
+
return {
|
|
61
|
+
isSwipingDown,
|
|
62
|
+
isSwipingUp,
|
|
63
|
+
isSwipingRight,
|
|
64
|
+
isSwipingLeft,
|
|
65
|
+
isVerticalSwipe,
|
|
66
|
+
isHorizontalSwipe
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function shouldActivateOrFail(params) {
|
|
70
|
+
"worklet";
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
deltaX,
|
|
74
|
+
deltaY,
|
|
75
|
+
hasHorizontal,
|
|
76
|
+
hasVertical,
|
|
77
|
+
isHorizontalSwipe,
|
|
78
|
+
isVerticalSwipe,
|
|
79
|
+
allowedRight,
|
|
80
|
+
allowedLeft,
|
|
81
|
+
allowedUp,
|
|
82
|
+
allowedDown,
|
|
83
|
+
horizontalGateRight,
|
|
84
|
+
horizontalGateLeft,
|
|
85
|
+
verticalGateUp,
|
|
86
|
+
verticalGateDown,
|
|
87
|
+
isSwipingRight,
|
|
88
|
+
isSwipingLeft,
|
|
89
|
+
isSwipingUp,
|
|
90
|
+
isSwipingDown
|
|
91
|
+
} = params;
|
|
92
|
+
let shouldActivate = false;
|
|
93
|
+
let shouldFail = false;
|
|
94
|
+
if (hasHorizontal && isHorizontalSwipe) {
|
|
95
|
+
const hasEnoughHorizontalMovement = Math.abs(deltaX) >= GESTURE_ACTIVATION_THRESHOLD_X;
|
|
96
|
+
const hasAcceptableVerticalDeviation = Math.abs(deltaY) <= GESTURE_FAIL_TOLERANCE_X;
|
|
97
|
+
if (hasEnoughHorizontalMovement && hasAcceptableVerticalDeviation) {
|
|
98
|
+
const rightOk = isSwipingRight && allowedRight && horizontalGateRight;
|
|
99
|
+
const leftOk = isSwipingLeft && allowedLeft && horizontalGateLeft;
|
|
100
|
+
if (rightOk || leftOk) {
|
|
101
|
+
shouldActivate = true;
|
|
102
|
+
}
|
|
103
|
+
} else if (!hasAcceptableVerticalDeviation) {
|
|
104
|
+
shouldFail = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (hasVertical && isVerticalSwipe) {
|
|
108
|
+
const hasEnoughVerticalMovement = Math.abs(deltaY) >= GESTURE_ACTIVATION_THRESHOLD_Y;
|
|
109
|
+
const hasAcceptableHorizontalDeviation = Math.abs(deltaX) <= GESTURE_FAIL_TOLERANCE_Y;
|
|
110
|
+
if (hasEnoughVerticalMovement && hasAcceptableHorizontalDeviation) {
|
|
111
|
+
const upOk = isSwipingUp && allowedUp && verticalGateUp;
|
|
112
|
+
const downOk = isSwipingDown && allowedDown && verticalGateDown;
|
|
113
|
+
if (upOk || downOk) {
|
|
114
|
+
shouldActivate = true;
|
|
115
|
+
}
|
|
116
|
+
} else if (!hasAcceptableHorizontalDeviation) {
|
|
117
|
+
shouldFail = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (hasHorizontal && isHorizontalSwipe) {
|
|
121
|
+
if (isSwipingLeft && !allowedLeft || isSwipingRight && !allowedRight) {
|
|
122
|
+
shouldFail = true;
|
|
123
|
+
}
|
|
124
|
+
// If gating prohibits the dominant horizontal swipe, fail early
|
|
125
|
+
if (isSwipingRight && allowedRight && !horizontalGateRight || isSwipingLeft && allowedLeft && !horizontalGateLeft) {
|
|
126
|
+
shouldFail = true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (hasVertical && isVerticalSwipe) {
|
|
130
|
+
if (isSwipingUp && !allowedUp || isSwipingDown && !allowedDown) {
|
|
131
|
+
shouldFail = true;
|
|
132
|
+
}
|
|
133
|
+
// If gating prohibits the dominant vertical swipe, fail early
|
|
134
|
+
if (isSwipingUp && allowedUp && !verticalGateUp || isSwipingDown && allowedDown && !verticalGateDown) {
|
|
135
|
+
shouldFail = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
shouldActivate,
|
|
140
|
+
shouldFail
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 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.
|
|
146
|
+
*/
|
|
147
|
+
export const applyOffsetRules = ({
|
|
148
|
+
initialTouch,
|
|
149
|
+
touch,
|
|
150
|
+
directions,
|
|
151
|
+
manager,
|
|
152
|
+
gestureOffsetState,
|
|
153
|
+
activationArea,
|
|
154
|
+
dimensions,
|
|
155
|
+
responseDistance
|
|
156
|
+
}) => {
|
|
157
|
+
"worklet";
|
|
158
|
+
|
|
159
|
+
const deltaX = touch.x - initialTouch.x;
|
|
160
|
+
const deltaY = touch.y - initialTouch.y;
|
|
161
|
+
const allowedDown = directions.vertical;
|
|
162
|
+
const allowedUp = directions.verticalInverted;
|
|
163
|
+
const allowedRight = directions.horizontal;
|
|
164
|
+
const allowedLeft = directions.horizontalInverted;
|
|
165
|
+
const hasHorizontal = allowedLeft || allowedRight;
|
|
166
|
+
const hasVertical = allowedUp || allowedDown;
|
|
167
|
+
const {
|
|
168
|
+
isSwipingDown,
|
|
169
|
+
isSwipingUp,
|
|
170
|
+
isSwipingRight,
|
|
171
|
+
isSwipingLeft,
|
|
172
|
+
isVerticalSwipe,
|
|
173
|
+
isHorizontalSwipe
|
|
174
|
+
} = calculateSwipeDirs(deltaX, deltaY);
|
|
175
|
+
|
|
176
|
+
// avoid re-running the function if the activation state is already set
|
|
177
|
+
if (gestureOffsetState.value === GestureOffsetState.PASSED || gestureOffsetState.value === GestureOffsetState.FAILED) {
|
|
178
|
+
return {
|
|
179
|
+
isSwipingDown,
|
|
180
|
+
isSwipingUp,
|
|
181
|
+
isSwipingRight,
|
|
182
|
+
isSwipingLeft
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const sides = normalizeSides(activationArea);
|
|
186
|
+
const {
|
|
187
|
+
horizontalRight: horizontalGateRight,
|
|
188
|
+
horizontalLeft: horizontalGateLeft,
|
|
189
|
+
verticalDown: verticalGateDown,
|
|
190
|
+
verticalUp: verticalGateUp
|
|
191
|
+
} = computeEdgeConstraints(initialTouch, dimensions, sides, responseDistance);
|
|
192
|
+
const {
|
|
193
|
+
shouldActivate,
|
|
194
|
+
shouldFail
|
|
195
|
+
} = shouldActivateOrFail({
|
|
196
|
+
deltaX,
|
|
197
|
+
deltaY,
|
|
198
|
+
hasHorizontal,
|
|
199
|
+
hasVertical,
|
|
200
|
+
isHorizontalSwipe,
|
|
201
|
+
isVerticalSwipe,
|
|
202
|
+
allowedRight,
|
|
203
|
+
allowedLeft,
|
|
204
|
+
allowedUp,
|
|
205
|
+
allowedDown,
|
|
206
|
+
horizontalGateRight,
|
|
207
|
+
horizontalGateLeft,
|
|
208
|
+
verticalGateUp,
|
|
209
|
+
verticalGateDown,
|
|
210
|
+
isSwipingRight,
|
|
211
|
+
isSwipingLeft,
|
|
212
|
+
isSwipingUp,
|
|
213
|
+
isSwipingDown
|
|
214
|
+
});
|
|
215
|
+
if (shouldActivate) {
|
|
216
|
+
gestureOffsetState.value = GestureOffsetState.PASSED;
|
|
217
|
+
} else if (shouldFail) {
|
|
218
|
+
gestureOffsetState.value = GestureOffsetState.FAILED;
|
|
219
|
+
manager?.fail();
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
isSwipingDown,
|
|
223
|
+
isSwipingUp,
|
|
224
|
+
isSwipingRight,
|
|
225
|
+
isSwipingLeft
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
//# sourceMappingURL=apply-offset-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GestureOffsetState","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","PASSED","FAILED","fail"],"sourceRoot":"../../../../src","sources":["utils/gesture/apply-offset-rules.ts"],"mappings":";;AAGA,SAGCA,kBAAkB,QAEZ,qBAAqB;AAuD5B;AACA;AACA;AACA,MAAMC,8BAA8B,GAAG,EAAE;AACzC,MAAMC,8BAA8B,GAAG,EAAE;AACzC,MAAMC,wBAAwB,GAAG,EAAE;AACnC,MAAMC,wBAAwB,GAAG,EAAE;AACnC,MAAM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