react-native-screen-transitions 3.3.0-beta.0 → 3.3.0-beta.2
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 +104 -9
- package/lib/commonjs/blank-stack/components/adjusted-screen.js +2 -2
- package/lib/commonjs/blank-stack/components/adjusted-screen.js.map +1 -1
- package/lib/commonjs/shared/animation/snap-to.js +62 -0
- package/lib/commonjs/shared/animation/snap-to.js.map +1 -0
- package/lib/commonjs/shared/constants.js +36 -10
- package/lib/commonjs/shared/constants.js.map +1 -1
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js +25 -18
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js +0 -25
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-screen-gesture-handlers.js +74 -64
- package/lib/commonjs/shared/hooks/gestures/use-screen-gesture-handlers.js.map +1 -1
- package/lib/commonjs/shared/hooks/navigation/use-screen-state.js +2 -61
- package/lib/commonjs/shared/hooks/navigation/use-screen-state.js.map +1 -1
- package/lib/commonjs/shared/index.js +7 -0
- package/lib/commonjs/shared/index.js.map +1 -1
- package/lib/commonjs/shared/stores/animation.store.js +2 -1
- package/lib/commonjs/shared/stores/animation.store.js.map +1 -1
- package/lib/commonjs/shared/utils/animation/animate-to-progress.js +8 -2
- package/lib/commonjs/shared/utils/animation/animate-to-progress.js.map +1 -1
- package/lib/commonjs/shared/utils/gesture/check-gesture-activation.js +90 -23
- package/lib/commonjs/shared/utils/gesture/check-gesture-activation.js.map +1 -1
- package/lib/commonjs/shared/utils/logger.js +22 -0
- package/lib/commonjs/shared/utils/logger.js.map +1 -0
- package/lib/module/blank-stack/components/adjusted-screen.js +1 -1
- package/lib/module/blank-stack/components/adjusted-screen.js.map +1 -1
- package/lib/module/shared/animation/snap-to.js +59 -0
- package/lib/module/shared/animation/snap-to.js.map +1 -0
- package/lib/module/shared/constants.js +34 -9
- package/lib/module/shared/constants.js.map +1 -1
- package/lib/module/shared/hooks/animation/use-screen-animation.js +25 -18
- package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js +0 -25
- package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-screen-gesture-handlers.js +69 -59
- package/lib/module/shared/hooks/gestures/use-screen-gesture-handlers.js.map +1 -1
- package/lib/module/shared/hooks/navigation/use-screen-state.js +4 -63
- package/lib/module/shared/hooks/navigation/use-screen-state.js.map +1 -1
- package/lib/module/shared/index.js +1 -0
- package/lib/module/shared/index.js.map +1 -1
- package/lib/module/shared/stores/animation.store.js +2 -1
- package/lib/module/shared/stores/animation.store.js.map +1 -1
- package/lib/module/shared/utils/animation/animate-to-progress.js +8 -2
- package/lib/module/shared/utils/animation/animate-to-progress.js.map +1 -1
- package/lib/module/shared/utils/gesture/check-gesture-activation.js +90 -23
- package/lib/module/shared/utils/gesture/check-gesture-activation.js.map +1 -1
- package/lib/module/shared/utils/logger.js +17 -0
- package/lib/module/shared/utils/logger.js.map +1 -0
- package/lib/typescript/blank-stack/components/adjusted-screen.d.ts.map +1 -1
- package/lib/typescript/shared/animation/snap-to.d.ts +18 -0
- package/lib/typescript/shared/animation/snap-to.d.ts.map +1 -0
- package/lib/typescript/shared/constants.d.ts +9 -0
- package/lib/typescript/shared/constants.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-screen-gesture-handlers.d.ts +1 -16
- package/lib/typescript/shared/hooks/gestures/use-screen-gesture-handlers.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts +0 -14
- package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts.map +1 -1
- package/lib/typescript/shared/index.d.ts +1 -0
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/stores/animation.store.d.ts +1 -0
- package/lib/typescript/shared/stores/animation.store.d.ts.map +1 -1
- package/lib/typescript/shared/types/animation.types.d.ts +9 -0
- package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
- package/lib/typescript/shared/utils/animation/animate-to-progress.d.ts.map +1 -1
- package/lib/typescript/shared/utils/gesture/check-gesture-activation.d.ts +4 -5
- package/lib/typescript/shared/utils/gesture/check-gesture-activation.d.ts.map +1 -1
- package/lib/typescript/shared/utils/logger.d.ts +6 -0
- package/lib/typescript/shared/utils/logger.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/blank-stack/components/adjusted-screen.tsx +1 -1
- package/src/shared/__tests__/derivations.test.ts +1 -0
- package/src/shared/__tests__/gesture-activation.test.ts +29 -56
- package/src/shared/animation/snap-to.ts +62 -0
- package/src/shared/constants.ts +36 -9
- package/src/shared/hooks/animation/use-screen-animation.tsx +32 -21
- package/src/shared/hooks/gestures/use-build-gestures.tsx +2 -34
- package/src/shared/hooks/gestures/use-screen-gesture-handlers.ts +94 -92
- package/src/shared/hooks/navigation/use-screen-state.tsx +2 -106
- package/src/shared/index.ts +1 -0
- package/src/shared/stores/animation.store.ts +2 -0
- package/src/shared/types/animation.types.ts +10 -0
- package/src/shared/utils/animation/animate-to-progress.ts +7 -2
- package/src/shared/utils/gesture/check-gesture-activation.ts +74 -23
- package/src/shared/utils/logger.ts +15 -0
|
@@ -240,10 +240,7 @@ exports.applyOffsetRules = applyOffsetRules;
|
|
|
240
240
|
function checkScrollAwareActivation({
|
|
241
241
|
swipeInfo,
|
|
242
242
|
directions,
|
|
243
|
-
|
|
244
|
-
scrollY,
|
|
245
|
-
maxScrollX,
|
|
246
|
-
maxScrollY,
|
|
243
|
+
scrollConfig,
|
|
247
244
|
hasSnapPoints,
|
|
248
245
|
canExpandMore
|
|
249
246
|
}) {
|
|
@@ -255,6 +252,95 @@ function checkScrollAwareActivation({
|
|
|
255
252
|
isSwipingRight,
|
|
256
253
|
isSwipingLeft
|
|
257
254
|
} = swipeInfo;
|
|
255
|
+
|
|
256
|
+
// Extract scroll values from config
|
|
257
|
+
const scrollX = scrollConfig?.x ?? 0;
|
|
258
|
+
const scrollY = scrollConfig?.y ?? 0;
|
|
259
|
+
const maxScrollX = scrollConfig ? scrollConfig.contentWidth - scrollConfig.layoutWidth : 0;
|
|
260
|
+
const maxScrollY = scrollConfig ? scrollConfig.contentHeight - scrollConfig.layoutHeight : 0;
|
|
261
|
+
const snapAxisInverted = directions.snapAxisInverted;
|
|
262
|
+
|
|
263
|
+
// With snap points, gestures should only activate based on the PRIMARY scroll edge
|
|
264
|
+
// (the edge where the sheet originates from), not the opposite edge.
|
|
265
|
+
// This prevents the auto-enabled opposite direction from hijacking scrolls.
|
|
266
|
+
if (hasSnapPoints) {
|
|
267
|
+
const isVerticalAxis = directions.vertical || directions.verticalInverted;
|
|
268
|
+
const isHorizontalAxis = directions.horizontal || directions.horizontalInverted;
|
|
269
|
+
if (isVerticalAxis) {
|
|
270
|
+
if (snapAxisInverted) {
|
|
271
|
+
// Sheet from TOP (vertical-inverted): only activate at scroll BOTTOM
|
|
272
|
+
if (scrollY >= maxScrollY) {
|
|
273
|
+
if (isSwipingUp) {
|
|
274
|
+
return {
|
|
275
|
+
shouldActivate: true,
|
|
276
|
+
direction: "vertical-inverted"
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
if (isSwipingDown && canExpandMore) {
|
|
280
|
+
return {
|
|
281
|
+
shouldActivate: true,
|
|
282
|
+
direction: "vertical"
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
// Sheet from BOTTOM (vertical): only activate at scroll TOP
|
|
288
|
+
if (scrollY <= 0) {
|
|
289
|
+
if (isSwipingDown) {
|
|
290
|
+
return {
|
|
291
|
+
shouldActivate: true,
|
|
292
|
+
direction: "vertical"
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
if (isSwipingUp && canExpandMore) {
|
|
296
|
+
return {
|
|
297
|
+
shouldActivate: true,
|
|
298
|
+
direction: "vertical-inverted"
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (isHorizontalAxis) {
|
|
305
|
+
if (snapAxisInverted) {
|
|
306
|
+
// Sheet from LEFT (horizontal-inverted): only activate at scroll RIGHT
|
|
307
|
+
if (scrollX >= maxScrollX) {
|
|
308
|
+
if (isSwipingLeft) {
|
|
309
|
+
return {
|
|
310
|
+
shouldActivate: true,
|
|
311
|
+
direction: "horizontal-inverted"
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
if (isSwipingRight && canExpandMore) {
|
|
315
|
+
return {
|
|
316
|
+
shouldActivate: true,
|
|
317
|
+
direction: "horizontal"
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
// Sheet from RIGHT (horizontal): only activate at scroll LEFT
|
|
323
|
+
if (scrollX <= 0) {
|
|
324
|
+
if (isSwipingRight) {
|
|
325
|
+
return {
|
|
326
|
+
shouldActivate: true,
|
|
327
|
+
direction: "horizontal"
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
if (isSwipingLeft && canExpandMore) {
|
|
331
|
+
return {
|
|
332
|
+
shouldActivate: true,
|
|
333
|
+
direction: "horizontal-inverted"
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
shouldActivate: false,
|
|
341
|
+
direction: null
|
|
342
|
+
};
|
|
343
|
+
}
|
|
258
344
|
if (directions.vertical && isSwipingDown && scrollY <= 0) {
|
|
259
345
|
return {
|
|
260
346
|
shouldActivate: true,
|
|
@@ -279,25 +365,6 @@ function checkScrollAwareActivation({
|
|
|
279
365
|
direction: "horizontal-inverted"
|
|
280
366
|
};
|
|
281
367
|
}
|
|
282
|
-
if (hasSnapPoints && canExpandMore) {
|
|
283
|
-
// Vertical sheet: swipe up at scroll top → expand
|
|
284
|
-
const enabledYAxis = directions.vertical || directions.verticalInverted;
|
|
285
|
-
const enabledXAxis = directions.horizontal || directions.horizontalInverted;
|
|
286
|
-
if (enabledYAxis && isSwipingUp && scrollY <= 0) {
|
|
287
|
-
return {
|
|
288
|
-
shouldActivate: true,
|
|
289
|
-
direction: "vertical-inverted"
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Horizontal sheet: swipe left at scroll left → expand
|
|
294
|
-
if (enabledXAxis && isSwipingLeft && scrollX <= 0) {
|
|
295
|
-
return {
|
|
296
|
-
shouldActivate: true,
|
|
297
|
-
direction: "horizontal-inverted"
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
368
|
return {
|
|
302
369
|
shouldActivate: false,
|
|
303
370
|
direction: null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_gesture","require","GESTURE_ACTIVATION_THRESHOLD_X","GESTURE_ACTIVATION_THRESHOLD_Y","GESTURE_FAIL_TOLERANCE_X","GESTURE_FAIL_TOLERANCE_Y","DEFAULT_EDGE_DISTANCE_HORIZONTAL","DEFAULT_EDGE_DISTANCE_VERTICAL","DEFAULT_ACTIVATION_AREA","normalizeSides","area","mode","left","right","top","bottom","s","computeEdgeConstraints","initialTouch","dimensions","sides","responseDistance","xDist","yDist","horizontalRight","x","horizontalLeft","width","verticalDown","y","verticalUp","height","calculateSwipeDirs","deltaX","deltaY","isVerticalSwipe","Math","abs","isHorizontalSwipe","isSwipingDown","isSwipingUp","isSwipingRight","isSwipingLeft","shouldActivateOrFail","params","hasHorizontal","hasVertical","allowedRight","allowedLeft","allowedUp","allowedDown","horizontalGateRight","horizontalGateLeft","verticalGateUp","verticalGateDown","shouldActivate","shouldFail","hasEnoughHorizontalMovement","hasAcceptableVerticalDeviation","rightOk","leftOk","hasEnoughVerticalMovement","hasAcceptableHorizontalDeviation","upOk","downOk","applyOffsetRules","touch","directions","manager","gestureOffsetState","activationArea","vertical","verticalInverted","horizontal","horizontalInverted","value","GestureOffsetState","PENDING","PASSED","FAILED","fail","exports","checkScrollAwareActivation","swipeInfo","scrollX","scrollY","maxScrollX","maxScrollY","
|
|
1
|
+
{"version":3,"names":["_gesture","require","GESTURE_ACTIVATION_THRESHOLD_X","GESTURE_ACTIVATION_THRESHOLD_Y","GESTURE_FAIL_TOLERANCE_X","GESTURE_FAIL_TOLERANCE_Y","DEFAULT_EDGE_DISTANCE_HORIZONTAL","DEFAULT_EDGE_DISTANCE_VERTICAL","DEFAULT_ACTIVATION_AREA","normalizeSides","area","mode","left","right","top","bottom","s","computeEdgeConstraints","initialTouch","dimensions","sides","responseDistance","xDist","yDist","horizontalRight","x","horizontalLeft","width","verticalDown","y","verticalUp","height","calculateSwipeDirs","deltaX","deltaY","isVerticalSwipe","Math","abs","isHorizontalSwipe","isSwipingDown","isSwipingUp","isSwipingRight","isSwipingLeft","shouldActivateOrFail","params","hasHorizontal","hasVertical","allowedRight","allowedLeft","allowedUp","allowedDown","horizontalGateRight","horizontalGateLeft","verticalGateUp","verticalGateDown","shouldActivate","shouldFail","hasEnoughHorizontalMovement","hasAcceptableVerticalDeviation","rightOk","leftOk","hasEnoughVerticalMovement","hasAcceptableHorizontalDeviation","upOk","downOk","applyOffsetRules","touch","directions","manager","gestureOffsetState","activationArea","vertical","verticalInverted","horizontal","horizontalInverted","value","GestureOffsetState","PENDING","PASSED","FAILED","fail","exports","checkScrollAwareActivation","swipeInfo","scrollConfig","hasSnapPoints","canExpandMore","scrollX","scrollY","maxScrollX","contentWidth","layoutWidth","maxScrollY","contentHeight","layoutHeight","snapAxisInverted","isVerticalAxis","isHorizontalAxis","direction"],"sourceRoot":"../../../../../src","sources":["shared/utils/gesture/check-gesture-activation.ts"],"mappings":";;;;;;;;;;;AAG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;MAAErC,cAAc,EAAE,IAAI;MAAE2C,SAAS,EAAE;IAAoB,CAAC;EAChE;EAEA,IAAI/B,UAAU,CAACO,kBAAkB,IAAIhC,aAAa,IAAI6C,OAAO,IAAIE,UAAU,EAAE;IAC5E,OAAO;MAAElC,cAAc,EAAE,IAAI;MAAE2C,SAAS,EAAE;IAAsB,CAAC;EAClE;EAEA,OAAO;IAAE3C,cAAc,EAAE,KAAK;IAAE2C,SAAS,EAAE;EAAK,CAAC;AAClD","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.logger = exports.error = void 0;
|
|
7
|
+
const LIBRARY_NAME = "react-native-screen-transitions";
|
|
8
|
+
const logger = exports.logger = {
|
|
9
|
+
error(message) {
|
|
10
|
+
"worklet";
|
|
11
|
+
|
|
12
|
+
console.error(`[${LIBRARY_NAME}] ${message}`);
|
|
13
|
+
},
|
|
14
|
+
warn(message) {
|
|
15
|
+
"worklet";
|
|
16
|
+
|
|
17
|
+
console.warn(`[${LIBRARY_NAME}] ${message}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const error = message => new Error(`[${LIBRARY_NAME}] ${message}`);
|
|
21
|
+
exports.error = error;
|
|
22
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LIBRARY_NAME","logger","exports","error","message","console","warn","Error"],"sourceRoot":"../../../../src","sources":["shared/utils/logger.ts"],"mappings":";;;;;;AAAA,MAAMA,YAAY,GAAG,iCAAiC;AAE/C,MAAMC,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG;EACrBE,KAAKA,CAACC,OAAe,EAAE;IACtB,SAAS;;IACTC,OAAO,CAACF,KAAK,CAAC,IAAIH,YAAY,KAAKI,OAAO,EAAE,CAAC;EAC9C,CAAC;EACDE,IAAIA,CAACF,OAAe,EAAE;IACrB,SAAS;;IACTC,OAAO,CAACC,IAAI,CAAC,IAAIN,YAAY,KAAKI,OAAO,EAAE,CAAC;EAC7C;AACD,CAAC;AAEM,MAAMD,KAAK,GAAIC,OAAe,IACpC,IAAIG,KAAK,CAAC,IAAIP,YAAY,KAAKI,OAAO,EAAE,CAAC;AAACF,OAAA,CAAAC,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { StyleSheet } from "react-native";
|
|
4
4
|
import Animated, { Extrapolation, interpolate, useAnimatedProps, useAnimatedRef, useDerivedValue, useSharedValue } from "react-native-reanimated";
|
|
5
5
|
import { Screen as RNSScreen } from "react-native-screens";
|
|
6
|
+
import { EPSILON } from "../../shared/constants";
|
|
6
7
|
import { useStack } from "../../shared/hooks/navigation/use-stack";
|
|
7
8
|
import { LayoutAnchorProvider } from "../../shared/providers/layout-anchor.provider";
|
|
8
9
|
import { useManagedStackContext } from "../../shared/providers/stack/managed.provider";
|
|
@@ -14,7 +15,6 @@ var ScreenActivity = /*#__PURE__*/function (ScreenActivity) {
|
|
|
14
15
|
ScreenActivity[ScreenActivity["ON_TOP"] = 2] = "ON_TOP";
|
|
15
16
|
return ScreenActivity;
|
|
16
17
|
}(ScreenActivity || {});
|
|
17
|
-
const EPSILON = 1e-5;
|
|
18
18
|
const POINT_NONE = "none";
|
|
19
19
|
const POINT_BOX_NONE = "box-none";
|
|
20
20
|
const AnimatedNativeScreen = Animated.createAnimatedComponent(RNSScreen);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","Animated","Extrapolation","interpolate","useAnimatedProps","useAnimatedRef","useDerivedValue","useSharedValue","Screen","RNSScreen","useStack","LayoutAnchorProvider","useManagedStackContext","AnimationStore","jsx","_jsx","ScreenActivity","
|
|
1
|
+
{"version":3,"names":["StyleSheet","Animated","Extrapolation","interpolate","useAnimatedProps","useAnimatedRef","useDerivedValue","useSharedValue","Screen","RNSScreen","EPSILON","useStack","LayoutAnchorProvider","useManagedStackContext","AnimationStore","jsx","_jsx","ScreenActivity","POINT_NONE","POINT_BOX_NONE","AnimatedNativeScreen","createAnimatedComponent","AdjustedScreen","routeKey","index","isPreloaded","children","freezeOnBlur","shouldFreeze","flags","DISABLE_NATIVE_SCREENS","activeScreensLimit","routes","routesLength","length","screenRef","sceneProgress","getAnimation","sceneClosing","screenActivity","TRANSITIONING_OR_BELOW_TOP","set","INACTIVE","outputValue","ON_TOP","v","get","CLAMP","next","Math","trunc","animatedProps","activity","activityState","pointerEvents","AdjustedScreenComponent","View","enabled","ref","style","absoluteFill","anchorRef"],"sourceRoot":"../../../../src","sources":["blank-stack/components/adjusted-screen.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAmB,cAAc;AACpD,OAAOC,QAAQ,IACdC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,cAAc,EACdC,eAAe,EACfC,cAAc,QACR,yBAAyB;AAChC,SAASC,MAAM,IAAIC,SAAS,QAAQ,sBAAsB;AAC1D,SAASC,OAAO,QAAQ,wBAAwB;AAChD,SAASC,QAAQ,QAAQ,yCAAyC;AAClE,SAASC,oBAAoB,QAAQ,+CAA+C;AACpF,SAASC,sBAAsB,QAAQ,+CAA+C;AACtF,SAASC,cAAc,QAAQ,qCAAqC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,IAUhEC,cAAc,0BAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA,EAAdA,cAAc;AAMnB,MAAMC,UAAU,GAAG,MAAe;AAClC,MAAMC,cAAc,GAAG,UAAmB;AAE1C,MAAMC,oBAAoB,GAAGnB,QAAQ,CAACoB,uBAAuB,CAACZ,SAAS,CAAC;AAExE,OAAO,MAAMa,cAAc,GAAGA,CAAC;EAC9BC,QAAQ;EACRC,KAAK;EACLC,W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} from "../configs/specs";
|
|
5
|
+
import { AnimationStore } from "../stores/animation.store";
|
|
6
|
+
import { HistoryStore } from "../stores/history.store";
|
|
7
|
+
import { animateToProgress } from "../utils/animation/animate-to-progress";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Programmatically snap the currently focused screen to a specific snap point.
|
|
11
|
+
*
|
|
12
|
+
* @param index - The index of the snap point to snap to (0-based, sorted ascending)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { snapTo } from 'react-native-screen-transitions';
|
|
17
|
+
*
|
|
18
|
+
* // Snap to the first (smallest) snap point
|
|
19
|
+
* snapTo(0);
|
|
20
|
+
*
|
|
21
|
+
* // Snap to the last (largest) snap point
|
|
22
|
+
* snapTo(2); // if there are 3 snap points
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function snapTo(index) {
|
|
26
|
+
const recent = HistoryStore.getMostRecent();
|
|
27
|
+
if (!recent) {
|
|
28
|
+
console.warn("snapTo: No screen in history");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const {
|
|
32
|
+
descriptor
|
|
33
|
+
} = recent;
|
|
34
|
+
const snapPoints = descriptor.options?.snapPoints;
|
|
35
|
+
if (!snapPoints || snapPoints.length === 0) {
|
|
36
|
+
console.warn("snapTo: No snapPoints defined on current screen");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const sorted = [...snapPoints].sort((a, b) => a - b);
|
|
40
|
+
if (index < 0 || index >= sorted.length) {
|
|
41
|
+
console.warn(`snapTo: index ${index} out of bounds (0-${sorted.length - 1})`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const targetProgress = sorted[index];
|
|
45
|
+
const animations = AnimationStore.getAll(descriptor.route.key);
|
|
46
|
+
runOnUI(() => {
|
|
47
|
+
"worklet";
|
|
48
|
+
|
|
49
|
+
animateToProgress({
|
|
50
|
+
target: targetProgress,
|
|
51
|
+
animations,
|
|
52
|
+
spec: {
|
|
53
|
+
open: descriptor.options.transitionSpec?.expand ?? DefaultSnapSpec,
|
|
54
|
+
close: descriptor.options.transitionSpec?.collapse ?? DefaultSnapSpec
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
})();
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=snap-to.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["runOnUI","DefaultSnapSpec","AnimationStore","HistoryStore","animateToProgress","snapTo","index","recent","getMostRecent","console","warn","descriptor","snapPoints","options","length","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,SAASC,YAAY,QAAQ,yBAAyB;AACtD,SAASC,iBAAiB,QAAQ,wCAAwC;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CAACC,KAAa,EAAQ;EAC3C,MAAMC,MAAM,GAAGJ,YAAY,CAACK,aAAa,CAAC,CAAC;EAE3C,IAAI,CAACD,MAAM,EAAE;IACZE,OAAO,CAACC,IAAI,CAAC,8BAA8B,CAAC;IAC5C;EACD;EAEA,MAAM;IAAEC;EAAW,CAAC,GAAGJ,MAAM;EAC7B,MAAMK,UAAU,GAAGD,UAAU,CAACE,OAAO,EAAED,UAAU;EAEjD,IAAI,CAACA,UAAU,IAAIA,UAAU,CAACE,MAAM,KAAK,CAAC,EAAE;IAC3CL,OAAO,CAACC,IAAI,CAAC,iDAAiD,CAAC;IAC/D;EACD;EAEA,MAAMK,MAAM,GAAG,CAAC,GAAGH,UAAU,CAAC,CAACI,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,CAAC;EAEpD,IAAIZ,KAAK,GAAG,CAAC,IAAIA,KAAK,IAAIS,MAAM,CAACD,MAAM,EAAE;IACxCL,OAAO,CAACC,IAAI,CACX,iBAAiBJ,KAAK,qBAAqBS,MAAM,CAACD,MAAM,GAAG,CAAC,GAC7D,CAAC;IACD;EACD;EAEA,MAAMK,cAAc,GAAGJ,MAAM,CAACT,KAAK,CAAC;EACpC,MAAMc,UAAU,GAAGlB,cAAc,CAACmB,MAAM,CAACV,UAAU,CAACW,KAAK,CAACC,GAAG,CAAC;EAE9DvB,OAAO,CAAC,MAAM;IACb,SAAS;;IACTI,iBAAiB,CAAC;MACjBoB,MAAM,EAAEL,cAAc;MACtBC,UAAU;MACVK,IAAI,EAAE;QACLC,IAAI,EAAEf,UAAU,CAACE,OAAO,CAACc,cAAc,EAAEC,MAAM,IAAI3B,eAAe;QAClE4B,KAAK,EAAElB,UAAU,CAACE,OAAO,CAACc,cAAc,EAAEG,QAAQ,IAAI7B;MACvD;IACD,CAAC,CAAC;EACH,CAAC,CAAC,CAAC,CAAC;AACL","ignoreList":[]}
|
|
@@ -13,22 +13,42 @@ export const CONTAINER_STYLE_ID = "_ROOT_CONTAINER";
|
|
|
13
13
|
export const NO_STYLES = Object.freeze({});
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Default
|
|
16
|
+
* Default gesture values
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
const DEFAULT_GESTURE_VALUES = {
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0,
|
|
21
|
+
normalizedX: 0,
|
|
22
|
+
normalizedY: 0,
|
|
23
|
+
isDismissing: 0,
|
|
24
|
+
isDragging: 0,
|
|
25
|
+
direction: null
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new screen transition state object
|
|
30
|
+
*/
|
|
31
|
+
export const createScreenTransitionState = (route, meta) => ({
|
|
19
32
|
progress: 0,
|
|
20
33
|
closing: 0,
|
|
21
34
|
animating: 0,
|
|
22
35
|
entering: 1,
|
|
23
36
|
gesture: {
|
|
24
|
-
|
|
25
|
-
y: 0,
|
|
26
|
-
normalizedX: 0,
|
|
27
|
-
normalizedY: 0,
|
|
28
|
-
isDismissing: 0,
|
|
29
|
-
isDragging: 0,
|
|
30
|
-
direction: null
|
|
37
|
+
...DEFAULT_GESTURE_VALUES
|
|
31
38
|
},
|
|
39
|
+
route,
|
|
40
|
+
meta
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Default screen transition state
|
|
45
|
+
*/
|
|
46
|
+
export const DEFAULT_SCREEN_TRANSITION_STATE = Object.freeze({
|
|
47
|
+
progress: 0,
|
|
48
|
+
closing: 0,
|
|
49
|
+
animating: 0,
|
|
50
|
+
entering: 1,
|
|
51
|
+
gesture: DEFAULT_GESTURE_VALUES,
|
|
32
52
|
route: {}
|
|
33
53
|
});
|
|
34
54
|
|
|
@@ -70,4 +90,9 @@ export const DEFAULT_GESTURE_ACTIVATION_AREA = "screen";
|
|
|
70
90
|
export const IS_WEB = Platform.OS === "web";
|
|
71
91
|
export const TRUE = 1;
|
|
72
92
|
export const FALSE = 0;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Small value for floating-point comparisons to handle animation/interpolation imprecision
|
|
96
|
+
*/
|
|
97
|
+
export const EPSILON = 1e-5;
|
|
73
98
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","MASK_STYLE_ID","CONTAINER_STYLE_ID","NO_STYLES","Object","freeze","
|
|
1
|
+
{"version":3,"names":["Platform","MASK_STYLE_ID","CONTAINER_STYLE_ID","NO_STYLES","Object","freeze","DEFAULT_GESTURE_VALUES","x","y","normalizedX","normalizedY","isDismissing","isDragging","direction","createScreenTransitionState","route","meta","progress","closing","animating","entering","gesture","DEFAULT_SCREEN_TRANSITION_STATE","EMPTY_BOUND_HELPER_RESULT","EMPTY_BOUND_HELPER_RESULT_RAW","scaleX","scaleY","scale","translateX","translateY","width","height","ENTER_RANGE","EXIT_RANGE","FULLSCREEN_DIMENSIONS","dimensions","pageX","pageY","GESTURE_VELOCITY_IMPACT","DEFAULT_GESTURE_DIRECTION","DEFAULT_GESTURE_DRIVES_PROGRESS","DEFAULT_GESTURE_ACTIVATION_AREA","IS_WEB","OS","TRUE","FALSE","EPSILON"],"sourceRoot":"../../../src","sources":["shared/constants.ts"],"mappings":";;AACA,SAASA,QAAQ,QAAQ,cAAc;AAOvC;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAG,cAAc;AAC3C,OAAO,MAAMC,kBAAkB,GAAG,iBAAiB;;AAEnD;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC;;AAE1C;AACA;AACA;AACA,MAAMC,sBAAsB,GAAG;EAC9BC,CAAC,EAAE,CAAC;EACJC,CAAC,EAAE,CAAC;EACJC,WAAW,EAAE,CAAC;EACdC,WAAW,EAAE,CAAC;EACdC,YAAY,EAAE,CAAC;EACfC,UAAU,EAAE,CAAC;EACbC,SAAS,EAAE;AACZ,CAAU;;AAEV;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAGA,CAC1CC,KAAqB,EACrBC,IAA8B,MACF;EAC5BC,QAAQ,EAAE,CAAC;EACXC,OAAO,EAAE,CAAC;EACVC,SAAS,EAAE,CAAC;EACZC,QAAQ,EAAE,CAAC;EACXC,OAAO,EAAE;IAAE,GAAGf;EAAuB,CAAC;EACtCS,KAAK;EACLC;AACD,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMM,+BAAsD,GAClElB,MAAM,CAACC,MAAM,CAAC;EACbY,QAAQ,EAAE,CAAC;EACXC,OAAO,EAAE,CAAC;EACVC,SAAS,EAAE,CAAC;EACZC,QAAQ,EAAE,CAAC;EACXC,OAAO,EAAEf,sBAAsB;EAC/BS,K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
|
import { useDerivedValue } from "react-native-reanimated";
|
|
6
6
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
7
|
-
import { DEFAULT_SCREEN_TRANSITION_STATE } from "../../constants";
|
|
7
|
+
import { createScreenTransitionState, DEFAULT_SCREEN_TRANSITION_STATE } from "../../constants";
|
|
8
8
|
import { useKeys } from "../../providers/screen/keys.provider";
|
|
9
9
|
import { AnimationStore } from "../../stores/animation.store";
|
|
10
10
|
import { GestureStore } from "../../stores/gesture.store";
|
|
11
11
|
import { derivations } from "../../utils/animation/derivations";
|
|
12
12
|
import { createBounds } from "../../utils/bounds";
|
|
13
13
|
import { useStack } from "../navigation/use-stack";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Computes the animated snap index based on progress and snap points.
|
|
16
|
+
* Returns -1 if no snap points, otherwise interpolates between indices.
|
|
17
|
+
*/
|
|
18
|
+
const computeSnapIndex = (progress, snapPoints) => {
|
|
19
|
+
"worklet";
|
|
20
|
+
|
|
21
|
+
if (snapPoints.length === 0) return -1;
|
|
22
|
+
if (progress <= snapPoints[0]) return 0;
|
|
23
|
+
if (progress >= snapPoints[snapPoints.length - 1]) return snapPoints.length - 1;
|
|
24
|
+
for (let i = 0; i < snapPoints.length - 1; i++) {
|
|
25
|
+
if (progress <= snapPoints[i + 1]) {
|
|
26
|
+
const t = (progress - snapPoints[i]) / (snapPoints[i + 1] - snapPoints[i]);
|
|
27
|
+
return i + t;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return snapPoints.length - 1;
|
|
31
|
+
};
|
|
31
32
|
const unwrapInto = s => {
|
|
32
33
|
"worklet";
|
|
33
34
|
|
|
@@ -89,6 +90,10 @@ export function _useScreenAnimation() {
|
|
|
89
90
|
const prevAnimation = useBuildScreenTransitionState(previousDescriptor);
|
|
90
91
|
const currentRouteKey = currentDescriptor?.route?.key;
|
|
91
92
|
const currentIndex = routeKeys.indexOf(currentRouteKey);
|
|
93
|
+
const sortedSnapPoints = useMemo(() => {
|
|
94
|
+
const points = currentDescriptor?.options?.snapPoints;
|
|
95
|
+
return points ? [...points].sort((a, b) => a - b) : [];
|
|
96
|
+
}, [currentDescriptor?.options?.snapPoints]);
|
|
92
97
|
const screenInterpolatorProps = useDerivedValue(() => {
|
|
93
98
|
"worklet";
|
|
94
99
|
|
|
@@ -108,6 +113,7 @@ export function _useScreenAnimation() {
|
|
|
108
113
|
// This gives us the sum of progress values from current screen onwards
|
|
109
114
|
// Falls back to current progress if index is invalid
|
|
110
115
|
const stackProgress = currentIndex >= 0 ? rootStackProgress.value - currentIndex : progress;
|
|
116
|
+
const snapIndex = computeSnapIndex(current.progress, sortedSnapPoints);
|
|
111
117
|
return {
|
|
112
118
|
layouts: {
|
|
113
119
|
screen: dimensions
|
|
@@ -118,6 +124,7 @@ export function _useScreenAnimation() {
|
|
|
118
124
|
next,
|
|
119
125
|
progress,
|
|
120
126
|
stackProgress,
|
|
127
|
+
snapIndex,
|
|
121
128
|
...helpers
|
|
122
129
|
};
|
|
123
130
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useWindowDimensions","useDerivedValue","useSafeAreaInsets","DEFAULT_SCREEN_TRANSITION_STATE","useKeys","AnimationStore","GestureStore","derivations","createBounds","useStack","
|
|
1
|
+
{"version":3,"names":["useMemo","useWindowDimensions","useDerivedValue","useSafeAreaInsets","createScreenTransitionState","DEFAULT_SCREEN_TRANSITION_STATE","useKeys","AnimationStore","GestureStore","derivations","createBounds","useStack","computeSnapIndex","progress","snapPoints","length","i","t","unwrapInto","s","out","unwrapped","value","closing","entering","animating","gesture","x","y","normalizedX","normalizedY","isDismissing","isDragging","direction","meta","useBuildScreenTransitionState","descriptor","key","route","options","undefined","getAnimation","getRouteGestures","hasTransitionsEnabled","alwaysOn","enableTransitions","_useScreenAnimation","windowDimensions","dimensions","insets","flags","stackProgress","rootStackProgress","routeKeys","transitionsAlwaysOn","TRANSITIONS_ALWAYS_ON","current","currentDescriptor","next","nextDescriptor","previous","previousDescriptor","currentAnimation","nextAnimation","prevAnimation","currentRouteKey","currentIndex","indexOf","sortedSnapPoints","points","sort","a","b","screenInterpolatorProps","helpers","snapIndex","layouts","screen","nextInterpolator","screenStyleInterpolator","currentInterpolator","useScreenAnimation","props","bounds"],"sourceRoot":"../../../../../src","sources":["shared/hooks/animation/use-screen-animation.tsx"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,mBAAmB,QAAQ,cAAc;AAClD,SAA2BC,eAAe,QAAQ,yBAAyB;AAC3E,SAASC,iBAAiB,QAAQ,gCAAgC;AAElE,SACCC,2BAA2B,EAC3BC,+BAA+B,QACzB,iBAAiB;AACxB,SAECC,OAAO,QACD,sCAAsC;AAC7C,SAASC,cAAc,QAAQ,8BAA8B;AAC7D,SAASC,YAAY,QAA8B,4BAA4B;AAO/E,SAASC,WAAW,QAAQ,mCAAmC;AAC/D,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,QAAQ,QAAQ,yBAAyB;AAalD;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAGA,CAACC,QAAgB,EAAEC,UAAoB,KAAa;EAC5E,SAAS;;EACT,IAAIA,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;EACtC,IAAIF,QAAQ,IAAIC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;EACvC,IAAID,QAAQ,IAAIC,UAAU,CAACA,UAAU,CAACC,MAAM,GAAG,CAAC,CAAC,EAChD,OAAOD,UAAU,CAACC,MAAM,GAAG,CAAC;EAE7B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GA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;AACH","ignoreList":[]}
|
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { StackActions } from "@react-navigation/native";
|
|
4
4
|
import { useCallback, useMemo, useRef } from "react";
|
|
5
|
-
import { useWindowDimensions } from "react-native";
|
|
6
5
|
import { Gesture } from "react-native-gesture-handler";
|
|
7
|
-
import { DEFAULT_GESTURE_ACTIVATION_AREA, DEFAULT_GESTURE_DIRECTION, DEFAULT_GESTURE_DRIVES_PROGRESS, GESTURE_VELOCITY_IMPACT } from "../../constants";
|
|
8
6
|
import { useKeys } from "../../providers/screen/keys.provider";
|
|
9
|
-
import { AnimationStore } from "../../stores/animation.store";
|
|
10
7
|
import { GestureStore } from "../../stores/gesture.store";
|
|
11
8
|
import { useScreenGestureHandlers } from "./use-screen-gesture-handlers";
|
|
12
9
|
export const useBuildGestures = ({
|
|
13
10
|
scrollConfig,
|
|
14
11
|
ancestorContext
|
|
15
12
|
}) => {
|
|
16
|
-
const dimensions = useWindowDimensions();
|
|
17
13
|
const {
|
|
18
14
|
current
|
|
19
15
|
} = useKeys();
|
|
@@ -25,14 +21,7 @@ export const useBuildGestures = ({
|
|
|
25
21
|
// Ref for external gesture coordination (e.g., swipeable lists)
|
|
26
22
|
const panGestureRef = useRef(undefined);
|
|
27
23
|
const gestureAnimationValues = GestureStore.getRouteGestures(current.route.key);
|
|
28
|
-
const animations = AnimationStore.getAll(current.route.key);
|
|
29
24
|
const {
|
|
30
|
-
gestureDirection = DEFAULT_GESTURE_DIRECTION,
|
|
31
|
-
gestureVelocityImpact = GESTURE_VELOCITY_IMPACT,
|
|
32
|
-
gestureDrivesProgress = DEFAULT_GESTURE_DRIVES_PROGRESS,
|
|
33
|
-
gestureActivationArea = DEFAULT_GESTURE_ACTIVATION_AREA,
|
|
34
|
-
gestureResponseDistance,
|
|
35
|
-
transitionSpec,
|
|
36
25
|
snapPoints
|
|
37
26
|
} = current.options;
|
|
38
27
|
|
|
@@ -68,25 +57,11 @@ export const useBuildGestures = ({
|
|
|
68
57
|
onUpdate,
|
|
69
58
|
onEnd
|
|
70
59
|
} = useScreenGestureHandlers({
|
|
71
|
-
dimensions,
|
|
72
|
-
animations,
|
|
73
|
-
gestureAnimationValues,
|
|
74
|
-
gestureDirection,
|
|
75
|
-
gestureDrivesProgress,
|
|
76
|
-
gestureVelocityImpact,
|
|
77
60
|
scrollConfig,
|
|
78
|
-
gestureActivationArea,
|
|
79
|
-
gestureResponseDistance,
|
|
80
|
-
snapPoints,
|
|
81
61
|
canDismiss,
|
|
82
|
-
transitionSpec,
|
|
83
62
|
handleDismiss,
|
|
84
63
|
ancestorIsDismissing: ancestorContext?.gestureAnimationValues.isDismissing
|
|
85
64
|
});
|
|
86
|
-
|
|
87
|
-
// Memoize gestures to keep stable references - critical for RNGH
|
|
88
|
-
// Child gestures reference ancestor's pan via requireExternalGestureToFail,
|
|
89
|
-
// so the pan gesture MUST be stable or children will reference stale objects
|
|
90
65
|
return useMemo(() => {
|
|
91
66
|
const panGesture = Gesture.Pan().withRef(panGestureRef).enabled(gestureEnabled).manualActivation(true).onTouchesDown(onTouchesDown).onTouchesMove(onTouchesMove).onStart(onStart).onUpdate(onUpdate).onEnd(onEnd);
|
|
92
67
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StackActions","useCallback","useMemo","useRef","
|
|
1
|
+
{"version":3,"names":["StackActions","useCallback","useMemo","useRef","Gesture","useKeys","GestureStore","useScreenGestureHandlers","useBuildGestures","scrollConfig","ancestorContext","current","navState","navigation","getState","isFirstScreen","routes","findIndex","r","key","route","panGestureRef","undefined","gestureAnimationValues","getRouteGestures","snapPoints","options","canDismiss","Boolean","gestureEnabled","hasSnapPoints","Array","isArray","length","handleDismiss","isDismissing","value","state","routeStillPresent","some","dispatch","pop","source","target","onTouchesDown","onTouchesMove","onStart","onUpdate","onEnd","ancestorIsDismissing","panGesture","Pan","withRef","enabled","manualActivation","nativeGesture","Native","requireExternalGestureToFail","blocksExternalGesture","activePanAncest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