react-native-screen-transitions 3.2.1 → 3.3.0-beta.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.
Files changed (146) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/shared/components/create-transition-aware-component.js +8 -2
  3. package/lib/commonjs/shared/components/create-transition-aware-component.js.map +1 -1
  4. package/lib/commonjs/shared/components/{root-transition-aware.js → screen-container.js} +28 -12
  5. package/lib/commonjs/shared/components/screen-container.js.map +1 -0
  6. package/lib/commonjs/shared/configs/presets.js +3 -3
  7. package/lib/commonjs/shared/configs/presets.js.map +1 -1
  8. package/lib/commonjs/shared/configs/specs.js +6 -1
  9. package/lib/commonjs/shared/configs/specs.js.map +1 -1
  10. package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js +36 -188
  11. package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
  12. package/lib/commonjs/shared/hooks/gestures/use-screen-gesture-handlers.js +334 -0
  13. package/lib/commonjs/shared/hooks/gestures/use-screen-gesture-handlers.js.map +1 -0
  14. package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js +47 -4
  15. package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
  16. package/lib/commonjs/shared/hooks/lifecycle/use-close-transition.js +3 -3
  17. package/lib/commonjs/shared/hooks/lifecycle/use-close-transition.js.map +1 -1
  18. package/lib/commonjs/shared/hooks/lifecycle/use-open-transition.js +25 -3
  19. package/lib/commonjs/shared/hooks/lifecycle/use-open-transition.js.map +1 -1
  20. package/lib/commonjs/shared/hooks/navigation/use-screen-state.js +61 -2
  21. package/lib/commonjs/shared/hooks/navigation/use-screen-state.js.map +1 -1
  22. package/lib/commonjs/shared/hooks/use-backdrop-pointer-events.js +32 -0
  23. package/lib/commonjs/shared/hooks/use-backdrop-pointer-events.js.map +1 -0
  24. package/lib/commonjs/shared/providers/gestures.provider.js +4 -2
  25. package/lib/commonjs/shared/providers/gestures.provider.js.map +1 -1
  26. package/lib/commonjs/shared/providers/screen/screen-composer.js +2 -2
  27. package/lib/commonjs/shared/providers/screen/screen-composer.js.map +1 -1
  28. package/lib/commonjs/shared/utils/animation/{start-screen-transition.js → animate-to-progress.js} +11 -7
  29. package/lib/commonjs/shared/utils/animation/animate-to-progress.js.map +1 -0
  30. package/lib/commonjs/shared/utils/gesture/check-gesture-activation.js +71 -0
  31. package/lib/commonjs/shared/utils/gesture/check-gesture-activation.js.map +1 -1
  32. package/lib/commonjs/shared/utils/gesture/determine-snap-target.js +56 -0
  33. package/lib/commonjs/shared/utils/gesture/determine-snap-target.js.map +1 -0
  34. package/lib/commonjs/shared/utils/gesture/validate-snap-points.js +31 -0
  35. package/lib/commonjs/shared/utils/gesture/validate-snap-points.js.map +1 -0
  36. package/lib/commonjs/shared/utils/gesture/velocity.js +11 -0
  37. package/lib/commonjs/shared/utils/gesture/velocity.js.map +1 -1
  38. package/lib/module/shared/components/create-transition-aware-component.js +8 -2
  39. package/lib/module/shared/components/create-transition-aware-component.js.map +1 -1
  40. package/lib/module/shared/components/screen-container.js +64 -0
  41. package/lib/module/shared/components/screen-container.js.map +1 -0
  42. package/lib/module/shared/configs/presets.js +3 -3
  43. package/lib/module/shared/configs/presets.js.map +1 -1
  44. package/lib/module/shared/configs/specs.js +5 -0
  45. package/lib/module/shared/configs/specs.js.map +1 -1
  46. package/lib/module/shared/hooks/gestures/use-build-gestures.js +36 -187
  47. package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
  48. package/lib/module/shared/hooks/gestures/use-screen-gesture-handlers.js +328 -0
  49. package/lib/module/shared/hooks/gestures/use-screen-gesture-handlers.js.map +1 -0
  50. package/lib/module/shared/hooks/gestures/use-scroll-registry.js +47 -4
  51. package/lib/module/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
  52. package/lib/module/shared/hooks/lifecycle/use-close-transition.js +3 -3
  53. package/lib/module/shared/hooks/lifecycle/use-close-transition.js.map +1 -1
  54. package/lib/module/shared/hooks/lifecycle/use-open-transition.js +25 -3
  55. package/lib/module/shared/hooks/lifecycle/use-open-transition.js.map +1 -1
  56. package/lib/module/shared/hooks/navigation/use-screen-state.js +63 -4
  57. package/lib/module/shared/hooks/navigation/use-screen-state.js.map +1 -1
  58. package/lib/module/shared/hooks/use-backdrop-pointer-events.js +28 -0
  59. package/lib/module/shared/hooks/use-backdrop-pointer-events.js.map +1 -0
  60. package/lib/module/shared/providers/gestures.provider.js +4 -2
  61. package/lib/module/shared/providers/gestures.provider.js.map +1 -1
  62. package/lib/module/shared/providers/screen/screen-composer.js +2 -2
  63. package/lib/module/shared/providers/screen/screen-composer.js.map +1 -1
  64. package/lib/module/shared/utils/animation/{start-screen-transition.js → animate-to-progress.js} +9 -5
  65. package/lib/module/shared/utils/animation/animate-to-progress.js.map +1 -0
  66. package/lib/module/shared/utils/gesture/check-gesture-activation.js +70 -0
  67. package/lib/module/shared/utils/gesture/check-gesture-activation.js.map +1 -1
  68. package/lib/module/shared/utils/gesture/determine-snap-target.js +52 -0
  69. package/lib/module/shared/utils/gesture/determine-snap-target.js.map +1 -0
  70. package/lib/module/shared/utils/gesture/validate-snap-points.js +26 -0
  71. package/lib/module/shared/utils/gesture/validate-snap-points.js.map +1 -0
  72. package/lib/module/shared/utils/gesture/velocity.js +11 -0
  73. package/lib/module/shared/utils/gesture/velocity.js.map +1 -1
  74. package/lib/typescript/shared/components/create-transition-aware-component.d.ts.map +1 -1
  75. package/lib/typescript/shared/components/screen-container.d.ts +6 -0
  76. package/lib/typescript/shared/components/screen-container.d.ts.map +1 -0
  77. package/lib/typescript/shared/configs/specs.d.ts +1 -0
  78. package/lib/typescript/shared/configs/specs.d.ts.map +1 -1
  79. package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts +1 -1
  80. package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
  81. package/lib/typescript/shared/hooks/gestures/use-screen-gesture-handlers.d.ts +34 -0
  82. package/lib/typescript/shared/hooks/gestures/use-screen-gesture-handlers.d.ts.map +1 -0
  83. package/lib/typescript/shared/hooks/gestures/use-scroll-registry.d.ts +5 -1
  84. package/lib/typescript/shared/hooks/gestures/use-scroll-registry.d.ts.map +1 -1
  85. package/lib/typescript/shared/hooks/lifecycle/use-open-transition.d.ts.map +1 -1
  86. package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts +14 -0
  87. package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts.map +1 -1
  88. package/lib/typescript/shared/hooks/use-backdrop-pointer-events.d.ts +15 -0
  89. package/lib/typescript/shared/hooks/use-backdrop-pointer-events.d.ts.map +1 -0
  90. package/lib/typescript/shared/providers/gestures.provider.d.ts +1 -0
  91. package/lib/typescript/shared/providers/gestures.provider.d.ts.map +1 -1
  92. package/lib/typescript/shared/types/animation.types.d.ts +28 -2
  93. package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
  94. package/lib/typescript/shared/types/screen.types.d.ts +26 -0
  95. package/lib/typescript/shared/types/screen.types.d.ts.map +1 -1
  96. package/lib/typescript/shared/utils/animation/animate-to-progress.d.ts +19 -0
  97. package/lib/typescript/shared/utils/animation/animate-to-progress.d.ts.map +1 -0
  98. package/lib/typescript/shared/utils/gesture/check-gesture-activation.d.ts +24 -0
  99. package/lib/typescript/shared/utils/gesture/check-gesture-activation.d.ts.map +1 -1
  100. package/lib/typescript/shared/utils/gesture/determine-snap-target.d.ts +26 -0
  101. package/lib/typescript/shared/utils/gesture/determine-snap-target.d.ts.map +1 -0
  102. package/lib/typescript/shared/utils/gesture/validate-snap-points.d.ts +13 -0
  103. package/lib/typescript/shared/utils/gesture/validate-snap-points.d.ts.map +1 -0
  104. package/lib/typescript/shared/utils/gesture/velocity.d.ts +1 -0
  105. package/lib/typescript/shared/utils/gesture/velocity.d.ts.map +1 -1
  106. package/package.json +3 -2
  107. package/src/shared/__tests__/determine-snap-target.test.ts +268 -0
  108. package/src/shared/__tests__/gesture-activation.test.ts +247 -0
  109. package/src/shared/__tests__/validate-snap-points.test.ts +125 -0
  110. package/src/shared/components/create-transition-aware-component.tsx +11 -1
  111. package/src/shared/components/screen-container.tsx +65 -0
  112. package/src/shared/configs/presets.ts +3 -3
  113. package/src/shared/configs/specs.ts +6 -0
  114. package/src/shared/hooks/gestures/use-build-gestures.tsx +33 -253
  115. package/src/shared/hooks/gestures/use-screen-gesture-handlers.ts +436 -0
  116. package/src/shared/hooks/gestures/use-scroll-registry.tsx +52 -1
  117. package/src/shared/hooks/lifecycle/use-close-transition.ts +3 -3
  118. package/src/shared/hooks/lifecycle/use-open-transition.ts +27 -3
  119. package/src/shared/hooks/navigation/use-screen-state.tsx +106 -2
  120. package/src/shared/hooks/use-backdrop-pointer-events.ts +32 -0
  121. package/src/shared/providers/gestures.provider.tsx +3 -2
  122. package/src/shared/providers/screen/screen-composer.tsx +2 -2
  123. package/src/shared/types/animation.types.ts +29 -2
  124. package/src/shared/types/screen.types.ts +29 -0
  125. package/src/shared/utils/animation/{start-screen-transition.ts → animate-to-progress.ts} +19 -7
  126. package/src/shared/utils/gesture/check-gesture-activation.ts +78 -0
  127. package/src/shared/utils/gesture/determine-snap-target.ts +75 -0
  128. package/src/shared/utils/gesture/validate-snap-points.ts +37 -0
  129. package/src/shared/utils/gesture/velocity.ts +10 -0
  130. package/lib/commonjs/shared/components/root-transition-aware.js.map +0 -1
  131. package/lib/commonjs/shared/hooks/use-stack-pointer-events.js +0 -23
  132. package/lib/commonjs/shared/hooks/use-stack-pointer-events.js.map +0 -1
  133. package/lib/commonjs/shared/utils/animation/start-screen-transition.js.map +0 -1
  134. package/lib/module/shared/components/root-transition-aware.js +0 -48
  135. package/lib/module/shared/components/root-transition-aware.js.map +0 -1
  136. package/lib/module/shared/hooks/use-stack-pointer-events.js +0 -20
  137. package/lib/module/shared/hooks/use-stack-pointer-events.js.map +0 -1
  138. package/lib/module/shared/utils/animation/start-screen-transition.js.map +0 -1
  139. package/lib/typescript/shared/components/root-transition-aware.d.ts +0 -6
  140. package/lib/typescript/shared/components/root-transition-aware.d.ts.map +0 -1
  141. package/lib/typescript/shared/hooks/use-stack-pointer-events.d.ts +0 -10
  142. package/lib/typescript/shared/hooks/use-stack-pointer-events.d.ts.map +0 -1
  143. package/lib/typescript/shared/utils/animation/start-screen-transition.d.ts +0 -13
  144. package/lib/typescript/shared/utils/animation/start-screen-transition.d.ts.map +0 -1
  145. package/src/shared/components/root-transition-aware.tsx +0 -49
  146. package/src/shared/hooks/use-stack-pointer-events.ts +0 -15
