react-native-screen-transitions 2.3.4 → 2.4.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 +11 -8
- package/lib/commonjs/__configs__/presets.js +10 -5
- package/lib/commonjs/__configs__/presets.js.map +1 -1
- package/lib/commonjs/constants.js +2 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/hooks/animation/use-screen-animation.js +2 -1
- package/lib/commonjs/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/hooks/bounds/use-bound-registry.js +10 -8
- package/lib/commonjs/hooks/bounds/use-bound-registry.js.map +1 -1
- package/lib/commonjs/hooks/gestures/use-build-gestures.js +17 -10
- package/lib/commonjs/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/hooks/use-stable-callback-value.js +64 -0
- package/lib/commonjs/hooks/use-stable-callback-value.js.map +1 -0
- package/lib/commonjs/stores/gestures.js +2 -1
- package/lib/commonjs/stores/gestures.js.map +1 -1
- package/lib/commonjs/utils/bounds/_utils/styles.js +58 -0
- package/lib/commonjs/utils/bounds/_utils/styles.js.map +1 -0
- package/lib/commonjs/utils/gesture/reset-gesture-values.js +14 -4
- package/lib/commonjs/utils/gesture/reset-gesture-values.js.map +1 -1
- package/lib/module/__configs__/presets.js +10 -5
- package/lib/module/__configs__/presets.js.map +1 -1
- package/lib/module/constants.js +2 -1
- package/lib/module/constants.js.map +1 -1
- package/lib/module/hooks/animation/use-screen-animation.js +2 -1
- package/lib/module/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/hooks/bounds/use-bound-registry.js +11 -9
- package/lib/module/hooks/bounds/use-bound-registry.js.map +1 -1
- package/lib/module/hooks/gestures/use-build-gestures.js +18 -11
- package/lib/module/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/hooks/use-stable-callback-value.js +60 -0
- package/lib/module/hooks/use-stable-callback-value.js.map +1 -0
- package/lib/module/stores/gestures.js +2 -1
- package/lib/module/stores/gestures.js.map +1 -1
- package/lib/module/utils/bounds/_utils/styles.js +54 -0
- package/lib/module/utils/bounds/_utils/styles.js.map +1 -0
- package/lib/module/utils/gesture/reset-gesture-values.js +14 -4
- package/lib/module/utils/gesture/reset-gesture-values.js.map +1 -1
- package/lib/typescript/__configs__/presets.d.ts.map +1 -1
- package/lib/typescript/constants.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-registry.d.ts.map +1 -1
- package/lib/typescript/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/hooks/use-stable-callback-value.d.ts +13 -0
- package/lib/typescript/hooks/use-stable-callback-value.d.ts.map +1 -0
- package/lib/typescript/stores/gestures.d.ts +2 -0
- package/lib/typescript/stores/gestures.d.ts.map +1 -1
- package/lib/typescript/types/animation.d.ts +10 -9
- package/lib/typescript/types/animation.d.ts.map +1 -1
- package/lib/typescript/types/gesture.d.ts +4 -0
- package/lib/typescript/types/gesture.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/_utils/styles.d.ts +7 -0
- package/lib/typescript/utils/bounds/_utils/styles.d.ts.map +1 -0
- package/lib/typescript/utils/gesture/reset-gesture-values.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__configs__/presets.ts +23 -7
- package/src/__tests__/determine-dismissal.test.ts +121 -0
- package/src/__tests__/gesture.velocity.test.ts +138 -0
- package/src/constants.ts +2 -0
- package/src/hooks/animation/use-screen-animation.tsx +1 -0
- package/src/hooks/bounds/use-bound-registry.tsx +9 -13
- package/src/hooks/gestures/use-build-gestures.tsx +21 -37
- package/src/hooks/use-stable-callback-value.tsx +68 -0
- package/src/stores/gestures.ts +5 -0
- package/src/types/animation.ts +10 -9
- package/src/types/gesture.ts +4 -0
- package/src/utils/bounds/_utils/styles.ts +68 -0
- package/src/utils/gesture/reset-gesture-values.ts +22 -4
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { isSharedValue } from "react-native-reanimated";
|
|
4
|
+
function mergeStyleArrays(style) {
|
|
5
|
+
"worklet";
|
|
6
|
+
|
|
7
|
+
// Early returns for non-objects
|
|
8
|
+
if (style === null || style === undefined || typeof style !== "object") {
|
|
9
|
+
return style;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// If not an array, return as-is
|
|
13
|
+
if (!Array.isArray(style)) {
|
|
14
|
+
return style;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Merge array of styles into single object
|
|
18
|
+
const merged = {};
|
|
19
|
+
for (let i = 0; i < style.length; i++) {
|
|
20
|
+
const currentStyle = mergeStyleArrays(style[i]);
|
|
21
|
+
if (currentStyle && typeof currentStyle === "object") {
|
|
22
|
+
Object.assign(merged, currentStyle);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return merged;
|
|
26
|
+
}
|
|
27
|
+
function stripNonSerializable(value) {
|
|
28
|
+
if (isSharedValue(value)) return value;
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
return value.map(stripNonSerializable);
|
|
31
|
+
}
|
|
32
|
+
if (value && typeof value === "object") {
|
|
33
|
+
const cleaned = {};
|
|
34
|
+
for (const key in value) {
|
|
35
|
+
if (key === "current") continue;
|
|
36
|
+
const cleanedValue = stripNonSerializable(value[key]);
|
|
37
|
+
if (cleanedValue !== undefined) {
|
|
38
|
+
cleaned[key] = cleanedValue;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return cleaned;
|
|
42
|
+
}
|
|
43
|
+
if (typeof value === "function") {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
export function prepareStyleForBounds(style) {
|
|
49
|
+
if (!style) return {};
|
|
50
|
+
const flattened = mergeStyleArrays(style);
|
|
51
|
+
const serializable = stripNonSerializable(flattened);
|
|
52
|
+
return serializable || {};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isSharedValue","mergeStyleArrays","style","undefined","Array","isArray","merged","i","length","currentStyle","Object","assign","stripNonSerializable","value","map","cleaned","key","cleanedValue","prepareStyleForBounds","flattened","serializable"],"sourceRoot":"../../../../../src","sources":["utils/bounds/_utils/styles.ts"],"mappings":";;AACA,SAASA,aAAa,QAAQ,yBAAyB;AAMvD,SAASC,gBAAgBA,CAAuBC,KAAQ,EAAK;EAC5D,SAAS;;EAET;EACA,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKC,SAAS,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;IACvE,OAAOA,KAAK;EACb;;EAEA;EACA,IAAI,CAACE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IAC1B,OAAOA,KAAK;EACb;;EAEA;EACA,MAAMI,MAAwB,GAAG,CAAC,CAAC;EACnC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,KAAK,CAACM,MAAM,EAAED,CAAC,EAAE,EAAE;IACtC,MAAME,YAAY,GAAGR,gBAAgB,CAACC,KAAK,CAACK,CAAC,CAAe,CAAC;IAC7D,IAAIE,YAAY,IAAI,OAAOA,YAAY,KAAK,QAAQ,EAAE;MACrDC,MAAM,CAACC,MAAM,CAACL,MAAM,EAAEG,YAAY,CAAC;IACpC;EACD;EACA,OAAOH,MAAM;AACd;AAEA,SAASM,oBAAoBA,CAAIC,KAAQ,EAAiB;EACzD,IAAIb,aAAa,CAACa,KAAK,CAAC,EAAE,OAAOA,KAAK;EAEtC,IAAIT,KAAK,CAACC,OAAO,CAACQ,KAAK,CAAC,EAAE;IACzB,OAAOA,KAAK,CAACC,GAAG,CAACF,oBAAoB,CAAC;EACvC;EAEA,IAAIC,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACvC,MAAME,OAAyB,GAAG,CAAC,CAAC;IACpC,KAAK,MAAMC,GAAG,IAAIH,KAAK,EAAE;MACxB,IAAIG,GAAG,KAAK,SAAS,EAAE;MAEvB,MAAMC,YAAY,GAAGL,oBAAoB,CAACC,KAAK,CAACG,GAAG,CAAC,CAAC;MACrD,IAAIC,YAAY,KAAKd,SAAS,EAAE;QAC/BY,OAAO,CAACC,GAAG,CAAC,GAAGC,YAAY;MAC5B;IACD;IACA,OAAOF,OAAO;EACf;EAEA,IAAI,OAAOF,KAAK,KAAK,UAAU,EAAE;IAChC,OAAOV,SAAS;EACjB;EAEA,OAAOU,KAAK;AACb;AAEA,OAAO,SAASK,qBAAqBA,CACpChB,KAA6B,EACV;EACnB,IAAI,CAACA,KAAK,EAAE,OAAO,CAAC,CAAC;EAErB,MAAMiB,SAAS,GAAGlB,gBAAgB,CAACC,KAAK,CAAC;EACzC,MAAMkB,YAAY,GAAGR,oBAAoB,CAACO,SAAS,CAAC;EAEpD,OAAOC,YAAY,IAAI,CAAC,CAAC;AAC1B","ignoreList":[]}
|
|
@@ -19,22 +19,32 @@ export const resetGestureValues = ({
|
|
|
19
19
|
const ny = gestures.normalizedY.value || event.translationY / Math.max(1, dimensions.height);
|
|
20
20
|
const vxTowardZero = velocity.calculateRestoreVelocity(nx, vxNorm);
|
|
21
21
|
const vyTowardZero = velocity.calculateRestoreVelocity(ny, vyNorm);
|
|
22
|
+
let remainingAnimations = 4;
|
|
23
|
+
const onFinish = finished => {
|
|
24
|
+
"worklet";
|
|
25
|
+
|
|
26
|
+
if (!finished) return;
|
|
27
|
+
remainingAnimations -= 1;
|
|
28
|
+
if (remainingAnimations === 0) {
|
|
29
|
+
gestures.direction.value = null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
22
32
|
gestures.x.value = animate(0, {
|
|
23
33
|
...spec,
|
|
24
34
|
velocity: vxTowardZero
|
|
25
|
-
});
|
|
35
|
+
}, onFinish);
|
|
26
36
|
gestures.y.value = animate(0, {
|
|
27
37
|
...spec,
|
|
28
38
|
velocity: vyTowardZero
|
|
29
|
-
});
|
|
39
|
+
}, onFinish);
|
|
30
40
|
gestures.normalizedX.value = animate(0, {
|
|
31
41
|
...spec,
|
|
32
42
|
velocity: vxTowardZero
|
|
33
|
-
});
|
|
43
|
+
}, onFinish);
|
|
34
44
|
gestures.normalizedY.value = animate(0, {
|
|
35
45
|
...spec,
|
|
36
46
|
velocity: vyTowardZero
|
|
37
|
-
});
|
|
47
|
+
}, onFinish);
|
|
38
48
|
gestures.isDragging.value = 0;
|
|
39
49
|
gestures.isDismissing.value = Number(shouldDismiss);
|
|
40
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["animate","velocity","resetGestureValues","spec","gestures","shouldDismiss","event","dimensions","vxNorm","normalize","velocityX","width","vyNorm","velocityY","height","nx","normalizedX","value","translationX","Math","max","ny","normalizedY","translationY","vxTowardZero","calculateRestoreVelocity","vyTowardZero","x","y","isDragging","isDismissing","Number"],"sourceRoot":"../../../../src","sources":["utils/gesture/reset-gesture-values.ts"],"mappings":";;AAMA,SAASA,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,QAAQ,QAAQ,YAAY;AAUrC,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAClCC,IAAI;EACJC,QAAQ;EACRC,aAAa;EACbC,KAAK;EACLC;AACwB,CAAC,KAAK;EAC9B,SAAS;;EAET,MAAMC,MAAM,GAAGP,QAAQ,CAACQ,SAAS,CAACH,KAAK,CAACI,SAAS,EAAEH,UAAU,CAACI,KAAK,CAAC;EACpE,MAAMC,MAAM,GAAGX,QAAQ,CAACQ,SAAS,CAACH,KAAK,CAACO,SAAS,EAAEN,UAAU,CAACO,MAAM,CAAC;;EAErE;EACA,MAAMC,EAAE,GACPX,QAAQ,CAACY,WAAW,CAACC,KAAK,IAC1BX,KAAK,CAACY,YAAY,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEb,UAAU,CAACI,KAAK,CAAC;EACnD,MAAMU,EAAE,GACPjB,QAAQ,CAACkB,WAAW,CAACL,KAAK,IAC1BX,KAAK,CAACiB,YAAY,GAAGJ,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEb,UAAU,CAACO,MAAM,CAAC;EAEpD,MAAMU,YAAY,GAAGvB,QAAQ,CAACwB,wBAAwB,CAACV,EAAE,EAAEP,MAAM,CAAC;EAClE,MAAMkB,YAAY,GAAGzB,QAAQ,CAACwB,wBAAwB,CAACJ,EAAE,EAAET,MAAM,CAAC;
|
|
1
|
+
{"version":3,"names":["animate","velocity","resetGestureValues","spec","gestures","shouldDismiss","event","dimensions","vxNorm","normalize","velocityX","width","vyNorm","velocityY","height","nx","normalizedX","value","translationX","Math","max","ny","normalizedY","translationY","vxTowardZero","calculateRestoreVelocity","vyTowardZero","remainingAnimations","onFinish","finished","direction","x","y","isDragging","isDismissing","Number"],"sourceRoot":"../../../../src","sources":["utils/gesture/reset-gesture-values.ts"],"mappings":";;AAMA,SAASA,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,QAAQ,QAAQ,YAAY;AAUrC,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAClCC,IAAI;EACJC,QAAQ;EACRC,aAAa;EACbC,KAAK;EACLC;AACwB,CAAC,KAAK;EAC9B,SAAS;;EAET,MAAMC,MAAM,GAAGP,QAAQ,CAACQ,SAAS,CAACH,KAAK,CAACI,SAAS,EAAEH,UAAU,CAACI,KAAK,CAAC;EACpE,MAAMC,MAAM,GAAGX,QAAQ,CAACQ,SAAS,CAACH,KAAK,CAACO,SAAS,EAAEN,UAAU,CAACO,MAAM,CAAC;;EAErE;EACA,MAAMC,EAAE,GACPX,QAAQ,CAACY,WAAW,CAACC,KAAK,IAC1BX,KAAK,CAACY,YAAY,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEb,UAAU,CAACI,KAAK,CAAC;EACnD,MAAMU,EAAE,GACPjB,QAAQ,CAACkB,WAAW,CAACL,KAAK,IAC1BX,KAAK,CAACiB,YAAY,GAAGJ,IAAI,CAACC,GAA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|
|
|
1
|
-
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../../src/__configs__/presets.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAKjE,eAAO,MAAM,YAAY,GACxB,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBA4BF,CAAC;AAEF,eAAO,MAAM,MAAM,GAClB,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBAkCF,CAAC;AAEF,eAAO,MAAM,eAAe,GAC3B,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBA2BF,CAAC;AAEF,eAAO,MAAM,aAAa,GACzB,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBAuCF,CAAC;AAEF,eAAO,MAAM,WAAW,GACvB,SAAQ,OAAO,CAAC,sBAAsB,CAAC,GAAG;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;CACE,KACxB,
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../../src/__configs__/presets.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAKjE,eAAO,MAAM,YAAY,GACxB,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBA4BF,CAAC;AAEF,eAAO,MAAM,MAAM,GAClB,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBAkCF,CAAC;AAEF,eAAO,MAAM,eAAe,GAC3B,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBA2BF,CAAC;AAEF,eAAO,MAAM,aAAa,GACzB,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBAuCF,CAAC;AAEF,eAAO,MAAM,WAAW,GACvB,SAAQ,OAAO,CAAC,sBAAsB,CAAC,GAAG;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;CACE,KACxB,sBAyDF,CAAC;AAEF,eAAO,MAAM,aAAa,GACzB,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBA6HF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC5B,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBAmMF,CAAC;AAEF,eAAO,MAAM,YAAY,GACxB,SAAQ,OAAO,CAAC,sBAAsB,CAAM,KAC1C,sBA+EF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,aAAa,iBAAiB,CAAC;AAC5C,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,SAAS,cAAoB,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MA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C;AACnD,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAClD,eAAO,MAAM,uBAAuB,EAAG,QAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-screen-animation.d.ts","sourceRoot":"","sources":["../../../../src/hooks/animation/use-screen-animation.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACX,wBAAwB,EAExB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-screen-animation.d.ts","sourceRoot":"","sources":["../../../../src/hooks/animation/use-screen-animation.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACX,wBAAwB,EAExB,MAAM,uBAAuB,CAAC;AAwD/B,wBAAgB,mBAAmB;;;EAmElC;AAED,wBAAgB,kBAAkB,6EAIjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-bound-registry.d.ts","sourceRoot":"","sources":["../../../../src/hooks/bounds/use-bound-registry.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACN,KAAK,WAAW,EAIhB,KAAK,UAAU,EAGf,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-bound-registry.d.ts","sourceRoot":"","sources":["../../../../src/hooks/bounds/use-bound-registry.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACN,KAAK,WAAW,EAIhB,KAAK,UAAU,EAGf,MAAM,yBAAyB,CAAC;AASjC,UAAU,sBAAsB;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACrD;AAcD,eAAO,MAAM,iBAAiB,GAAI,kDAK/B,sBAAsB;;;8GAoFD;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;CAyBpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-build-gestures.d.ts","sourceRoot":"","sources":["../../../../src/hooks/gestures/use-build-gestures.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIN,KAAK,WAAW,EAGhB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAEN,KAAK,WAAW,EAEhB,MAAM,yBAAyB,CAAC;AAQjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-build-gestures.d.ts","sourceRoot":"","sources":["../../../../src/hooks/gestures/use-build-gestures.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIN,KAAK,WAAW,EAGhB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAEN,KAAK,WAAW,EAEhB,MAAM,yBAAyB,CAAC;AAQjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAe7D,UAAU,sBAAsB;IAC/B,YAAY,EAAE,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;CAC/C;AAED,eAAO,MAAM,gBAAgB,GAAI,mBAE9B,sBAAsB,KAAG;IAC3B,UAAU,EAAE,WAAW,CAAC;IACxB,aAAa,EAAE,WAAW,CAAC;CAqR3B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type AnyFunction = (...args: Array<any>) => any;
|
|
2
|
+
/** Creates a stable worklet callback that can be called from the UI runtime
|
|
3
|
+
* @param callback The JavaScript or worklet function to be called
|
|
4
|
+
* @returns A worklet function that can be safely called from the UI thread
|
|
5
|
+
* @default Behavior:
|
|
6
|
+
* - If passed a regular JS function, calls it on the JS thread using runOnJS
|
|
7
|
+
* - If passed a worklet function, calls it directly on the UI thread
|
|
8
|
+
* @important The returned function maintains a stable reference and properly handles
|
|
9
|
+
* thread execution based on the input callback type
|
|
10
|
+
*/
|
|
11
|
+
export default function useStableCallbackValue<C extends AnyFunction>(callback?: C): (...args: Parameters<C>) => void;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=use-stable-callback-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-stable-callback-value.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-stable-callback-value.tsx"],"names":[],"mappings":"AAYA,KAAK,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC;AA0BhD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,CAAC,SAAS,WAAW,EACnE,QAAQ,CAAC,EAAE,CAAC,aAaD,UAAU,CAAC,CAAC,CAAC,UAMxB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type SharedValue } from "react-native-reanimated";
|
|
2
|
+
import type { GestureDirection } from "../types/gesture";
|
|
2
3
|
import type { ScreenKey } from "../types/navigator";
|
|
3
4
|
export type GestureKey = "x" | "y" | "normalizedX" | "normalizedY" | "isDismissing" | "isDragging";
|
|
4
5
|
export type GestureMap = {
|
|
@@ -8,6 +9,7 @@ export type GestureMap = {
|
|
|
8
9
|
normalizedY: SharedValue<number>;
|
|
9
10
|
isDismissing: SharedValue<number>;
|
|
10
11
|
isDragging: SharedValue<number>;
|
|
12
|
+
direction: SharedValue<Omit<GestureDirection, "bidirectional"> | null>;
|
|
11
13
|
};
|
|
12
14
|
declare function getGesture(routeKey: ScreenKey, gestureKey: GestureKey): SharedValue<number>;
|
|
13
15
|
declare function getRouteGestures(routeKey: ScreenKey): GestureMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gestures.d.ts","sourceRoot":"","sources":["../../../src/stores/gestures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,WAAW,EAAE,MAA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,GAAG,IAAI,CAAC,CAAC;CACvE,CAAC;AAuBF,iBAAS,UAAU,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,uBAE9D;AAED,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,SAAS,cAE5C;AAED,iBAAS,KAAK,CAAC,QAAQ,EAAE,SAAS,QAEjC;AAED,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC"}
|
|
@@ -12,10 +12,11 @@ export type ScreenTransitionState = {
|
|
|
12
12
|
route: RouteProp<ParamListBase>;
|
|
13
13
|
};
|
|
14
14
|
export interface ScreenInterpolationProps {
|
|
15
|
-
/** Values for the screen that
|
|
15
|
+
/** Values for the screen that came before the current one in the navigation stack. */
|
|
16
16
|
previous: ScreenTransitionState | undefined;
|
|
17
|
+
/** Values for the current screen being interpolated. */
|
|
17
18
|
current: ScreenTransitionState;
|
|
18
|
-
/** Values for the screen
|
|
19
|
+
/** Values for the screen that comes after the current one in the navigation stack. */
|
|
19
20
|
next: ScreenTransitionState | undefined;
|
|
20
21
|
/** Layout measurements for the screen. */
|
|
21
22
|
layouts: {
|
|
@@ -27,19 +28,19 @@ export interface ScreenInterpolationProps {
|
|
|
27
28
|
};
|
|
28
29
|
/** The safe area insets for the screen. */
|
|
29
30
|
insets: EdgeInsets;
|
|
30
|
-
/** The
|
|
31
|
+
/** The ID of the currently active shared bound (e.g., 'a' when Transition.Pressable has sharedBoundTag='a'). */
|
|
31
32
|
activeBoundId: string;
|
|
32
|
-
/** Whether the screen is focused. */
|
|
33
|
+
/** Whether the current screen is the focused (topmost) screen in the stack. */
|
|
33
34
|
focused: boolean;
|
|
34
|
-
/**
|
|
35
|
+
/** Combined progress of current and next screen transitions, ranging from 0-2. */
|
|
35
36
|
progress: number;
|
|
36
|
-
/**
|
|
37
|
+
/** Function that provides access to bounds builders for creating shared element transitions. */
|
|
37
38
|
bounds: BoundsAccessor;
|
|
38
|
-
/** The
|
|
39
|
+
/** The screen state that is currently driving the transition (either current or next, whichever is focused). */
|
|
39
40
|
active: ScreenTransitionState;
|
|
40
|
-
/** Whether the active screen is transitioning. */
|
|
41
|
+
/** Whether the active screen is currently transitioning (either being dragged or animating). */
|
|
41
42
|
isActiveTransitioning: boolean;
|
|
42
|
-
/** Whether the active screen is
|
|
43
|
+
/** Whether the active screen is in the process of being dismissed/closed. */
|
|
43
44
|
isDismissing: boolean;
|
|
44
45
|
}
|
|
45
46
|
export type ScreenStyleInterpolator = (props: ScreenInterpolationProps) => TransitionInterpolatedStyle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../src/types/animation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EACX,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,qBAAqB,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACnC,KAAK,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACxC,
|
|
1
|
+
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../src/types/animation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EACX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MAAM,MAAM,uBAAuB,GAAG,CACrC,KAAK,EAAE,wBAAwB,KAC3B,2BAA2B,CAAC;AAEjC,MAAM,MAAM,2BAA2B,GAAG;IACzC;;OAEG;IACH,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B;;OAEG;IACH,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,KAAK,CAAC,EAAE,eAAe,CAAC;CACxB"}
|
|
@@ -38,5 +38,9 @@ export type GestureValues = {
|
|
|
38
38
|
* A flag indicating if the screen is in the process of dismissing.
|
|
39
39
|
*/
|
|
40
40
|
isDismissing: number;
|
|
41
|
+
/**
|
|
42
|
+
* The initial direction that activated the gesture.
|
|
43
|
+
*/
|
|
44
|
+
direction: Omit<GestureDirection, "bidirectional"> | null;
|
|
41
45
|
};
|
|
42
46
|
//# sourceMappingURL=gesture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gesture.d.ts","sourceRoot":"","sources":["../../../src/types/gesture.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACzB,YAAY,GACZ,qBAAqB,GACrB,UAAU,GACV,mBAAmB,GACnB,eAAe,CAAC;AAEnB,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE/C,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,MAAM,CAAC,EAAE,cAAc,CAAC;CACxB,CAAC;AAEF,oBAAY,kBAAkB;IAC7B,OAAO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W,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAC,GAAG,IAAI,CAAC;CAC1D,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
type AnyStyle = ViewStyle | TextStyle | ImageStyle;
|
|
3
|
+
type StyleValue = StyleProp<AnyStyle>;
|
|
4
|
+
type PlainStyleObject = Record<string, any>;
|
|
5
|
+
export declare function prepareStyleForBounds(style: StyleValue | undefined): PlainStyleObject;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/utils/bounds/_utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGhF,KAAK,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AACnD,KAAK,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AACtC,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAqD5C,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,UAAU,GAAG,SAAS,GAC3B,gBAAgB,CAOlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-gesture-values.d.ts","sourceRoot":"","sources":["../../../../src/utils/gesture/reset-gesture-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,uBAAuB,EACvB,6BAA6B,EAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,UAAU,uBAAuB;IAChC,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,UAAU,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,uBAAuB,CAAC,6BAA6B,CAAC,CAAC;IAC9D,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9C;AAED,eAAO,MAAM,kBAAkB,GAAI,uDAMhC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"reset-gesture-values.d.ts","sourceRoot":"","sources":["../../../../src/utils/gesture/reset-gesture-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,uBAAuB,EACvB,6BAA6B,EAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,UAAU,uBAAuB;IAChC,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,UAAU,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,uBAAuB,CAAC,6BAA6B,CAAC,CAAC;IAC9D,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9C;AAED,eAAO,MAAM,kBAAkB,GAAI,uDAMhC,uBAAuB,SA0CzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -173,7 +173,6 @@ export const ElasticCard = (
|
|
|
173
173
|
/**
|
|
174
174
|
* Applies to both screens ( previous and incoming)
|
|
175
175
|
*/
|
|
176
|
-
|
|
177
176
|
const scale = interpolate(progress, [0, 1, 2], [0, 1, 0.8]);
|
|
178
177
|
|
|
179
178
|
// applies to current screen
|
|
@@ -367,16 +366,33 @@ export const SharedAppleMusic = (
|
|
|
367
366
|
|
|
368
367
|
const normX = active.gesture.normalizedX;
|
|
369
368
|
const normY = active.gesture.normalizedY;
|
|
369
|
+
const initialDirection = active.gesture.direction;
|
|
370
370
|
|
|
371
371
|
/**
|
|
372
372
|
* ===============================
|
|
373
373
|
* Animations for both bounds
|
|
374
374
|
* ===============================
|
|
375
375
|
*/
|
|
376
|
-
const
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
const
|
|
376
|
+
const xResistance = initialDirection === "horizontal" ? 0.7 : 0.4;
|
|
377
|
+
const yResistance = initialDirection === "vertical" ? 0.7 : 0.4;
|
|
378
|
+
|
|
379
|
+
const xScaleOuput = initialDirection === "horizontal" ? [1, 0.5] : [1, 1];
|
|
380
|
+
const yScaleOuput = initialDirection === "vertical" ? [1, 0.5] : [1, 1];
|
|
381
|
+
|
|
382
|
+
const dragX = interpolate(
|
|
383
|
+
normX,
|
|
384
|
+
[-1, 0, 1],
|
|
385
|
+
[-screen.width * xResistance, 0, screen.width * xResistance],
|
|
386
|
+
"clamp",
|
|
387
|
+
);
|
|
388
|
+
const dragY = interpolate(
|
|
389
|
+
normY,
|
|
390
|
+
[-1, 0, 1],
|
|
391
|
+
[-screen.height * yResistance, 0, screen.height * yResistance],
|
|
392
|
+
"clamp",
|
|
393
|
+
);
|
|
394
|
+
const dragXScale = interpolate(normX, [0, 1], xScaleOuput);
|
|
395
|
+
const dragYScale = interpolate(normY, [0, 1], yScaleOuput);
|
|
380
396
|
|
|
381
397
|
const boundValues = bounds({
|
|
382
398
|
method: focused ? "content" : "transform",
|
|
@@ -387,8 +403,8 @@ export const SharedAppleMusic = (
|
|
|
387
403
|
|
|
388
404
|
const opacity = interpolate(
|
|
389
405
|
progress,
|
|
390
|
-
[0, 0.
|
|
391
|
-
[0, 1, 1,
|
|
406
|
+
[0, 0.25, 1.25, 2],
|
|
407
|
+
[0, 1, 1, 0],
|
|
392
408
|
"clamp",
|
|
393
409
|
);
|
|
394
410
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { describe, expect, it, mock } from "bun:test";
|
|
2
|
+
|
|
3
|
+
mock.module("react-native", () => ({}));
|
|
4
|
+
mock.module("react-native-gesture-handler", () => ({}));
|
|
5
|
+
mock.module("react-native-reanimated", () => ({
|
|
6
|
+
clamp: (value: number, lower: number, upper: number) =>
|
|
7
|
+
Math.min(Math.max(value, lower), upper),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
const { determineDismissal } = await import(
|
|
11
|
+
"../utils/gesture/determine-dismissal"
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
describe("determineDismissal", () => {
|
|
15
|
+
const dimensions = { width: 320, height: 640 };
|
|
16
|
+
|
|
17
|
+
it("dismisses when horizontal translation exceeds the threshold", () => {
|
|
18
|
+
const { shouldDismiss } = determineDismissal({
|
|
19
|
+
event: {
|
|
20
|
+
translationX: 170,
|
|
21
|
+
translationY: 0,
|
|
22
|
+
velocityX: 0,
|
|
23
|
+
velocityY: 0,
|
|
24
|
+
},
|
|
25
|
+
directions: {
|
|
26
|
+
vertical: false,
|
|
27
|
+
verticalInverted: false,
|
|
28
|
+
horizontal: true,
|
|
29
|
+
horizontalInverted: false,
|
|
30
|
+
},
|
|
31
|
+
dimensions,
|
|
32
|
+
gestureVelocityImpact: 0.3,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
expect(shouldDismiss).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("ignores movement in disallowed directions", () => {
|
|
39
|
+
const { shouldDismiss } = determineDismissal({
|
|
40
|
+
event: {
|
|
41
|
+
translationX: 200,
|
|
42
|
+
translationY: 0,
|
|
43
|
+
velocityX: 0,
|
|
44
|
+
velocityY: 0,
|
|
45
|
+
},
|
|
46
|
+
directions: {
|
|
47
|
+
vertical: true,
|
|
48
|
+
verticalInverted: false,
|
|
49
|
+
horizontal: false,
|
|
50
|
+
horizontalInverted: false,
|
|
51
|
+
},
|
|
52
|
+
dimensions,
|
|
53
|
+
gestureVelocityImpact: 0.3,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expect(shouldDismiss).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("dismisses vertical gestures when velocity pushes the projection past the threshold", () => {
|
|
60
|
+
const { shouldDismiss } = determineDismissal({
|
|
61
|
+
event: {
|
|
62
|
+
translationX: 0,
|
|
63
|
+
translationY: 40,
|
|
64
|
+
velocityX: 0,
|
|
65
|
+
velocityY: 1800,
|
|
66
|
+
},
|
|
67
|
+
directions: {
|
|
68
|
+
vertical: true,
|
|
69
|
+
verticalInverted: false,
|
|
70
|
+
horizontal: false,
|
|
71
|
+
horizontalInverted: false,
|
|
72
|
+
},
|
|
73
|
+
dimensions,
|
|
74
|
+
gestureVelocityImpact: 0.3,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
expect(shouldDismiss).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("respects inverted horizontal directions", () => {
|
|
81
|
+
const { shouldDismiss } = determineDismissal({
|
|
82
|
+
event: {
|
|
83
|
+
translationX: -160,
|
|
84
|
+
translationY: 0,
|
|
85
|
+
velocityX: -700,
|
|
86
|
+
velocityY: 0,
|
|
87
|
+
},
|
|
88
|
+
directions: {
|
|
89
|
+
vertical: false,
|
|
90
|
+
verticalInverted: false,
|
|
91
|
+
horizontal: false,
|
|
92
|
+
horizontalInverted: true,
|
|
93
|
+
},
|
|
94
|
+
dimensions,
|
|
95
|
+
gestureVelocityImpact: 0.25,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
expect(shouldDismiss).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("returns false when movement never exceeds the composite threshold", () => {
|
|
102
|
+
const { shouldDismiss } = determineDismissal({
|
|
103
|
+
event: {
|
|
104
|
+
translationX: 30,
|
|
105
|
+
translationY: 0,
|
|
106
|
+
velocityX: 100,
|
|
107
|
+
velocityY: 0,
|
|
108
|
+
},
|
|
109
|
+
directions: {
|
|
110
|
+
vertical: false,
|
|
111
|
+
verticalInverted: false,
|
|
112
|
+
horizontal: true,
|
|
113
|
+
horizontalInverted: false,
|
|
114
|
+
},
|
|
115
|
+
dimensions,
|
|
116
|
+
gestureVelocityImpact: 0.2,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(shouldDismiss).toBe(false);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { describe, expect, it, mock } from "bun:test";
|
|
2
|
+
|
|
3
|
+
mock.module("react-native", () => ({}));
|
|
4
|
+
mock.module("react-native-gesture-handler", () => ({}));
|
|
5
|
+
mock.module("react-native-reanimated", () => ({
|
|
6
|
+
clamp: (value: number, lower: number, upper: number) =>
|
|
7
|
+
Math.min(Math.max(value, lower), upper),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
const { velocity } = await import("../utils/gesture/velocity");
|
|
11
|
+
|
|
12
|
+
type Directions = {
|
|
13
|
+
horizontal: boolean;
|
|
14
|
+
horizontalInverted: boolean;
|
|
15
|
+
vertical: boolean;
|
|
16
|
+
verticalInverted: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type GestureEventInit = {
|
|
20
|
+
translationX?: number;
|
|
21
|
+
translationY?: number;
|
|
22
|
+
velocityX?: number;
|
|
23
|
+
velocityY?: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const createAnimations = (progress: number) =>
|
|
27
|
+
({
|
|
28
|
+
progress: { value: progress },
|
|
29
|
+
closing: { value: 0 },
|
|
30
|
+
animating: { value: 0 },
|
|
31
|
+
}) as const;
|
|
32
|
+
|
|
33
|
+
const createEvent = ({
|
|
34
|
+
translationX = 0,
|
|
35
|
+
translationY = 0,
|
|
36
|
+
velocityX = 0,
|
|
37
|
+
velocityY = 0,
|
|
38
|
+
}: GestureEventInit) =>
|
|
39
|
+
({ translationX, translationY, velocityX, velocityY }) as any;
|
|
40
|
+
|
|
41
|
+
const createDirections = (overrides: Partial<Directions> = {}) => ({
|
|
42
|
+
horizontal: false,
|
|
43
|
+
horizontalInverted: false,
|
|
44
|
+
vertical: false,
|
|
45
|
+
verticalInverted: false,
|
|
46
|
+
...overrides,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("velocity.normalize", () => {
|
|
50
|
+
it("clamps values to the configured range", () => {
|
|
51
|
+
expect(velocity.normalize(6400, 320)).toBeCloseTo(3.2, 5);
|
|
52
|
+
expect(velocity.normalize(-6400, 320)).toBeCloseTo(-3.2, 5);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe("velocity.calculateProgressVelocity", () => {
|
|
57
|
+
const dimensions = { width: 320, height: 640 };
|
|
58
|
+
|
|
59
|
+
it("returns positive magnitude when progressing toward open target", () => {
|
|
60
|
+
const animations = createAnimations(0.25);
|
|
61
|
+
const event = createEvent({
|
|
62
|
+
translationX: 48,
|
|
63
|
+
translationY: 6,
|
|
64
|
+
velocityX: 800,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const result = velocity.calculateProgressVelocity({
|
|
68
|
+
animations: animations as any,
|
|
69
|
+
shouldDismiss: false,
|
|
70
|
+
event,
|
|
71
|
+
dimensions,
|
|
72
|
+
directions: createDirections({ horizontal: true }),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(result).toBeCloseTo(2.5, 5);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("prefers the axis with greater normalized translation", () => {
|
|
79
|
+
const animations = createAnimations(0.8);
|
|
80
|
+
const event = createEvent({
|
|
81
|
+
translationX: 24,
|
|
82
|
+
translationY: -140,
|
|
83
|
+
velocityX: 120,
|
|
84
|
+
velocityY: -900,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const result = velocity.calculateProgressVelocity({
|
|
88
|
+
animations: animations as any,
|
|
89
|
+
shouldDismiss: true,
|
|
90
|
+
event,
|
|
91
|
+
dimensions,
|
|
92
|
+
directions: createDirections({ horizontal: true, verticalInverted: true }),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
expect(result).toBeLessThan(0);
|
|
96
|
+
expect(Math.abs(result)).toBeCloseTo(1.406, 3);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("caps the returned magnitude using clamp", () => {
|
|
100
|
+
const animations = createAnimations(0.5);
|
|
101
|
+
const event = createEvent({
|
|
102
|
+
translationX: 10,
|
|
103
|
+
velocityX: 5000,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const result = velocity.calculateProgressVelocity({
|
|
107
|
+
animations: animations as any,
|
|
108
|
+
shouldDismiss: false,
|
|
109
|
+
event,
|
|
110
|
+
dimensions,
|
|
111
|
+
directions: createDirections({ horizontal: true }),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expect(result).toBeCloseTo(3.2, 5);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe("velocity.shouldPassDismissalThreshold", () => {
|
|
119
|
+
const width = 320;
|
|
120
|
+
|
|
121
|
+
it("returns true once translation alone crosses half the screen", () => {
|
|
122
|
+
expect(
|
|
123
|
+
velocity.shouldPassDismissalThreshold(170, 0, width, 0.3),
|
|
124
|
+
).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("combines translation with weighted velocity", () => {
|
|
128
|
+
expect(
|
|
129
|
+
velocity.shouldPassDismissalThreshold(40, 2500, width, 0.5),
|
|
130
|
+
).toBe(true);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("returns false when movement is negligible", () => {
|
|
134
|
+
expect(
|
|
135
|
+
velocity.shouldPassDismissalThreshold(0, 0, width, 0.3),
|
|
136
|
+
).toBe(false);
|
|
137
|
+
});
|
|
138
|
+
});
|
package/src/constants.ts
CHANGED
|
@@ -33,6 +33,7 @@ export const DEFAULT_SCREEN_TRANSITION_STATE: ScreenTransitionState =
|
|
|
33
33
|
normalizedY: 0,
|
|
34
34
|
isDismissing: 0,
|
|
35
35
|
isDragging: 0,
|
|
36
|
+
direction: null,
|
|
36
37
|
},
|
|
37
38
|
bounds: {} as Record<string, BoundEntry>,
|
|
38
39
|
route: {} as RouteProp<ParamListBase>,
|
|
@@ -54,6 +55,7 @@ export const EMPTY_BOUND_HELPER_RESULT_RAW = Object.freeze({
|
|
|
54
55
|
});
|
|
55
56
|
export const ENTER_RANGE = [0, 1] as const;
|
|
56
57
|
export const EXIT_RANGE = [1, 2] as const;
|
|
58
|
+
|
|
57
59
|
export const FULLSCREEN_DIMENSIONS = (
|
|
58
60
|
dimensions: ScaledSize,
|
|
59
61
|
): MeasuredDimensions => {
|
|
@@ -45,6 +45,7 @@ const unwrap = (
|
|
|
45
45
|
normalizedY: s.gesture.normalizedY.value,
|
|
46
46
|
isDismissing: s.gesture.isDismissing.value,
|
|
47
47
|
isDragging: s.gesture.isDragging.value,
|
|
48
|
+
direction: s.gesture.direction.value,
|
|
48
49
|
},
|
|
49
50
|
bounds: Bounds.getBounds(key) || NO_BOUNDS_MAP,
|
|
50
51
|
route: s.route,
|