react-native-screen-transitions 3.3.0-beta.2 → 3.3.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/shared/animation/snap-to.js +15 -10
- package/lib/commonjs/shared/animation/snap-to.js.map +1 -1
- package/lib/commonjs/shared/components/screen-container.js +10 -4
- package/lib/commonjs/shared/components/screen-container.js.map +1 -1
- package/lib/commonjs/shared/providers/gestures.provider.js +1 -20
- package/lib/commonjs/shared/providers/gestures.provider.js.map +1 -1
- package/lib/module/shared/animation/snap-to.js +15 -10
- package/lib/module/shared/animation/snap-to.js.map +1 -1
- package/lib/module/shared/components/screen-container.js +10 -4
- package/lib/module/shared/components/screen-container.js.map +1 -1
- package/lib/module/shared/providers/gestures.provider.js +1 -20
- package/lib/module/shared/providers/gestures.provider.js.map +1 -1
- package/lib/typescript/shared/animation/snap-to.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-container.d.ts.map +1 -1
- package/lib/typescript/shared/providers/gestures.provider.d.ts +1 -1
- package/lib/typescript/shared/providers/gestures.provider.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/shared/animation/snap-to.ts +16 -11
- package/src/shared/components/screen-container.tsx +11 -6
- package/src/shared/providers/gestures.provider.tsx +2 -20
|
@@ -9,6 +9,7 @@ var _specs = require("../configs/specs");
|
|
|
9
9
|
var _animation = require("../stores/animation.store");
|
|
10
10
|
var _history = require("../stores/history.store");
|
|
11
11
|
var _animateToProgress = require("../utils/animation/animate-to-progress");
|
|
12
|
+
var _logger = require("../utils/logger");
|
|
12
13
|
/**
|
|
13
14
|
* Programmatically snap the currently focused screen to a specific snap point.
|
|
14
15
|
*
|
|
@@ -26,22 +27,26 @@ var _animateToProgress = require("../utils/animation/animate-to-progress");
|
|
|
26
27
|
* ```
|
|
27
28
|
*/
|
|
28
29
|
function snapTo(index) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// Find the most recent screen that has snapPoints defined.
|
|
31
|
+
// This handles cases where parent screens (e.g., expo-router) register after
|
|
32
|
+
// ComponentStack screens, but the ComponentStack is what we want to snap.
|
|
33
|
+
const allHistory = _history.HistoryStore.toArray();
|
|
34
|
+
const screenWithSnapPoints = allHistory.filter(entry => {
|
|
35
|
+
const sp = entry.descriptor.options?.snapPoints;
|
|
36
|
+
return sp && sp.length > 0;
|
|
37
|
+
}).pop(); // Last item is most recent (toArray returns oldest-first)
|
|
38
|
+
|
|
39
|
+
if (!screenWithSnapPoints) {
|
|
40
|
+
_logger.logger.warn("snapTo: No screens with snapPoints in history");
|
|
32
41
|
return;
|
|
33
42
|
}
|
|
34
43
|
const {
|
|
35
44
|
descriptor
|
|
36
|
-
} =
|
|
37
|
-
const snapPoints = descriptor.options
|
|
38
|
-
if (!snapPoints || snapPoints.length === 0) {
|
|
39
|
-
console.warn("snapTo: No snapPoints defined on current screen");
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
45
|
+
} = screenWithSnapPoints;
|
|
46
|
+
const snapPoints = descriptor.options.snapPoints;
|
|
42
47
|
const sorted = [...snapPoints].sort((a, b) => a - b);
|
|
43
48
|
if (index < 0 || index >= sorted.length) {
|
|
44
|
-
|
|
49
|
+
_logger.logger.warn(`snapTo: index ${index} out of bounds (0-${sorted.length - 1})`);
|
|
45
50
|
return;
|
|
46
51
|
}
|
|
47
52
|
const targetProgress = sorted[index];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeReanimated","require","_specs","_animation","_history","_animateToProgress","snapTo","index","
|
|
1
|
+
{"version":3,"names":["_reactNativeReanimated","require","_specs","_animation","_history","_animateToProgress","_logger","snapTo","index","allHistory","HistoryStore","toArray","screenWithSnapPoints","filter","entry","sp","descriptor","options","snapPoints","length","pop","logger","warn","sorted","sort","a","b","targetProgress","animations","AnimationStore","getAll","route","key","runOnUI","animateToProgress","target","spec","open","transitionSpec","expand","DefaultSnapSpec","close","collapse"],"sourceRoot":"../../../../src","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C;EACpC,MAAMoB,UAAU,GAAGC,yBAAc,CAACC,MAAM,CAACd,UAAU,CAACe,KAAK,CAACC,GAAG,CAAC;EAE9D,IAAAC,8BAAO,EAAC,MAAM;IACb,SAAS;;IACT,IAAAC,oCAAiB,EAAC;MACjBC,MAAM,EAAER,cAAc;MACtBC,UAAU;MACVQ,IAAI,EAAE;QACLC,IAAI,EAAErB,UAAU,CAACC,OAAO,CAACqB,cAAc,EAAEC,MAAM,IAAIC,sBAAe;QAClEC,KAAK,EAAEzB,UAAU,CAACC,OAAO,CAACqB,cAAc,EAAEI,QAAQ,IAAIF;MACvD;IACD,CAAC,CAAC;EACH,CAAC,CAAC,CAAC,CAAC;AACL","ignoreList":[]}
|
|
@@ -7,9 +7,11 @@ exports.ScreenContainer = void 0;
|
|
|
7
7
|
var _native = require("@react-navigation/native");
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
|
+
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
10
11
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
11
12
|
var _constants = require("../constants");
|
|
12
13
|
var _useBackdropPointerEvents = require("../hooks/use-backdrop-pointer-events");
|
|
14
|
+
var _gestures = require("../providers/gestures.provider");
|
|
13
15
|
var _keys = require("../providers/screen/keys.provider");
|
|
14
16
|
var _styles = require("../providers/screen/styles.provider");
|
|
15
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -27,6 +29,7 @@ const ScreenContainer = exports.ScreenContainer = /*#__PURE__*/(0, _react.memo)(
|
|
|
27
29
|
pointerEvents,
|
|
28
30
|
backdropBehavior
|
|
29
31
|
} = (0, _useBackdropPointerEvents.useBackdropPointerEvents)();
|
|
32
|
+
const gestureContext = (0, _gestures.useGestureContext)();
|
|
30
33
|
const isDismissable = backdropBehavior === "dismiss";
|
|
31
34
|
const handleBackdropPress = (0, _react.useCallback)(() => {
|
|
32
35
|
current.navigation.dispatch(_native.StackActions.pop());
|
|
@@ -51,10 +54,13 @@ const ScreenContainer = exports.ScreenContainer = /*#__PURE__*/(0, _react.memo)(
|
|
|
51
54
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
52
55
|
style: [_reactNative.StyleSheet.absoluteFillObject, animatedBackdropStyle]
|
|
53
56
|
})
|
|
54
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector, {
|
|
58
|
+
gesture: gestureContext.panGesture,
|
|
59
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
60
|
+
style: [styles.content, animatedContentStyle],
|
|
61
|
+
pointerEvents: isDismissable ? "box-none" : pointerEvents,
|
|
62
|
+
children: children
|
|
63
|
+
})
|
|
58
64
|
})]
|
|
59
65
|
});
|
|
60
66
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_native","require","_react","_reactNative","_reactNativeReanimated","_interopRequireWildcard","_constants","_useBackdropPointerEvents","_keys","_styles","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ScreenContainer","exports","memo","children","stylesMap","useScreenStyles","current","useKeys","pointerEvents","backdropBehavior","useBackdropPointerEvents","isDismissable","handleBackdropPress","useCallback","navigation","dispatch","StackActions","pop","animatedContentStyle","useAnimatedStyle","value","contentStyle","NO_STYLES","animatedBackdropStyle","backdropStyle","overlayStyle","jsxs","View","style","styles","container","jsx","Pressable","StyleSheet","absoluteFillObject","onPress","undefined","content","create","flex"],"sourceRoot":"../../../../src","sources":["shared/components/screen-container.tsx"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAC,uBAAA,
|
|
1
|
+
{"version":3,"names":["_native","require","_react","_reactNative","_reactNativeGestureHandler","_reactNativeReanimated","_interopRequireWildcard","_constants","_useBackdropPointerEvents","_gestures","_keys","_styles","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ScreenContainer","exports","memo","children","stylesMap","useScreenStyles","current","useKeys","pointerEvents","backdropBehavior","useBackdropPointerEvents","gestureContext","useGestureContext","isDismissable","handleBackdropPress","useCallback","navigation","dispatch","StackActions","pop","animatedContentStyle","useAnimatedStyle","value","contentStyle","NO_STYLES","animatedBackdropStyle","backdropStyle","overlayStyle","jsxs","View","style","styles","container","jsx","Pressable","StyleSheet","absoluteFillObject","onPress","undefined","GestureDetector","gesture","panGesture","content","create","flex"],"sourceRoot":"../../../../src","sources":["shared/components/screen-container.tsx"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAC,uBAAA,CAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,yBAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAAsE,IAAAW,WAAA,GAAAX,OAAA;AAAA,SAAAK,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC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E;QAC9CZ,aAAa,EAAEK,aAAa,GAAG,UAAU,GAAGL,aAAc;QAAAL,QAAA,EAEzDA;MAAQ,CACK;IAAC,CACA,CAAC;EAAA,CACb,CAAC;AAET,CAAC,CAAC;AAEF,MAAM4B,MAAM,GAAGI,uBAAU,CAACQ,MAAM,CAAC;EAChCX,SAAS,EAAE;IACVY,IAAI,EAAE;EACP,CAAC;EACDF,OAAO,EAAE;IACRE,IAAI,EAAE;EACP;AACD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -4,14 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useGestureContext = exports.ScreenGestureProvider = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
9
7
|
var _reactNativeReanimated = require("react-native-reanimated");
|
|
10
8
|
var _useBuildGestures = require("../hooks/gestures/use-build-gestures");
|
|
11
|
-
var _useBackdropPointerEvents = require("../hooks/use-backdrop-pointer-events");
|
|
12
9
|
var _createProvider = _interopRequireDefault(require("../utils/create-provider"));
|
|
13
10
|
var _keys = require("./screen/keys.provider");
|
|
14
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
12
|
const {
|
|
17
13
|
ScreenGestureProvider,
|
|
@@ -26,9 +22,6 @@ const {
|
|
|
26
22
|
} = (0, _keys.useKeys)();
|
|
27
23
|
const ancestorContext = useGestureContext();
|
|
28
24
|
const scrollConfig = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
29
|
-
const {
|
|
30
|
-
pointerEvents
|
|
31
|
-
} = (0, _useBackdropPointerEvents.useBackdropPointerEvents)();
|
|
32
25
|
const hasGestures = current.options.gestureEnabled === true;
|
|
33
26
|
const {
|
|
34
27
|
panGesture,
|
|
@@ -50,21 +43,9 @@ const {
|
|
|
50
43
|
};
|
|
51
44
|
return {
|
|
52
45
|
value,
|
|
53
|
-
children
|
|
54
|
-
gesture: panGesture,
|
|
55
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
56
|
-
style: styles.container,
|
|
57
|
-
pointerEvents: pointerEvents,
|
|
58
|
-
children: children
|
|
59
|
-
})
|
|
60
|
-
})
|
|
46
|
+
children
|
|
61
47
|
};
|
|
62
48
|
});
|
|
63
49
|
exports.useGestureContext = useGestureContext;
|
|
64
50
|
exports.ScreenGestureProvider = ScreenGestureProvider;
|
|
65
|
-
const styles = _reactNative.StyleSheet.create({
|
|
66
|
-
container: {
|
|
67
|
-
flex: 1
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
51
|
//# sourceMappingURL=gestures.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_reactNativeReanimated","require","_useBuildGestures","_createProvider","_interopRequireDefault","_keys","e","__esModule","default","ScreenGestureProvider","useScreenGestureContext","useGestureContext","createProvider","guarded","children","current","useKeys","ancestorContext","scrollConfig","useSharedValue","hasGestures","options","gestureEnabled","panGesture","panGestureRef","nativeGesture","gestureAnimationValues","useBuildGestures","value","exports"],"sourceRoot":"../../../../src","sources":["shared/providers/gestures.provider.tsx"],"mappings":";;;;;;AAEA,IAAAA,sBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAAiD,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA0B1C,MAAM;EACZG,qBAAqB;EACrBC,uBAAuB,EAAEC;AAC1B,CAAC,GAAG,IAAAC,uBAAc,EAAC,eAAe,EAAE;EAAEC,OAAO,EAAE;AAAM,CAAC,CAAC,CAGrD,CAAC;EAAEC;AAAS,CAAC,KAAK;EACnB,MAAM;IAAEC;EAAQ,CAAC,GAAG,IAAAC,aAAO,EAAC,CAAC;EAC7B,MAAMC,eAAe,GAAGN,iBAAiB,CAAC,CAAC;EAC3C,MAAMO,YAAY,GAAG,IAAAC,qCAAc,EAAsB,IAAI,CAAC;EAE9D,MAAMC,WAAW,GAAGL,OAAO,CAACM,OAAO,CAACC,cAAc,KAAK,IAAI;EAE3D,MAAM;IAAEC,UAAU;IAAEC,aAAa;IAAEC,aAAa;IAAEC;EAAuB,CAAC,GACzE,IAAAC,kCAAgB,EAAC;IAChBT,YAAY;IACZD;EACD,CAAC,CAAC;EAEH,MAAMW,KAAyB,GAAG;IACjCL,UAAU;IACVC,aAAa;IACbN,YAAY;IACZO,aAAa;IACbC,sBAAsB;IACtBT,eAAe;IACfK,cAAc,EAAEF;EACjB,CAAC;EAED,OAAO;IACNQ,KAAK;IACLd;EACD,CAAC;AACF,CAAC,CAAC;AAACe,OAAA,CAAAlB,iBAAA,GAAAA,iBAAA;AAAAkB,OAAA,CAAApB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ import { DefaultSnapSpec } from "../configs/specs";
|
|
|
5
5
|
import { AnimationStore } from "../stores/animation.store";
|
|
6
6
|
import { HistoryStore } from "../stores/history.store";
|
|
7
7
|
import { animateToProgress } from "../utils/animation/animate-to-progress";
|
|
8
|
+
import { logger } from "../utils/logger";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Programmatically snap the currently focused screen to a specific snap point.
|
|
@@ -23,22 +24,26 @@ import { animateToProgress } from "../utils/animation/animate-to-progress";
|
|
|
23
24
|
* ```
|
|
24
25
|
*/
|
|
25
26
|
export function snapTo(index) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// Find the most recent screen that has snapPoints defined.
|
|
28
|
+
// This handles cases where parent screens (e.g., expo-router) register after
|
|
29
|
+
// ComponentStack screens, but the ComponentStack is what we want to snap.
|
|
30
|
+
const allHistory = HistoryStore.toArray();
|
|
31
|
+
const screenWithSnapPoints = allHistory.filter(entry => {
|
|
32
|
+
const sp = entry.descriptor.options?.snapPoints;
|
|
33
|
+
return sp && sp.length > 0;
|
|
34
|
+
}).pop(); // Last item is most recent (toArray returns oldest-first)
|
|
35
|
+
|
|
36
|
+
if (!screenWithSnapPoints) {
|
|
37
|
+
logger.warn("snapTo: No screens with snapPoints in history");
|
|
29
38
|
return;
|
|
30
39
|
}
|
|
31
40
|
const {
|
|
32
41
|
descriptor
|
|
33
|
-
} =
|
|
34
|
-
const snapPoints = descriptor.options
|
|
35
|
-
if (!snapPoints || snapPoints.length === 0) {
|
|
36
|
-
console.warn("snapTo: No snapPoints defined on current screen");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
42
|
+
} = screenWithSnapPoints;
|
|
43
|
+
const snapPoints = descriptor.options.snapPoints;
|
|
39
44
|
const sorted = [...snapPoints].sort((a, b) => a - b);
|
|
40
45
|
if (index < 0 || index >= sorted.length) {
|
|
41
|
-
|
|
46
|
+
logger.warn(`snapTo: index ${index} out of bounds (0-${sorted.length - 1})`);
|
|
42
47
|
return;
|
|
43
48
|
}
|
|
44
49
|
const targetProgress = sorted[index];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["runOnUI","DefaultSnapSpec","AnimationStore","HistoryStore","animateToProgress","snapTo","index","
|
|
1
|
+
{"version":3,"names":["runOnUI","DefaultSnapSpec","AnimationStore","HistoryStore","animateToProgress","logger","snapTo","index","allHistory","toArray","screenWithSnapPoints","filter","entry","sp","descriptor","options","snapPoints","length","pop","warn","sorted","sort","a","b","targetProgress","animations","getAll","route","key","target","spec","open","transitionSpec","expand","close","collapse"],"sourceRoot":"../../../../src","sources":["shared/animation/snap-to.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,yBAAyB;AACjD,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,cAAc,QAAQ,2BAA2B;AAC1D,SA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SAAS;;IACTI,iBAAiB,CAAC;MACjByB,MAAM,EAAEL,cAAc;MACtBC,UAAU;MACVK,IAAI,EAAE;QACLC,IAAI,EAAEjB,UAAU,CAACC,OAAO,CAACiB,cAAc,EAAEC,MAAM,IAAIhC,eAAe;QAClEiC,KAAK,EAAEpB,UAAU,CAACC,OAAO,CAACiB,cAAc,EAAEG,QAAQ,IAAIlC;MACvD;IACD,CAAC,CAAC;EACH,CAAC,CAAC,CAAC,CAAC;AACL","ignoreList":[]}
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
import { StackActions } from "@react-navigation/native";
|
|
4
4
|
import { memo, useCallback } from "react";
|
|
5
5
|
import { Pressable, StyleSheet, View } from "react-native";
|
|
6
|
+
import { GestureDetector } from "react-native-gesture-handler";
|
|
6
7
|
import Animated, { useAnimatedStyle } from "react-native-reanimated";
|
|
7
8
|
import { NO_STYLES } from "../constants";
|
|
8
9
|
import { useBackdropPointerEvents } from "../hooks/use-backdrop-pointer-events";
|
|
10
|
+
import { useGestureContext } from "../providers/gestures.provider";
|
|
9
11
|
import { useKeys } from "../providers/screen/keys.provider";
|
|
10
12
|
import { useScreenStyles } from "../providers/screen/styles.provider";
|
|
11
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -22,6 +24,7 @@ export const ScreenContainer = /*#__PURE__*/memo(({
|
|
|
22
24
|
pointerEvents,
|
|
23
25
|
backdropBehavior
|
|
24
26
|
} = useBackdropPointerEvents();
|
|
27
|
+
const gestureContext = useGestureContext();
|
|
25
28
|
const isDismissable = backdropBehavior === "dismiss";
|
|
26
29
|
const handleBackdropPress = useCallback(() => {
|
|
27
30
|
current.navigation.dispatch(StackActions.pop());
|
|
@@ -46,10 +49,13 @@ export const ScreenContainer = /*#__PURE__*/memo(({
|
|
|
46
49
|
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
47
50
|
style: [StyleSheet.absoluteFillObject, animatedBackdropStyle]
|
|
48
51
|
})
|
|
49
|
-
}), /*#__PURE__*/_jsx(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
}), /*#__PURE__*/_jsx(GestureDetector, {
|
|
53
|
+
gesture: gestureContext.panGesture,
|
|
54
|
+
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
55
|
+
style: [styles.content, animatedContentStyle],
|
|
56
|
+
pointerEvents: isDismissable ? "box-none" : pointerEvents,
|
|
57
|
+
children: children
|
|
58
|
+
})
|
|
53
59
|
})]
|
|
54
60
|
});
|
|
55
61
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StackActions","memo","useCallback","Pressable","StyleSheet","View","Animated","useAnimatedStyle","NO_STYLES","useBackdropPointerEvents","useKeys","useScreenStyles","jsx","_jsx","jsxs","_jsxs","ScreenContainer","children","stylesMap","current","pointerEvents","backdropBehavior","isDismissable","handleBackdropPress","navigation","dispatch","pop","animatedContentStyle","value","contentStyle","animatedBackdropStyle","backdropStyle","overlayStyle","style","styles","container","absoluteFillObject","onPress","undefined","content","create","flex"],"sourceRoot":"../../../../src","sources":["shared/components/screen-container.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,0BAA0B;AACvD,SAASC,IAAI,EAAEC,WAAW,QAAQ,OAAO;AACzC,SAASC,SAAS,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC1D,OAAOC,QAAQ,IAAIC,gBAAgB,QAAQ,yBAAyB;AACpE,SAASC,SAAS,QAAQ,cAAc;AACxC,SAASC,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,OAAO,QAAQ,mCAAmC;AAC3D,SAASC,eAAe,QAAQ,qCAAqC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAMtE,OAAO,MAAMC,eAAe,
|
|
1
|
+
{"version":3,"names":["StackActions","memo","useCallback","Pressable","StyleSheet","View","GestureDetector","Animated","useAnimatedStyle","NO_STYLES","useBackdropPointerEvents","useGestureContext","useKeys","useScreenStyles","jsx","_jsx","jsxs","_jsxs","ScreenContainer","children","stylesMap","current","pointerEvents","backdropBehavior","gestureContext","isDismissable","handleBackdropPress","navigation","dispatch","pop","animatedContentStyle","value","contentStyle","animatedBackdropStyle","backdropStyle","overlayStyle","style","styles","container","absoluteFillObject","onPress","undefined","gesture","panGesture","content","create","flex"],"sourceRoot":"../../../../src","sources":["shared/components/screen-container.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,0BAA0B;AACvD,SAASC,IAAI,EAAEC,WAAW,QAAQ,OAAO;AACzC,SAASC,SAAS,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC1D,SAASC,eAAe,QAAQ,8BAA8B;AAC9D,OAAOC,QAAQ,IAAIC,gBAAgB,QAAQ,yBAAyB;AACpE,SAASC,SAAS,QAAQ,cAAc;AACxC,SAASC,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,OAAO,QAAQ,mCAAmC;AAC3D,SAASC,eAAe,QAAQ,qCAAqC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAMtE,OAAO,MAAMC,eAAe,gBAAGjB,IAAI,CAAC,CAAC;EAAEkB;AAAgB,CAAC,KAAK;EAC5D,MAAM;IAAEC;EAAU,CAAC,GAAGP,eAAe,CAAC,CAAC;EACvC,MAAM;IAAEQ;EAAQ,CAAC,GAAGT,OAAO,CAAC,CAAC;EAC7B,MAAM;IAAEU,aAAa;IAAEC;EAAiB,CAAC,GAAGb,wBAAwB,CAAC,CAAC;EACtE,MAAMc,cAAc,GAAGb,iBAAiB,CAAC,CAAC;EAE1C,MAAMc,aAAa,GAAGF,gBAAgB,KAAK,SAAS;EAEpD,MAAMG,mBAAmB,GAAGxB,WAAW,CAAC,MAAM;IAC7CmB,OAAO,CAACM,UAAU,CAACC,QAAQ,CAAC5B,YAAY,CAAC6B,GAAG,CAAC,CAAC,CAAC;EAChD,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C;EACDF,OAAO,EAAE;IACRE,IAAI,EAAE;EACP;AACD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { StyleSheet, View } from "react-native";
|
|
4
|
-
import { GestureDetector } from "react-native-gesture-handler";
|
|
5
3
|
import { useSharedValue } from "react-native-reanimated";
|
|
6
4
|
import { useBuildGestures } from "../hooks/gestures/use-build-gestures";
|
|
7
|
-
import { useBackdropPointerEvents } from "../hooks/use-backdrop-pointer-events";
|
|
8
5
|
import createProvider from "../utils/create-provider";
|
|
9
6
|
import { useKeys } from "./screen/keys.provider";
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
7
|
export const {
|
|
12
8
|
ScreenGestureProvider,
|
|
13
9
|
useScreenGestureContext: useGestureContext
|
|
@@ -21,9 +17,6 @@ export const {
|
|
|
21
17
|
} = useKeys();
|
|
22
18
|
const ancestorContext = useGestureContext();
|
|
23
19
|
const scrollConfig = useSharedValue(null);
|
|
24
|
-
const {
|
|
25
|
-
pointerEvents
|
|
26
|
-
} = useBackdropPointerEvents();
|
|
27
20
|
const hasGestures = current.options.gestureEnabled === true;
|
|
28
21
|
const {
|
|
29
22
|
panGesture,
|
|
@@ -45,19 +38,7 @@ export const {
|
|
|
45
38
|
};
|
|
46
39
|
return {
|
|
47
40
|
value,
|
|
48
|
-
children
|
|
49
|
-
gesture: panGesture,
|
|
50
|
-
children: /*#__PURE__*/_jsx(View, {
|
|
51
|
-
style: styles.container,
|
|
52
|
-
pointerEvents: pointerEvents,
|
|
53
|
-
children: children
|
|
54
|
-
})
|
|
55
|
-
})
|
|
41
|
+
children
|
|
56
42
|
};
|
|
57
43
|
});
|
|
58
|
-
const styles = StyleSheet.create({
|
|
59
|
-
container: {
|
|
60
|
-
flex: 1
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
44
|
//# sourceMappingURL=gestures.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useSharedValue","useBuildGestures","createProvider","useKeys","ScreenGestureProvider","useScreenGestureContext","useGestureContext","guarded","children","current","ancestorContext","scrollConfig","hasGestures","options","gestureEnabled","panGesture","panGestureRef","nativeGesture","gestureAnimationValues","value"],"sourceRoot":"../../../../src","sources":["shared/providers/gestures.provider.tsx"],"mappings":";;AAEA,SAASA,cAAc,QAAQ,yBAAyB;AACxD,SAASC,gBAAgB,QAAQ,sCAAsC;AAEvE,OAAOC,cAAc,MAAM,0BAA0B;AACrD,SAASC,OAAO,QAAQ,wBAAwB;AA0BhD,OAAO,MAAM;EACZC,qBAAqB;EACrBC,uBAAuB,EAAEC;AAC1B,CAAC,GAAGJ,cAAc,CAAC,eAAe,EAAE;EAAEK,OAAO,EAAE;AAAM,CAAC,CAAC,CAGrD,CAAC;EAAEC;AAAS,CAAC,KAAK;EACnB,MAAM;IAAEC;EAAQ,CAAC,GAAGN,OAAO,CAAC,CAAC;EAC7B,MAAMO,eAAe,GAAGJ,iBAAiB,CAAC,CAAC;EAC3C,MAAMK,YAAY,GAAGX,cAAc,CAAsB,IAAI,CAAC;EAE9D,MAAMY,WAAW,GAAGH,OAAO,CAACI,OAAO,CAACC,cAAc,KAAK,IAAI;EAE3D,MAAM;IAAEC,UAAU;IAAEC,aAAa;IAAEC,aAAa;IAAEC;EAAuB,CAAC,GACzEjB,gBAAgB,CAAC;IAChBU,YAAY;IACZD;EACD,CAAC,CAAC;EAEH,MAAMS,KAAyB,GAAG;IACjCJ,UAAU;IACVC,aAAa;IACbL,YAAY;IACZM,aAAa;IACbC,sBAAsB;IACtBR,eAAe;IACfI,cAAc,EAAEF;EACjB,CAAC;EAED,OAAO;IACNO,KAAK;IACLX;EACD,CAAC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snap-to.d.ts","sourceRoot":"","sources":["../../../../src/shared/animation/snap-to.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"snap-to.d.ts","sourceRoot":"","sources":["../../../../src/shared/animation/snap-to.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CA2C1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen-container.d.ts","sourceRoot":"","sources":["../../../../src/shared/components/screen-container.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"screen-container.d.ts","sourceRoot":"","sources":["../../../../src/shared/components/screen-container.tsx"],"names":[],"mappings":"AAWA,KAAK,KAAK,GAAG;IACZ,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,eAAe,qDAAuB,KAAK,6CA6CtD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { GestureType } from "react-native-gesture-handler";
|
|
2
2
|
import type { SharedValue } from "react-native-reanimated";
|
|
3
3
|
import type { GestureStoreMap } from "../stores/gesture.store";
|
|
4
4
|
export type ScrollConfig = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gestures.provider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/gestures.provider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gestures.provider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/gestures.provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI/D,MAAM,MAAM,YAAY,GAAG;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,kBAAkB;IAClC,UAAU,EAAE,WAAW,CAAC;IACxB,aAAa,EAAE,KAAK,CAAC,gBAAgB,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;IAC/D,aAAa,EAAE,WAAW,CAAC;IAC3B,YAAY,EAAE,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC/C,sBAAsB,EAAE,eAAe,CAAC;IACxC,eAAe,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC3C,cAAc,EAAE,OAAO,CAAC;CACxB;AAED,UAAU,0BAA0B;IACnC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED,eAAO,MACN,qBAAqB,kDACI,iBAAiB,iCA+BzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import { DefaultSnapSpec } from "../configs/specs";
|
|
|
3
3
|
import { AnimationStore } from "../stores/animation.store";
|
|
4
4
|
import { HistoryStore } from "../stores/history.store";
|
|
5
5
|
import { animateToProgress } from "../utils/animation/animate-to-progress";
|
|
6
|
+
import { logger } from "../utils/logger";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Programmatically snap the currently focused screen to a specific snap point.
|
|
@@ -21,25 +22,29 @@ import { animateToProgress } from "../utils/animation/animate-to-progress";
|
|
|
21
22
|
* ```
|
|
22
23
|
*/
|
|
23
24
|
export function snapTo(index: number): void {
|
|
24
|
-
|
|
25
|
+
// Find the most recent screen that has snapPoints defined.
|
|
26
|
+
// This handles cases where parent screens (e.g., expo-router) register after
|
|
27
|
+
// ComponentStack screens, but the ComponentStack is what we want to snap.
|
|
28
|
+
const allHistory = HistoryStore.toArray();
|
|
29
|
+
const screenWithSnapPoints = allHistory
|
|
30
|
+
.filter((entry) => {
|
|
31
|
+
const sp = entry.descriptor.options?.snapPoints;
|
|
32
|
+
return sp && sp.length > 0;
|
|
33
|
+
})
|
|
34
|
+
.pop(); // Last item is most recent (toArray returns oldest-first)
|
|
25
35
|
|
|
26
|
-
if (!
|
|
27
|
-
|
|
36
|
+
if (!screenWithSnapPoints) {
|
|
37
|
+
logger.warn("snapTo: No screens with snapPoints in history");
|
|
28
38
|
return;
|
|
29
39
|
}
|
|
30
40
|
|
|
31
|
-
const { descriptor } =
|
|
32
|
-
const snapPoints = descriptor.options
|
|
33
|
-
|
|
34
|
-
if (!snapPoints || snapPoints.length === 0) {
|
|
35
|
-
console.warn("snapTo: No snapPoints defined on current screen");
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
41
|
+
const { descriptor } = screenWithSnapPoints;
|
|
42
|
+
const snapPoints = descriptor.options!.snapPoints!;
|
|
38
43
|
|
|
39
44
|
const sorted = [...snapPoints].sort((a, b) => a - b);
|
|
40
45
|
|
|
41
46
|
if (index < 0 || index >= sorted.length) {
|
|
42
|
-
|
|
47
|
+
logger.warn(
|
|
43
48
|
`snapTo: index ${index} out of bounds (0-${sorted.length - 1})`,
|
|
44
49
|
);
|
|
45
50
|
return;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { StackActions } from "@react-navigation/native";
|
|
2
2
|
import { memo, useCallback } from "react";
|
|
3
3
|
import { Pressable, StyleSheet, View } from "react-native";
|
|
4
|
+
import { GestureDetector } from "react-native-gesture-handler";
|
|
4
5
|
import Animated, { useAnimatedStyle } from "react-native-reanimated";
|
|
5
6
|
import { NO_STYLES } from "../constants";
|
|
6
7
|
import { useBackdropPointerEvents } from "../hooks/use-backdrop-pointer-events";
|
|
8
|
+
import { useGestureContext } from "../providers/gestures.provider";
|
|
7
9
|
import { useKeys } from "../providers/screen/keys.provider";
|
|
8
10
|
import { useScreenStyles } from "../providers/screen/styles.provider";
|
|
9
11
|
|
|
@@ -15,6 +17,7 @@ export const ScreenContainer = memo(({ children }: Props) => {
|
|
|
15
17
|
const { stylesMap } = useScreenStyles();
|
|
16
18
|
const { current } = useKeys();
|
|
17
19
|
const { pointerEvents, backdropBehavior } = useBackdropPointerEvents();
|
|
20
|
+
const gestureContext = useGestureContext();
|
|
18
21
|
|
|
19
22
|
const isDismissable = backdropBehavior === "dismiss";
|
|
20
23
|
|
|
@@ -45,12 +48,14 @@ export const ScreenContainer = memo(({ children }: Props) => {
|
|
|
45
48
|
style={[StyleSheet.absoluteFillObject, animatedBackdropStyle]}
|
|
46
49
|
/>
|
|
47
50
|
</Pressable>
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
<GestureDetector gesture={gestureContext!.panGesture}>
|
|
52
|
+
<Animated.View
|
|
53
|
+
style={[styles.content, animatedContentStyle]}
|
|
54
|
+
pointerEvents={isDismissable ? "box-none" : pointerEvents}
|
|
55
|
+
>
|
|
56
|
+
{children}
|
|
57
|
+
</Animated.View>
|
|
58
|
+
</GestureDetector>
|
|
54
59
|
</View>
|
|
55
60
|
);
|
|
56
61
|
});
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
GestureDetector,
|
|
4
|
-
type GestureType,
|
|
5
|
-
} from "react-native-gesture-handler";
|
|
1
|
+
import type { GestureType } from "react-native-gesture-handler";
|
|
6
2
|
import type { SharedValue } from "react-native-reanimated";
|
|
7
3
|
import { useSharedValue } from "react-native-reanimated";
|
|
8
4
|
import { useBuildGestures } from "../hooks/gestures/use-build-gestures";
|
|
9
|
-
import { useBackdropPointerEvents } from "../hooks/use-backdrop-pointer-events";
|
|
10
5
|
import type { GestureStoreMap } from "../stores/gesture.store";
|
|
11
6
|
import createProvider from "../utils/create-provider";
|
|
12
7
|
import { useKeys } from "./screen/keys.provider";
|
|
@@ -45,7 +40,6 @@ export const {
|
|
|
45
40
|
const { current } = useKeys();
|
|
46
41
|
const ancestorContext = useGestureContext();
|
|
47
42
|
const scrollConfig = useSharedValue<ScrollConfig | null>(null);
|
|
48
|
-
const { pointerEvents } = useBackdropPointerEvents();
|
|
49
43
|
|
|
50
44
|
const hasGestures = current.options.gestureEnabled === true;
|
|
51
45
|
|
|
@@ -67,18 +61,6 @@ export const {
|
|
|
67
61
|
|
|
68
62
|
return {
|
|
69
63
|
value,
|
|
70
|
-
children
|
|
71
|
-
<GestureDetector gesture={panGesture}>
|
|
72
|
-
<View style={styles.container} pointerEvents={pointerEvents}>
|
|
73
|
-
{children}
|
|
74
|
-
</View>
|
|
75
|
-
</GestureDetector>
|
|
76
|
-
),
|
|
64
|
+
children,
|
|
77
65
|
};
|
|
78
66
|
});
|
|
79
|
-
|
|
80
|
-
const styles = StyleSheet.create({
|
|
81
|
-
container: {
|
|
82
|
-
flex: 1,
|
|
83
|
-
},
|
|
84
|
-
});
|