@@ -4,6 +4,7 @@ import {
4
4
  computeEdgeConstraints,
5
5
  calculateSwipeDirs,
6
6
  shouldActivateOrFail,
7
+ checkScrollAwareActivation,
7
8
  } from "../utils/gesture/check-gesture-activation";
8
9
 
9
10
  describe("normalizeSides", () => {
@@ -249,3 +250,249 @@ describe("shouldActivateOrFail", () => {
249
250
  expect(result.shouldActivate).toBe(true);
250
251
  });
251
252
  });
253
+
254
+ describe("checkScrollAwareActivation", () => {
255
+ const baseDirections = {
256
+ vertical: true,
257
+ verticalInverted: false,
258
+ horizontal: false,
259
+ horizontalInverted: false,
260
+ };
261
+
262
+ const noSwipe = {
263
+ isSwipingDown: false,
264
+ isSwipingUp: false,
265
+ isSwipingRight: false,
266
+ isSwipingLeft: false,
267
+ };
268
+
269
+ describe("vertical sheet (dismiss down)", () => {
270
+ it("activates when swiping down at scroll top", () => {
271
+ const result = checkScrollAwareActivation({
272
+ swipeInfo: { ...noSwipe, isSwipingDown: true },
273
+ directions: baseDirections,
274
+ scrollX: 0,
275
+ scrollY: 0,
276
+ maxScrollX: 0,
277
+ maxScrollY: 500,
278
+ });
279
+ expect(result.shouldActivate).toBe(true);
280
+ expect(result.direction).toBe("vertical");
281
+ });
282
+
283
+ it("does not activate when swiping down but scroll is not at top", () => {
284
+ const result = checkScrollAwareActivation({
285
+ swipeInfo: { ...noSwipe, isSwipingDown: true },
286
+ directions: baseDirections,
287
+ scrollX: 0,
288
+ scrollY: 100,
289
+ maxScrollX: 0,
290
+ maxScrollY: 500,
291
+ });
292
+ expect(result.shouldActivate).toBe(false);
293
+ });
294
+
295
+ it("does not activate when swiping up without snap points", () => {
296
+ const result = checkScrollAwareActivation({
297
+ swipeInfo: { ...noSwipe, isSwipingUp: true },
298
+ directions: baseDirections,
299
+ scrollX: 0,
300
+ scrollY: 0,
301
+ maxScrollX: 0,
302
+ maxScrollY: 500,
303
+ });
304
+ expect(result.shouldActivate).toBe(false);
305
+ });
306
+ });
307
+
308
+ describe("vertical inverted sheet (dismiss up)", () => {
309
+ const invertedDirections = {
310
+ vertical: false,
311
+ verticalInverted: true,
312
+ horizontal: false,
313
+ horizontalInverted: false,
314
+ };
315
+
316
+ it("activates when swiping up at scroll bottom", () => {
317
+ const result = checkScrollAwareActivation({
318
+ swipeInfo: { ...noSwipe, isSwipingUp: true },
319
+ directions: invertedDirections,
320
+ scrollX: 0,
321
+ scrollY: 500,
322
+ maxScrollX: 0,
323
+ maxScrollY: 500,
324
+ });
325
+ expect(result.shouldActivate).toBe(true);
326
+ expect(result.direction).toBe("vertical-inverted");
327
+ });
328
+
329
+ it("does not activate when swiping up but scroll is not at bottom", () => {
330
+ const result = checkScrollAwareActivation({
331
+ swipeInfo: { ...noSwipe, isSwipingUp: true },
332
+ directions: invertedDirections,
333
+ scrollX: 0,
334
+ scrollY: 200,
335
+ maxScrollX: 0,
336
+ maxScrollY: 500,
337
+ });
338
+ expect(result.shouldActivate).toBe(false);
339
+ });
340
+ });
341
+
342
+ describe("horizontal sheet (dismiss right)", () => {
343
+ const horizontalDirections = {
344
+ vertical: false,
345
+ verticalInverted: false,
346
+ horizontal: true,
347
+ horizontalInverted: false,
348
+ };
349
+
350
+ it("activates when swiping right at scroll left edge", () => {
351
+ const result = checkScrollAwareActivation({
352
+ swipeInfo: { ...noSwipe, isSwipingRight: true },
353
+ directions: horizontalDirections,
354
+ scrollX: 0,
355
+ scrollY: 0,
356
+ maxScrollX: 500,
357
+ maxScrollY: 0,
358
+ });
359
+ expect(result.shouldActivate).toBe(true);
360
+ expect(result.direction).toBe("horizontal");
361
+ });
362
+
363
+ it("does not activate when scroll is not at left edge", () => {
364
+ const result = checkScrollAwareActivation({
365
+ swipeInfo: { ...noSwipe, isSwipingRight: true },
366
+ directions: horizontalDirections,
367
+ scrollX: 100,
368
+ scrollY: 0,
369
+ maxScrollX: 500,
370
+ maxScrollY: 0,
371
+ });
372
+ expect(result.shouldActivate).toBe(false);
373
+ });
374
+ });
375
+
376
+ describe("horizontal inverted sheet (dismiss left)", () => {
377
+ const invertedHorizontalDirections = {
378
+ vertical: false,
379
+ verticalInverted: false,
380
+ horizontal: false,
381
+ horizontalInverted: true,
382
+ };
383
+
384
+ it("activates when swiping left at scroll right edge", () => {
385
+ const result = checkScrollAwareActivation({
386
+ swipeInfo: { ...noSwipe, isSwipingLeft: true },
387
+ directions: invertedHorizontalDirections,
388
+ scrollX: 500,
389
+ scrollY: 0,
390
+ maxScrollX: 500,
391
+ maxScrollY: 0,
392
+ });
393
+ expect(result.shouldActivate).toBe(true);
394
+ expect(result.direction).toBe("horizontal-inverted");
395
+ });
396
+ });
397
+
398
+ describe("snap points behavior", () => {
399
+ it("activates for swipe up (expand) at scroll top when hasSnapPoints and canExpandMore", () => {
400
+ const result = checkScrollAwareActivation({
401
+ swipeInfo: { ...noSwipe, isSwipingUp: true },
402
+ directions: baseDirections,
403
+ scrollX: 0,
404
+ scrollY: 0,
405
+ maxScrollX: 0,
406
+ maxScrollY: 500,
407
+ hasSnapPoints: true,
408
+ canExpandMore: true,
409
+ });
410
+ expect(result.shouldActivate).toBe(true);
411
+ expect(result.direction).toBe("vertical-inverted");
412
+ });
413
+
414
+ it("does not activate for swipe up when canExpandMore is false", () => {
415
+ const result = checkScrollAwareActivation({
416
+ swipeInfo: { ...noSwipe, isSwipingUp: true },
417
+ directions: baseDirections,
418
+ scrollX: 0,
419
+ scrollY: 0,
420
+ maxScrollX: 0,
421
+ maxScrollY: 500,
422
+ hasSnapPoints: true,
423
+ canExpandMore: false,
424
+ });
425
+ expect(result.shouldActivate).toBe(false);
426
+ });
427
+
428
+ it("does not activate for swipe up when scroll is not at top", () => {
429
+ const result = checkScrollAwareActivation({
430
+ swipeInfo: { ...noSwipe, isSwipingUp: true },
431
+ directions: baseDirections,
432
+ scrollX: 0,
433
+ scrollY: 100,
434
+ maxScrollX: 0,
435
+ maxScrollY: 500,
436
+ hasSnapPoints: true,
437
+ canExpandMore: true,
438
+ });
439
+ expect(result.shouldActivate).toBe(false);
440
+ });
441
+
442
+ it("activates for swipe left (expand) on horizontal sheet with snap points", () => {
443
+ const horizontalDirections = {
444
+ vertical: false,
445
+ verticalInverted: false,
446
+ horizontal: true,
447
+ horizontalInverted: false,
448
+ };
449
+
450
+ const result = checkScrollAwareActivation({
451
+ swipeInfo: { ...noSwipe, isSwipingLeft: true },
452
+ directions: horizontalDirections,
453
+ scrollX: 0,
454
+ scrollY: 0,
455
+ maxScrollX: 500,
456
+ maxScrollY: 0,
457
+ hasSnapPoints: true,
458
+ canExpandMore: true,
459
+ });
460
+ expect(result.shouldActivate).toBe(true);
461
+ expect(result.direction).toBe("horizontal-inverted");
462
+ });
463
+ });
464
+
465
+ describe("no activation cases", () => {
466
+ it("returns false when no swipe is detected", () => {
467
+ const result = checkScrollAwareActivation({
468
+ swipeInfo: noSwipe,
469
+ directions: baseDirections,
470
+ scrollX: 0,
471
+ scrollY: 0,
472
+ maxScrollX: 0,
473
+ maxScrollY: 500,
474
+ });
475
+ expect(result.shouldActivate).toBe(false);
476
+ expect(result.direction).toBe(null);
477
+ });
478
+
479
+ it("returns false when direction is disabled", () => {
480
+ const disabledDirections = {
481
+ vertical: false,
482
+ verticalInverted: false,
483
+ horizontal: false,
484
+ horizontalInverted: false,
485
+ };
486
+
487
+ const result = checkScrollAwareActivation({
488
+ swipeInfo: { ...noSwipe, isSwipingDown: true },
489
+ directions: disabledDirections,
490
+ scrollX: 0,
491
+ scrollY: 0,
492
+ maxScrollX: 0,
493
+ maxScrollY: 500,
494
+ });
495
+ expect(result.shouldActivate).toBe(false);
496
+ });
497
+ });
498
+ });
@@ -0,0 +1,125 @@
1
+ import { describe, expect, it } from "bun:test";
2
+ import { validateSnapPoints } from "../utils/gesture/validate-snap-points";
3
+
4
+ describe("validateSnapPoints", () => {
5
+ describe("when no snap points provided", () => {
6
+ it("returns hasSnapPoints false", () => {
7
+ const result = validateSnapPoints({});
8
+ expect(result.hasSnapPoints).toBe(false);
9
+ });
10
+
11
+ it("returns empty snapPoints array", () => {
12
+ const result = validateSnapPoints({});
13
+ expect(result.snapPoints).toEqual([]);
14
+ });
15
+
16
+ it("returns -1 for min and max", () => {
17
+ const result = validateSnapPoints({});
18
+ expect(result.minSnapPoint).toBe(-1);
19
+ expect(result.maxSnapPoint).toBe(-1);
20
+ });
21
+
22
+ it("handles undefined snapPoints", () => {
23
+ const result = validateSnapPoints({ snapPoints: undefined });
24
+ expect(result.hasSnapPoints).toBe(false);
25
+ });
26
+ });
27
+
28
+ describe("when snap points provided", () => {
29
+ it("returns hasSnapPoints true", () => {
30
+ const result = validateSnapPoints({ snapPoints: [0.3, 0.6, 1] });
31
+ expect(result.hasSnapPoints).toBe(true);
32
+ });
33
+
34
+ it("sorts snap points in ascending order", () => {
35
+ const result = validateSnapPoints({ snapPoints: [1, 0.3, 0.6] });
36
+ expect(result.snapPoints).toEqual([0.3, 0.6, 1]);
37
+ });
38
+
39
+ it("returns correct max snap point", () => {
40
+ const result = validateSnapPoints({ snapPoints: [0.3, 0.6, 1] });
41
+ expect(result.maxSnapPoint).toBe(1);
42
+ });
43
+
44
+ it("handles single snap point", () => {
45
+ const result = validateSnapPoints({ snapPoints: [0.5] });
46
+ expect(result.hasSnapPoints).toBe(true);
47
+ expect(result.snapPoints).toEqual([0.5]);
48
+ expect(result.minSnapPoint).toBe(0.5);
49
+ expect(result.maxSnapPoint).toBe(0.5);
50
+ });
51
+
52
+ it("does not mutate original array", () => {
53
+ const original = [1, 0.3, 0.6];
54
+ validateSnapPoints({ snapPoints: original });
55
+ expect(original).toEqual([1, 0.3, 0.6]);
56
+ });
57
+ });
58
+
59
+ describe("canDismiss behavior", () => {
60
+ it("sets minSnapPoint to 0 when canDismiss is true", () => {
61
+ const result = validateSnapPoints({
62
+ snapPoints: [0.3, 0.6, 1],
63
+ canDismiss: true,
64
+ });
65
+ expect(result.minSnapPoint).toBe(0);
66
+ });
67
+
68
+ it("sets minSnapPoint to first snap point when canDismiss is false", () => {
69
+ const result = validateSnapPoints({
70
+ snapPoints: [0.3, 0.6, 1],
71
+ canDismiss: false,
72
+ });
73
+ expect(result.minSnapPoint).toBe(0.3);
74
+ });
75
+
76
+ it("defaults canDismiss to falsy (minSnapPoint = first snap)", () => {
77
+ const result = validateSnapPoints({ snapPoints: [0.3, 0.6, 1] });
78
+ expect(result.minSnapPoint).toBe(0.3);
79
+ });
80
+
81
+ it("handles canDismiss with unsorted snap points", () => {
82
+ const result = validateSnapPoints({
83
+ snapPoints: [1, 0.5, 0.25],
84
+ canDismiss: false,
85
+ });
86
+ // After sorting: [0.25, 0.5, 1]
87
+ expect(result.minSnapPoint).toBe(0.25);
88
+ expect(result.maxSnapPoint).toBe(1);
89
+ });
90
+ });
91
+
92
+ describe("edge cases", () => {
93
+ it("handles empty array", () => {
94
+ const result = validateSnapPoints({ snapPoints: [] });
95
+ // Empty array is falsy for snap points
96
+ expect(result.hasSnapPoints).toBe(true); // Array exists but is empty
97
+ expect(result.snapPoints).toEqual([]);
98
+ });
99
+
100
+ it("handles snap points at 0", () => {
101
+ const result = validateSnapPoints({
102
+ snapPoints: [0, 0.5, 1],
103
+ canDismiss: true,
104
+ });
105
+ expect(result.minSnapPoint).toBe(0);
106
+ expect(result.snapPoints).toEqual([0, 0.5, 1]);
107
+ });
108
+
109
+ it("handles duplicate snap points", () => {
110
+ const result = validateSnapPoints({ snapPoints: [0.5, 0.5, 1] });
111
+ expect(result.snapPoints).toEqual([0.5, 0.5, 1]);
112
+ });
113
+
114
+ it("handles very small snap point values", () => {
115
+ const result = validateSnapPoints({ snapPoints: [0.01, 0.1, 0.5] });
116
+ expect(result.minSnapPoint).toBe(0.01);
117
+ expect(result.maxSnapPoint).toBe(0.5);
118
+ });
119
+
120
+ it("handles snap points greater than 1", () => {
121
+ const result = validateSnapPoints({ snapPoints: [0.5, 1, 1.5] });
122
+ expect(result.maxSnapPoint).toBe(1.5);
123
+ });
124
+ });
125
+ });
@@ -27,10 +27,18 @@ export function createTransitionAwareComponent<P extends object>(
27
27
  TransitionAwareProps<P>
28
28
  >((props: any, ref) => {
29
29
  const { nativeGesture } = useGestureContext()!;
30
- const { scrollHandler, onContentSizeChange, onLayout } = useScrollRegistry({
30
+ const {
31
+ scrollHandler,
32
+ onContentSizeChange,
33
+ onLayout,
34
+ onTouchStart,
35
+ onTouchEnd,
36
+ } = useScrollRegistry({
31
37
  onScroll: props.onScroll,
32
38
  onContentSizeChange: props.onContentSizeChange,
33
39
  onLayout: props.onLayout,
40
+ onTouchStart: props.onTouchStart,
41
+ onTouchEnd: props.onTouchEnd,
34
42
  });
35
43
 
36
44
  return (
@@ -41,6 +49,8 @@ export function createTransitionAwareComponent<P extends object>(
41
49
  onScroll={scrollHandler}
42
50
  onContentSizeChange={onContentSizeChange}
43
51
  onLayout={onLayout}
52
+ onTouchStart={onTouchStart}
53
+ onTouchEnd={onTouchEnd}
44
54
  scrollEventThrottle={props.scrollEventThrottle || 16}
45
55
  />
46
56
  </GestureDetector>
@@ -0,0 +1,65 @@
1
+ import { StackActions } from "@react-navigation/native";
2
+ import { memo, useCallback } from "react";
3
+ import { Pressable, StyleSheet, View } from "react-native";
4
+ import Animated, { useAnimatedStyle } from "react-native-reanimated";
5
+ import { NO_STYLES } from "../constants";
6
+ import { useBackdropPointerEvents } from "../hooks/use-backdrop-pointer-events";
7
+ import { useKeys } from "../providers/screen/keys.provider";
8
+ import { useScreenStyles } from "../providers/screen/styles.provider";
9
+
10
+ type Props = {
11
+ children: React.ReactNode;
12
+ };
13
+
14
+ export const ScreenContainer = memo(({ children }: Props) => {
15
+ const { stylesMap } = useScreenStyles();
16
+ const { current } = useKeys();
17
+ const { pointerEvents, backdropBehavior } = useBackdropPointerEvents();
18
+
19
+ const isDismissable = backdropBehavior === "dismiss";
20
+
21
+ const handleBackdropPress = useCallback(() => {
22
+ current.navigation.dispatch(StackActions.pop());
23
+ }, [current.navigation]);
24
+
25
+ const animatedContentStyle = useAnimatedStyle(() => {
26
+ "worklet";
27
+ return stylesMap.value.contentStyle || NO_STYLES;
28
+ });
29
+
30
+ const animatedBackdropStyle = useAnimatedStyle(() => {
31
+ "worklet";
32
+ return (
33
+ stylesMap.value.backdropStyle ?? stylesMap.value.overlayStyle ?? NO_STYLES
34
+ );
35
+ });
36
+
37
+ return (
38
+ <View style={styles.container} pointerEvents={pointerEvents}>
39
+ <Pressable
40
+ style={StyleSheet.absoluteFillObject}
41
+ pointerEvents={isDismissable ? "auto" : "none"}
42
+ onPress={isDismissable ? handleBackdropPress : undefined}
43
+ >
44
+ <Animated.View
45
+ style={[StyleSheet.absoluteFillObject, animatedBackdropStyle]}
46
+ />
47
+ </Pressable>
48
+ <Animated.View
49
+ style={[styles.content, animatedContentStyle]}
50
+ pointerEvents={isDismissable ? "box-none" : pointerEvents}
51
+ >
52
+ {children}
53
+ </Animated.View>
54
+ </View>
55
+ );
56
+ });
57
+
58
+ const styles = StyleSheet.create({
59
+ container: {
60
+ flex: 1,
61
+ },
62
+ content: {
63
+ flex: 1,
64
+ },
65
+ });
@@ -208,7 +208,7 @@ export const ElasticCard = (
208
208
  contentStyle: {
209
209
  transform: [{ scale }, { translateX }, { translateY }],
210
210
  },
211
- overlayStyle: {
211
+ backdropStyle: {
212
212
  backgroundColor: !next ? overlayColor : "rgba(0,0,0,0)",
213
213
  },
214
214
  };
@@ -281,7 +281,7 @@ export const SharedIGImage = ({
281
281
  });
282
282
 
283
283
  return {
284
- overlayStyle: {
284
+ backdropStyle: {
285
285
  backgroundColor: "black",
286
286
  opacity: interpolate(progress, [0, 1], [0, 0.5]),
287
287
  },
@@ -634,7 +634,7 @@ export const SharedXImage = ({
634
634
  transform: [{ translateY: contentY }, { translateY: dragY }],
635
635
  pointerEvents: current.animating ? "none" : "auto",
636
636
  },
637
- overlayStyle: {
637
+ backdropStyle: {
638
638
  backgroundColor: overlayClr,
639
639
  },
640
640
  };
@@ -8,3 +8,9 @@ export const DefaultSpec: WithSpringConfig = {
8
8
  // @ts-expect-error
9
9
  restSpeedThreshold: 0.02,
10
10
  };
11
+
12
+ export const DefaultSnapSpec: WithSpringConfig = {
13
+ stiffness: 500,
14
+ damping: 50,
15
+ mass: 1,
16
+ };