react-native-screen-transitions 4.0.0-alpha.8 → 4.0.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 (308) hide show
  1. package/README.md +6 -11
  2. package/lib/commonjs/components/boundary/create-boundary-component.js +5 -1
  3. package/lib/commonjs/components/boundary/create-boundary-component.js.map +1 -1
  4. package/lib/commonjs/components/boundary/portal/components/boundary-content-portal/helpers/active-handoff-receiver.js +53 -1
  5. package/lib/commonjs/components/boundary/portal/components/boundary-content-portal/helpers/active-handoff-receiver.js.map +1 -1
  6. package/lib/commonjs/components/boundary/portal/components/boundary-content-portal/hooks/use-boundary-content-portal-attachment.js +43 -8
  7. package/lib/commonjs/components/boundary/portal/components/boundary-content-portal/hooks/use-boundary-content-portal-attachment.js.map +1 -1
  8. package/lib/commonjs/components/boundary/portal/components/boundary-portal/hooks/use-boundary-portal-attachment.js +2 -3
  9. package/lib/commonjs/components/boundary/portal/components/boundary-portal/hooks/use-boundary-portal-attachment.js.map +1 -1
  10. package/lib/commonjs/components/boundary/portal/teleport.js +1 -13
  11. package/lib/commonjs/components/boundary/portal/teleport.js.map +1 -1
  12. package/lib/commonjs/components/boundary/utils/source-signals.js +6 -4
  13. package/lib/commonjs/components/boundary/utils/source-signals.js.map +1 -1
  14. package/lib/commonjs/components/overlay/helpers/get-active-overlay.js +3 -24
  15. package/lib/commonjs/components/overlay/helpers/get-active-overlay.js.map +1 -1
  16. package/lib/commonjs/components/overlay/helpers/retain-ready-overlay-resources.js +4 -3
  17. package/lib/commonjs/components/overlay/helpers/retain-ready-overlay-resources.js.map +1 -1
  18. package/lib/commonjs/components/overlay/hooks/use-overlay-slot.js +1 -2
  19. package/lib/commonjs/components/overlay/hooks/use-overlay-slot.js.map +1 -1
  20. package/lib/commonjs/components/overlay/variations/float-overlay.js +0 -2
  21. package/lib/commonjs/components/overlay/variations/float-overlay.js.map +1 -1
  22. package/lib/commonjs/components/overlay/variations/overlay-host.js +18 -15
  23. package/lib/commonjs/components/overlay/variations/overlay-host.js.map +1 -1
  24. package/lib/commonjs/components/screen-container/layers/content.js +10 -5
  25. package/lib/commonjs/components/screen-container/layers/content.js.map +1 -1
  26. package/lib/commonjs/components/screen-container/layers/surface.js +50 -0
  27. package/lib/commonjs/components/screen-container/layers/surface.js.map +1 -0
  28. package/lib/commonjs/components/stack-view.js +7 -29
  29. package/lib/commonjs/components/stack-view.js.map +1 -1
  30. package/lib/commonjs/configs/index.js +1 -4
  31. package/lib/commonjs/configs/index.js.map +1 -1
  32. package/lib/commonjs/configs/presets.js +1 -384
  33. package/lib/commonjs/configs/presets.js.map +1 -1
  34. package/lib/commonjs/constants.js +2 -1
  35. package/lib/commonjs/constants.js.map +1 -1
  36. package/lib/commonjs/navigators/create-blank-stack-navigator.js +7 -67
  37. package/lib/commonjs/navigators/create-blank-stack-navigator.js.map +1 -1
  38. package/lib/commonjs/navigators/expo-router/index.js +1 -18
  39. package/lib/commonjs/navigators/expo-router/index.js.map +1 -1
  40. package/lib/commonjs/navigators/react-navigation/index.js +1 -3
  41. package/lib/commonjs/navigators/react-navigation/index.js.map +1 -1
  42. package/lib/commonjs/providers/screen/animation/animation.provider.js +6 -1
  43. package/lib/commonjs/providers/screen/animation/animation.provider.js.map +1 -1
  44. package/lib/commonjs/providers/screen/animation/helpers/build-screen-transition-options.js +1 -0
  45. package/lib/commonjs/providers/screen/animation/helpers/build-screen-transition-options.js.map +1 -1
  46. package/lib/commonjs/providers/screen/animation/helpers/hydrate-transition-state/gesture-progress.js +20 -5
  47. package/lib/commonjs/providers/screen/animation/helpers/hydrate-transition-state/gesture-progress.js.map +1 -1
  48. package/lib/commonjs/providers/screen/animation/helpers/hydrate-transition-state/index.js +16 -1
  49. package/lib/commonjs/providers/screen/animation/helpers/hydrate-transition-state/index.js.map +1 -1
  50. package/lib/commonjs/providers/screen/animation/helpers/selected-interpolator-options.js +1 -1
  51. package/lib/commonjs/providers/screen/animation/helpers/selected-interpolator-options.js.map +1 -1
  52. package/lib/commonjs/providers/screen/animation/use-screen-animation.js +1 -8
  53. package/lib/commonjs/providers/screen/animation/use-screen-animation.js.map +1 -1
  54. package/lib/commonjs/providers/screen/gestures/pan/behavior/pan-release.js +28 -6
  55. package/lib/commonjs/providers/screen/gestures/pan/behavior/pan-release.js.map +1 -1
  56. package/lib/commonjs/providers/screen/gestures/pinch/behavior/pinch-release.js +26 -6
  57. package/lib/commonjs/providers/screen/gestures/pinch/behavior/pinch-release.js.map +1 -1
  58. package/lib/commonjs/providers/screen/gestures/shared/policy.js +1 -0
  59. package/lib/commonjs/providers/screen/gestures/shared/policy.js.map +1 -1
  60. package/lib/commonjs/providers/screen/gestures/shared/snap-points.js +71 -1
  61. package/lib/commonjs/providers/screen/gestures/shared/snap-points.js.map +1 -1
  62. package/lib/commonjs/providers/screen/options/helpers.js +8 -1
  63. package/lib/commonjs/providers/screen/options/helpers.js.map +1 -1
  64. package/lib/commonjs/providers/screen/styles/constants.js +4 -1
  65. package/lib/commonjs/providers/screen/styles/constants.js.map +1 -1
  66. package/lib/commonjs/providers/screen/styles/hooks/slot-resolvers.js +1 -9
  67. package/lib/commonjs/providers/screen/styles/hooks/slot-resolvers.js.map +1 -1
  68. package/lib/commonjs/providers/screen/styles/slot.provider.js +3 -1
  69. package/lib/commonjs/providers/screen/styles/slot.provider.js.map +1 -1
  70. package/lib/commonjs/providers/stack/blank-stack-state/helpers/build-blank-stack-state.js +10 -4
  71. package/lib/commonjs/providers/stack/blank-stack-state/helpers/build-blank-stack-state.js.map +1 -1
  72. package/lib/commonjs/providers/stack/blank-stack-state/helpers/derive-blank-stack-state.js +4 -3
  73. package/lib/commonjs/providers/stack/blank-stack-state/helpers/derive-blank-stack-state.js.map +1 -1
  74. package/lib/commonjs/providers/stack/blank-stack-state/helpers/reconcile-blank-stack-routes.js.map +1 -1
  75. package/lib/commonjs/providers/stack/blank-stack-state/helpers/state-equality.js +9 -2
  76. package/lib/commonjs/providers/stack/blank-stack-state/helpers/state-equality.js.map +1 -1
  77. package/lib/commonjs/utils/create-provider.js +14 -3
  78. package/lib/commonjs/utils/create-provider.js.map +1 -1
  79. package/lib/module/components/boundary/create-boundary-component.js +6 -2
  80. package/lib/module/components/boundary/create-boundary-component.js.map +1 -1
  81. package/lib/module/components/boundary/portal/components/boundary-content-portal/helpers/active-handoff-receiver.js +50 -0
  82. package/lib/module/components/boundary/portal/components/boundary-content-portal/helpers/active-handoff-receiver.js.map +1 -1
  83. package/lib/module/components/boundary/portal/components/boundary-content-portal/hooks/use-boundary-content-portal-attachment.js +44 -9
  84. package/lib/module/components/boundary/portal/components/boundary-content-portal/hooks/use-boundary-content-portal-attachment.js.map +1 -1
  85. package/lib/module/components/boundary/portal/components/boundary-portal/hooks/use-boundary-portal-attachment.js +2 -3
  86. package/lib/module/components/boundary/portal/components/boundary-portal/hooks/use-boundary-portal-attachment.js.map +1 -1
  87. package/lib/module/components/boundary/portal/teleport.js +1 -14
  88. package/lib/module/components/boundary/portal/teleport.js.map +1 -1
  89. package/lib/module/components/boundary/utils/source-signals.js +6 -4
  90. package/lib/module/components/boundary/utils/source-signals.js.map +1 -1
  91. package/lib/module/components/overlay/helpers/get-active-overlay.js +3 -24
  92. package/lib/module/components/overlay/helpers/get-active-overlay.js.map +1 -1
  93. package/lib/module/components/overlay/helpers/retain-ready-overlay-resources.js +4 -3
  94. package/lib/module/components/overlay/helpers/retain-ready-overlay-resources.js.map +1 -1
  95. package/lib/module/components/overlay/hooks/use-overlay-slot.js +1 -2
  96. package/lib/module/components/overlay/hooks/use-overlay-slot.js.map +1 -1
  97. package/lib/module/components/overlay/variations/float-overlay.js +0 -2
  98. package/lib/module/components/overlay/variations/float-overlay.js.map +1 -1
  99. package/lib/module/components/overlay/variations/overlay-host.js +19 -16
  100. package/lib/module/components/overlay/variations/overlay-host.js.map +1 -1
  101. package/lib/module/components/screen-container/layers/content.js +10 -5
  102. package/lib/module/components/screen-container/layers/content.js.map +1 -1
  103. package/lib/module/components/screen-container/layers/surface.js +45 -0
  104. package/lib/module/components/screen-container/layers/surface.js.map +1 -0
  105. package/lib/module/components/stack-view.js +7 -29
  106. package/lib/module/components/stack-view.js.map +1 -1
  107. package/lib/module/configs/index.js +2 -5
  108. package/lib/module/configs/index.js.map +1 -1
  109. package/lib/module/configs/presets.js +0 -380
  110. package/lib/module/configs/presets.js.map +1 -1
  111. package/lib/module/constants.js +1 -0
  112. package/lib/module/constants.js.map +1 -1
  113. package/lib/module/navigators/create-blank-stack-navigator.js +7 -66
  114. package/lib/module/navigators/create-blank-stack-navigator.js.map +1 -1
  115. package/lib/module/navigators/expo-router/index.js +1 -18
  116. package/lib/module/navigators/expo-router/index.js.map +1 -1
  117. package/lib/module/navigators/react-navigation/index.js +1 -3
  118. package/lib/module/navigators/react-navigation/index.js.map +1 -1
  119. package/lib/module/providers/screen/animation/animation.provider.js +4 -0
  120. package/lib/module/providers/screen/animation/animation.provider.js.map +1 -1
  121. package/lib/module/providers/screen/animation/helpers/build-screen-transition-options.js +1 -0
  122. package/lib/module/providers/screen/animation/helpers/build-screen-transition-options.js.map +1 -1
  123. package/lib/module/providers/screen/animation/helpers/hydrate-transition-state/gesture-progress.js +20 -5
  124. package/lib/module/providers/screen/animation/helpers/hydrate-transition-state/gesture-progress.js.map +1 -1
  125. package/lib/module/providers/screen/animation/helpers/hydrate-transition-state/index.js +16 -1
  126. package/lib/module/providers/screen/animation/helpers/hydrate-transition-state/index.js.map +1 -1
  127. package/lib/module/providers/screen/animation/helpers/selected-interpolator-options.js +1 -1
  128. package/lib/module/providers/screen/animation/helpers/selected-interpolator-options.js.map +1 -1
  129. package/lib/module/providers/screen/animation/use-screen-animation.js +2 -9
  130. package/lib/module/providers/screen/animation/use-screen-animation.js.map +1 -1
  131. package/lib/module/providers/screen/gestures/pan/behavior/pan-release.js +29 -7
  132. package/lib/module/providers/screen/gestures/pan/behavior/pan-release.js.map +1 -1
  133. package/lib/module/providers/screen/gestures/pinch/behavior/pinch-release.js +27 -7
  134. package/lib/module/providers/screen/gestures/pinch/behavior/pinch-release.js.map +1 -1
  135. package/lib/module/providers/screen/gestures/shared/policy.js +2 -1
  136. package/lib/module/providers/screen/gestures/shared/policy.js.map +1 -1
  137. package/lib/module/providers/screen/gestures/shared/snap-points.js +66 -0
  138. package/lib/module/providers/screen/gestures/shared/snap-points.js.map +1 -1
  139. package/lib/module/providers/screen/options/helpers.js +9 -2
  140. package/lib/module/providers/screen/options/helpers.js.map +1 -1
  141. package/lib/module/providers/screen/styles/constants.js +4 -1
  142. package/lib/module/providers/screen/styles/constants.js.map +1 -1
  143. package/lib/module/providers/screen/styles/hooks/slot-resolvers.js +2 -10
  144. package/lib/module/providers/screen/styles/hooks/slot-resolvers.js.map +1 -1
  145. package/lib/module/providers/screen/styles/slot.provider.js +1 -0
  146. package/lib/module/providers/screen/styles/slot.provider.js.map +1 -1
  147. package/lib/module/providers/stack/blank-stack-state/helpers/build-blank-stack-state.js +11 -5
  148. package/lib/module/providers/stack/blank-stack-state/helpers/build-blank-stack-state.js.map +1 -1
  149. package/lib/module/providers/stack/blank-stack-state/helpers/derive-blank-stack-state.js +5 -4
  150. package/lib/module/providers/stack/blank-stack-state/helpers/derive-blank-stack-state.js.map +1 -1
  151. package/lib/module/providers/stack/blank-stack-state/helpers/reconcile-blank-stack-routes.js.map +1 -1
  152. package/lib/module/providers/stack/blank-stack-state/helpers/state-equality.js +7 -1
  153. package/lib/module/providers/stack/blank-stack-state/helpers/state-equality.js.map +1 -1
  154. package/lib/module/types/animation.types.js +10 -0
  155. package/lib/module/types/animation.types.js.map +1 -1
  156. package/lib/module/utils/create-provider.js +14 -3
  157. package/lib/module/utils/create-provider.js.map +1 -1
  158. package/lib/typescript/components/boundary/create-boundary-component.d.ts.map +1 -1
  159. package/lib/typescript/components/boundary/portal/components/boundary-content-portal/helpers/active-handoff-receiver.d.ts +20 -1
  160. package/lib/typescript/components/boundary/portal/components/boundary-content-portal/helpers/active-handoff-receiver.d.ts.map +1 -1
  161. package/lib/typescript/components/boundary/portal/components/boundary-content-portal/hooks/use-boundary-content-portal-attachment.d.ts.map +1 -1
  162. package/lib/typescript/components/boundary/portal/components/boundary-portal/hooks/use-boundary-portal-attachment.d.ts.map +1 -1
  163. package/lib/typescript/components/boundary/portal/teleport.d.ts +1 -1
  164. package/lib/typescript/components/boundary/portal/teleport.d.ts.map +1 -1
  165. package/lib/typescript/components/boundary/utils/source-signals.d.ts.map +1 -1
  166. package/lib/typescript/components/overlay/helpers/get-active-overlay.d.ts +2 -8
  167. package/lib/typescript/components/overlay/helpers/get-active-overlay.d.ts.map +1 -1
  168. package/lib/typescript/components/overlay/helpers/retain-ready-overlay-resources.d.ts +2 -1
  169. package/lib/typescript/components/overlay/helpers/retain-ready-overlay-resources.d.ts.map +1 -1
  170. package/lib/typescript/components/overlay/hooks/use-overlay-slot.d.ts.map +1 -1
  171. package/lib/typescript/components/overlay/variations/float-overlay.d.ts.map +1 -1
  172. package/lib/typescript/components/overlay/variations/overlay-host.d.ts +2 -3
  173. package/lib/typescript/components/overlay/variations/overlay-host.d.ts.map +1 -1
  174. package/lib/typescript/components/screen-container/layers/content.d.ts.map +1 -1
  175. package/lib/typescript/components/screen-container/layers/surface.d.ts +7 -0
  176. package/lib/typescript/components/screen-container/layers/surface.d.ts.map +1 -0
  177. package/lib/typescript/components/stack-view.d.ts +1 -1
  178. package/lib/typescript/components/stack-view.d.ts.map +1 -1
  179. package/lib/typescript/configs/index.d.ts +0 -9
  180. package/lib/typescript/configs/index.d.ts.map +1 -1
  181. package/lib/typescript/configs/presets.d.ts +0 -9
  182. package/lib/typescript/configs/presets.d.ts.map +1 -1
  183. package/lib/typescript/constants.d.ts +2 -1
  184. package/lib/typescript/constants.d.ts.map +1 -1
  185. package/lib/typescript/index.d.ts +1 -10
  186. package/lib/typescript/index.d.ts.map +1 -1
  187. package/lib/typescript/navigators/create-blank-stack-navigator.d.ts +2 -4
  188. package/lib/typescript/navigators/create-blank-stack-navigator.d.ts.map +1 -1
  189. package/lib/typescript/navigators/expo-router/index.d.ts +3 -3
  190. package/lib/typescript/navigators/expo-router/index.d.ts.map +1 -1
  191. package/lib/typescript/navigators/react-navigation/index.d.ts +1 -1
  192. package/lib/typescript/navigators/react-navigation/index.d.ts.map +1 -1
  193. package/lib/typescript/providers/screen/animation/animation.provider.d.ts +10 -1
  194. package/lib/typescript/providers/screen/animation/animation.provider.d.ts.map +1 -1
  195. package/lib/typescript/providers/screen/animation/helpers/build-screen-transition-options.d.ts.map +1 -1
  196. package/lib/typescript/providers/screen/animation/helpers/hydrate-transition-state/gesture-progress.d.ts +2 -1
  197. package/lib/typescript/providers/screen/animation/helpers/hydrate-transition-state/gesture-progress.d.ts.map +1 -1
  198. package/lib/typescript/providers/screen/animation/helpers/hydrate-transition-state/index.d.ts.map +1 -1
  199. package/lib/typescript/providers/screen/animation/helpers/selected-interpolator-options.d.ts.map +1 -1
  200. package/lib/typescript/providers/screen/animation/use-screen-animation.d.ts.map +1 -1
  201. package/lib/typescript/providers/screen/gestures/pan/behavior/pan-release.d.ts.map +1 -1
  202. package/lib/typescript/providers/screen/gestures/pinch/behavior/pinch-release.d.ts.map +1 -1
  203. package/lib/typescript/providers/screen/gestures/shared/policy.d.ts +2 -1
  204. package/lib/typescript/providers/screen/gestures/shared/policy.d.ts.map +1 -1
  205. package/lib/typescript/providers/screen/gestures/shared/snap-points.d.ts +11 -0
  206. package/lib/typescript/providers/screen/gestures/shared/snap-points.d.ts.map +1 -1
  207. package/lib/typescript/providers/screen/gestures/types.d.ts +2 -0
  208. package/lib/typescript/providers/screen/gestures/types.d.ts.map +1 -1
  209. package/lib/typescript/providers/screen/options/helpers.d.ts.map +1 -1
  210. package/lib/typescript/providers/screen/options/types.d.ts +1 -0
  211. package/lib/typescript/providers/screen/options/types.d.ts.map +1 -1
  212. package/lib/typescript/providers/screen/styles/constants.d.ts.map +1 -1
  213. package/lib/typescript/providers/screen/styles/hooks/slot-resolvers.d.ts.map +1 -1
  214. package/lib/typescript/providers/screen/styles/slot.provider.d.ts +11 -2
  215. package/lib/typescript/providers/screen/styles/slot.provider.d.ts.map +1 -1
  216. package/lib/typescript/providers/stack/blank-stack-state/helpers/build-blank-stack-state.d.ts +3 -3
  217. package/lib/typescript/providers/stack/blank-stack-state/helpers/build-blank-stack-state.d.ts.map +1 -1
  218. package/lib/typescript/providers/stack/blank-stack-state/helpers/derive-blank-stack-state.d.ts.map +1 -1
  219. package/lib/typescript/providers/stack/blank-stack-state/helpers/reconcile-blank-stack-routes.d.ts +3 -2
  220. package/lib/typescript/providers/stack/blank-stack-state/helpers/reconcile-blank-stack-routes.d.ts.map +1 -1
  221. package/lib/typescript/providers/stack/blank-stack-state/helpers/state-equality.d.ts +4 -4
  222. package/lib/typescript/providers/stack/blank-stack-state/helpers/state-equality.d.ts.map +1 -1
  223. package/lib/typescript/providers/stack/blank-stack-state/helpers/types.d.ts +6 -5
  224. package/lib/typescript/providers/stack/blank-stack-state/helpers/types.d.ts.map +1 -1
  225. package/lib/typescript/providers/stack/blank-stack.provider.d.ts +3 -1
  226. package/lib/typescript/providers/stack/blank-stack.provider.d.ts.map +1 -1
  227. package/lib/typescript/types/animation.types.d.ts +16 -12
  228. package/lib/typescript/types/animation.types.d.ts.map +1 -1
  229. package/lib/typescript/types/blank-stack.types.d.ts +2 -23
  230. package/lib/typescript/types/blank-stack.types.d.ts.map +1 -1
  231. package/lib/typescript/types/index.d.ts +2 -2
  232. package/lib/typescript/types/index.d.ts.map +1 -1
  233. package/lib/typescript/types/providers/blank-stack-provider.types.d.ts +8 -6
  234. package/lib/typescript/types/providers/blank-stack-provider.types.d.ts.map +1 -1
  235. package/lib/typescript/types/screen.types.d.ts +50 -0
  236. package/lib/typescript/types/screen.types.d.ts.map +1 -1
  237. package/lib/typescript/utils/create-provider.d.ts +4 -1
  238. package/lib/typescript/utils/create-provider.d.ts.map +1 -1
  239. package/package.json +3 -8
  240. package/src/components/boundary/create-boundary-component.tsx +10 -2
  241. package/src/components/boundary/portal/components/boundary-content-portal/helpers/active-handoff-receiver.ts +89 -0
  242. package/src/components/boundary/portal/components/boundary-content-portal/hooks/use-boundary-content-portal-attachment.ts +97 -14
  243. package/src/components/boundary/portal/components/boundary-portal/hooks/use-boundary-portal-attachment.ts +2 -6
  244. package/src/components/boundary/portal/teleport.ts +2 -23
  245. package/src/components/boundary/utils/source-signals.ts +6 -4
  246. package/src/components/overlay/helpers/get-active-overlay.ts +4 -36
  247. package/src/components/overlay/helpers/retain-ready-overlay-resources.ts +10 -1
  248. package/src/components/overlay/hooks/use-overlay-slot.ts +1 -5
  249. package/src/components/overlay/variations/float-overlay.tsx +9 -12
  250. package/src/components/overlay/variations/overlay-host.tsx +24 -22
  251. package/src/components/screen-container/layers/content.tsx +12 -7
  252. package/src/components/screen-container/layers/surface.tsx +65 -0
  253. package/src/components/stack-view.tsx +8 -39
  254. package/src/configs/index.ts +0 -6
  255. package/src/configs/presets.ts +0 -447
  256. package/src/constants.ts +2 -0
  257. package/src/index.ts +4 -1
  258. package/src/navigators/create-blank-stack-navigator.tsx +16 -124
  259. package/src/navigators/expo-router/index.tsx +0 -23
  260. package/src/navigators/react-navigation/index.tsx +0 -3
  261. package/src/providers/screen/animation/animation.provider.tsx +60 -54
  262. package/src/providers/screen/animation/helpers/build-screen-transition-options.ts +1 -0
  263. package/src/providers/screen/animation/helpers/hydrate-transition-state/gesture-progress.ts +26 -0
  264. package/src/providers/screen/animation/helpers/hydrate-transition-state/index.ts +20 -0
  265. package/src/providers/screen/animation/helpers/selected-interpolator-options.ts +1 -0
  266. package/src/providers/screen/animation/use-screen-animation.tsx +2 -14
  267. package/src/providers/screen/gestures/pan/behavior/pan-release.ts +46 -7
  268. package/src/providers/screen/gestures/pinch/behavior/pinch-release.ts +45 -4
  269. package/src/providers/screen/gestures/shared/policy.ts +4 -0
  270. package/src/providers/screen/gestures/shared/snap-points.ts +87 -0
  271. package/src/providers/screen/gestures/types.ts +2 -0
  272. package/src/providers/screen/options/helpers.ts +18 -0
  273. package/src/providers/screen/options/types.ts +1 -0
  274. package/src/providers/screen/styles/constants.ts +2 -1
  275. package/src/providers/screen/styles/hooks/slot-resolvers.tsx +2 -17
  276. package/src/providers/screen/styles/slot.provider.tsx +2 -1
  277. package/src/providers/stack/blank-stack-state/helpers/build-blank-stack-state.ts +30 -12
  278. package/src/providers/stack/blank-stack-state/helpers/derive-blank-stack-state.ts +11 -3
  279. package/src/providers/stack/blank-stack-state/helpers/reconcile-blank-stack-routes.ts +2 -2
  280. package/src/providers/stack/blank-stack-state/helpers/state-equality.ts +27 -16
  281. package/src/providers/stack/blank-stack-state/helpers/types.ts +9 -4
  282. package/src/types/animation.types.ts +16 -13
  283. package/src/types/blank-stack.types.ts +1 -29
  284. package/src/types/index.ts +4 -1
  285. package/src/types/providers/blank-stack-provider.types.ts +14 -11
  286. package/src/types/screen.types.ts +57 -0
  287. package/src/utils/create-provider.tsx +22 -4
  288. package/lib/commonjs/components/boundary/portal/utils/teleport-control.js +0 -16
  289. package/lib/commonjs/components/boundary/portal/utils/teleport-control.js.map +0 -1
  290. package/lib/commonjs/providers/navigation/navigation-host.provider.js +0 -56
  291. package/lib/commonjs/providers/navigation/navigation-host.provider.js.map +0 -1
  292. package/lib/commonjs/providers/navigation/react-navigation-host.js +0 -23
  293. package/lib/commonjs/providers/navigation/react-navigation-host.js.map +0 -1
  294. package/lib/module/components/boundary/portal/utils/teleport-control.js +0 -11
  295. package/lib/module/components/boundary/portal/utils/teleport-control.js.map +0 -1
  296. package/lib/module/providers/navigation/navigation-host.provider.js +0 -50
  297. package/lib/module/providers/navigation/navigation-host.provider.js.map +0 -1
  298. package/lib/module/providers/navigation/react-navigation-host.js +0 -19
  299. package/lib/module/providers/navigation/react-navigation-host.js.map +0 -1
  300. package/lib/typescript/components/boundary/portal/utils/teleport-control.d.ts +0 -3
  301. package/lib/typescript/components/boundary/portal/utils/teleport-control.d.ts.map +0 -1
  302. package/lib/typescript/providers/navigation/navigation-host.provider.d.ts +0 -21
  303. package/lib/typescript/providers/navigation/navigation-host.provider.d.ts.map +0 -1
  304. package/lib/typescript/providers/navigation/react-navigation-host.d.ts +0 -3
  305. package/lib/typescript/providers/navigation/react-navigation-host.d.ts.map +0 -1
  306. package/src/components/boundary/portal/utils/teleport-control.ts +0 -13
  307. package/src/providers/navigation/navigation-host.provider.tsx +0 -75
  308. package/src/providers/navigation/react-navigation-host.tsx +0 -24
@@ -6,7 +6,6 @@ import {
6
6
  type StackRouterOptions,
7
7
  type StandardNavigationTypeBagBase,
8
8
  } from "@react-navigation/native";
9
- import { reactNavigationHost } from "../../providers/navigation/react-navigation-host";
10
9
  import type {
11
10
  BlankStackNavigationEventMap,
12
11
  BlankStackNavigationOptions,
@@ -33,11 +32,9 @@ export const {
33
32
  >(BlankStackNavigator, StackRouter, ({ state, navigation }) => ({
34
33
  navigationState: state,
35
34
  navigation,
36
- navigationHost: reactNavigationHost,
37
35
  }));
38
36
 
39
37
  export type {
40
- BlankStackFactoryOptions,
41
38
  BlankStackNavigationEventMap,
42
39
  BlankStackNavigationOptions,
43
40
  BlankStackNavigationProp,
@@ -1,6 +1,7 @@
1
1
  import { type ReactNode, useMemo } from "react";
2
2
  import { createBoundsAccessor } from "../../../utils/bounds";
3
3
  import createProvider from "../../../utils/create-provider";
4
+ import { useBlankStackStore } from "../../stack/blank-stack.provider";
4
5
  import { useDescriptorsStore } from "../descriptors";
5
6
  import { useCurrentScreenRelationships } from "../use-current-screen-relationships";
6
7
  import { useScreenAnimationPipeline } from "./helpers/pipeline";
@@ -26,63 +27,68 @@ const createScreenAnimationProvider = createProvider("ScreenAnimation", {
26
27
  })<Props, ScreenAnimationContextValue>;
27
28
 
28
29
  export const {
30
+ StoreProvider: ScreenAnimationStoreProvider,
29
31
  ScreenAnimationProvider,
30
32
  useOptionalScreenAnimationStore,
31
33
  useScreenAnimationStore,
32
- }: ReturnType<typeof createScreenAnimationProvider> =
33
- createScreenAnimationProvider((_props) => {
34
- const currentScreenKey = useDescriptorsStore(
35
- (store) => store.derivations.currentScreenKey,
36
- );
37
- const relationships = useCurrentScreenRelationships();
38
- const pipeline = useScreenAnimationPipeline();
34
+ }: ReturnType<
35
+ typeof createScreenAnimationProvider
36
+ > = createScreenAnimationProvider((_props) => {
37
+ const currentScreenKey = useDescriptorsStore(
38
+ (store) => store.derivations.currentScreenKey,
39
+ );
40
+ const isClosing = useBlankStackStore(
41
+ (store) => store.scenesByKey[currentScreenKey]?.activity === "closing",
42
+ );
43
+ const relationships = useCurrentScreenRelationships();
44
+ const pipeline = useScreenAnimationPipeline();
39
45
 
40
- const screenAnimationSource = useMemo<ScreenAnimationTransitionSource>(
41
- () => ({
42
- screenInterpolatorProps: pipeline.screenInterpolatorProps,
43
- screenInterpolatorPropsRevision:
44
- pipeline.screenInterpolatorPropsRevision,
45
- boundsAccessor: createBoundsAccessor(() => {
46
- "worklet";
47
- return pipeline.screenInterpolatorProps.get();
48
- }),
46
+ const screenAnimationSource = useMemo<ScreenAnimationTransitionSource>(
47
+ () => ({
48
+ screenInterpolatorProps: pipeline.screenInterpolatorProps,
49
+ screenInterpolatorPropsRevision: pipeline.screenInterpolatorPropsRevision,
50
+ boundsAccessor: createBoundsAccessor(() => {
51
+ "worklet";
52
+ return pipeline.screenInterpolatorProps.get();
49
53
  }),
50
- [
51
- pipeline.screenInterpolatorProps,
52
- pipeline.screenInterpolatorPropsRevision,
53
- ],
54
- );
55
- const ancestorSources =
56
- useOptionalScreenAnimationStore(
57
- relationships.parentScreenKey,
58
- (store) => store.transitionSourcesThroughSelf,
59
- ) ?? EMPTY_TRANSITION_SOURCES;
60
- const descendantSources =
61
- useOptionalScreenAnimationStore(
62
- relationships.activeChildScreenKey,
63
- (store) => store.transitionSourcesFromSelf,
64
- ) ?? EMPTY_TRANSITION_SOURCES;
65
- const transitionSourcesThroughSelf = useMemo(
66
- () => [...ancestorSources, screenAnimationSource],
67
- [ancestorSources, screenAnimationSource],
68
- );
69
- const transitionSourcesFromSelf = useMemo(
70
- () => [screenAnimationSource, ...descendantSources],
71
- [screenAnimationSource, descendantSources],
72
- );
73
- const transitionSources = useMemo(
74
- () => [...transitionSourcesThroughSelf, ...descendantSources],
75
- [transitionSourcesThroughSelf, descendantSources],
76
- );
54
+ }),
55
+ [
56
+ pipeline.screenInterpolatorProps,
57
+ pipeline.screenInterpolatorPropsRevision,
58
+ ],
59
+ );
60
+ const ancestorSources =
61
+ useOptionalScreenAnimationStore(
62
+ relationships.parentScreenKey,
63
+ (store) => store.transitionSourcesThroughSelf,
64
+ ) ?? EMPTY_TRANSITION_SOURCES;
65
+ const descendantSources =
66
+ useOptionalScreenAnimationStore(
67
+ relationships.activeChildScreenKey,
68
+ (store) => store.transitionSourcesFromSelf,
69
+ ) ?? EMPTY_TRANSITION_SOURCES;
70
+ const transitionSourcesThroughSelf = useMemo(
71
+ () => [...ancestorSources, screenAnimationSource],
72
+ [ancestorSources, screenAnimationSource],
73
+ );
74
+ const transitionSourcesFromSelf = useMemo(
75
+ () => [screenAnimationSource, ...descendantSources],
76
+ [screenAnimationSource, descendantSources],
77
+ );
78
+ const transitionSources = useMemo(
79
+ () => [...transitionSourcesThroughSelf, ...descendantSources],
80
+ [transitionSourcesThroughSelf, descendantSources],
81
+ );
77
82
 
78
- return {
79
- key: currentScreenKey,
80
- value: {
81
- ...pipeline,
82
- transitionSources,
83
- transitionOriginIndex: ancestorSources.length,
84
- transitionSourcesThroughSelf,
85
- transitionSourcesFromSelf,
86
- },
87
- };
88
- });
83
+ return {
84
+ key: currentScreenKey,
85
+ unregisterOnCleanup: isClosing,
86
+ value: {
87
+ ...pipeline,
88
+ transitionSources,
89
+ transitionOriginIndex: ancestorSources.length,
90
+ transitionSourcesThroughSelf,
91
+ transitionSourcesFromSelf,
92
+ },
93
+ };
94
+ });
@@ -17,6 +17,7 @@ export const buildScreenTransitionOptions = (
17
17
  gestureSnapVelocityImpact: options.gestureSnapVelocityImpact,
18
18
  gestureReleaseVelocityScale: options.gestureReleaseVelocityScale,
19
19
  gestureSnapLocked: options.gestureSnapLocked,
20
+ sheetSnapBehavior: options.sheetSnapBehavior,
20
21
  sheetScrollGestureBehavior:
21
22
  options.sheetScrollGestureBehavior !== undefined
22
23
  ? resolveSheetScrollGestureBehavior(options)
@@ -4,6 +4,7 @@ import type {
4
4
  GestureDirectionOption,
5
5
  GestureValues,
6
6
  } from "../../../../../types/gesture.types";
7
+ import type { SheetSnapBehavior } from "../../../../../types/screen.types";
7
8
  import {
8
9
  getPanActivationDirections,
9
10
  getPanSnapAxisConfigForDirection,
@@ -12,6 +13,7 @@ import {
12
13
  getSnapPinchDirectionConfig,
13
14
  isResolvedPanGestureDirection,
14
15
  } from "../../../gestures/shared/directions";
16
+ import { resolveStepSnapProgress } from "../../../gestures/shared/snap-points";
15
17
  import type { SnapBounds } from "./types";
16
18
 
17
19
  type PanProgressDelta = {
@@ -26,6 +28,8 @@ const resolvePanGestureAffectedProgress = (
26
28
  gestureDirection: GestureDirectionOption,
27
29
  hasSnapPoints: boolean,
28
30
  snapBounds: SnapBounds | null,
31
+ snapPoints: number[],
32
+ sheetSnapBehavior: SheetSnapBehavior,
29
33
  ) => {
30
34
  "worklet";
31
35
 
@@ -46,6 +50,13 @@ const resolvePanGestureAffectedProgress = (
46
50
  const axisValue =
47
51
  activeAxis.axis === "horizontal" ? progressDelta.x : progressDelta.y;
48
52
  const signedProgressDelta = activeAxis.config.progressSign * axisValue;
53
+ if (sheetSnapBehavior === "step") {
54
+ return resolveStepSnapProgress({
55
+ baseline: transitionProgress,
56
+ normalizedDelta: signedProgressDelta,
57
+ snapPoints,
58
+ });
59
+ }
49
60
 
50
61
  return clamp(
51
62
  transitionProgress + signedProgressDelta,
@@ -85,6 +96,8 @@ const resolvePinchGestureAffectedProgress = (
85
96
  gestureDirection: GestureDirectionOption,
86
97
  hasSnapPoints: boolean,
87
98
  snapBounds: SnapBounds | null,
99
+ snapPoints: number[],
100
+ sheetSnapBehavior: SheetSnapBehavior,
88
101
  ) => {
89
102
  "worklet";
90
103
  const pinchDirection =
@@ -108,6 +121,13 @@ const resolvePinchGestureAffectedProgress = (
108
121
  snapDirections.collapse === pinchDirection
109
122
  ? -Math.abs(gesture.normScale)
110
123
  : Math.abs(gesture.normScale);
124
+ if (sheetSnapBehavior === "step") {
125
+ return resolveStepSnapProgress({
126
+ baseline: transitionProgress,
127
+ normalizedDelta: progressDelta,
128
+ snapPoints,
129
+ });
130
+ }
111
131
 
112
132
  return clamp(
113
133
  transitionProgress + progressDelta,
@@ -134,6 +154,8 @@ export const resolveGestureAffectedProgress = (
134
154
  panProgressDelta: PanProgressDelta,
135
155
  gestureDirection: GestureDirectionOption | undefined,
136
156
  snapBounds: SnapBounds | null,
157
+ snapPoints: number[] = [],
158
+ sheetSnapBehavior: SheetSnapBehavior = "continuous",
137
159
  ) => {
138
160
  "worklet";
139
161
  const resolvedGestureDirection =
@@ -152,6 +174,8 @@ export const resolveGestureAffectedProgress = (
152
174
  resolvedGestureDirection,
153
175
  hasSnapPoints,
154
176
  snapBounds,
177
+ snapPoints,
178
+ sheetSnapBehavior,
155
179
  );
156
180
  }
157
181
 
@@ -162,5 +186,7 @@ export const resolveGestureAffectedProgress = (
162
186
  resolvedGestureDirection,
163
187
  hasSnapPoints,
164
188
  snapBounds,
189
+ snapPoints,
190
+ sheetSnapBehavior,
165
191
  );
166
192
  };
@@ -35,6 +35,8 @@ const mergeTransitionOptions = (
35
35
  effective.gestureReleaseVelocityScale ?? base.gestureReleaseVelocityScale;
36
36
  slot.gestureSnapLocked =
37
37
  effective.gestureSnapLocked ?? base.gestureSnapLocked;
38
+ slot.sheetSnapBehavior =
39
+ effective.sheetSnapBehavior ?? base.sheetSnapBehavior;
38
40
  slot.sheetScrollGestureBehavior =
39
41
  effective.sheetScrollGestureBehavior ?? base.sheetScrollGestureBehavior;
40
42
  slot.backdropBehavior = effective.backdropBehavior ?? base.backdropBehavior;
@@ -56,6 +58,22 @@ export const hydrateTransitionState = (
56
58
  s.optionsSlot,
57
59
  );
58
60
  const canDismiss = options.gestureEnabled !== false;
61
+ const resolvedSnapPoints = [...s.sortedNumericSnapPoints];
62
+ const resolvedAutoSnapPoint = s.hasAutoSnapPoint
63
+ ? s.resolvedAutoSnapPoint.get()
64
+ : null;
65
+ if (resolvedAutoSnapPoint !== null) {
66
+ resolvedSnapPoints.push(resolvedAutoSnapPoint);
67
+ }
68
+ if (canDismiss) {
69
+ resolvedSnapPoints.push(0);
70
+ }
71
+ resolvedSnapPoints.sort((a, b) => a - b);
72
+ for (let index = resolvedSnapPoints.length - 1; index > 0; index--) {
73
+ if (resolvedSnapPoints[index] === resolvedSnapPoints[index - 1]) {
74
+ resolvedSnapPoints.splice(index, 1);
75
+ }
76
+ }
59
77
  out.transitionProgress = transitionProgress;
60
78
  out.willAnimate = s.willAnimate.get();
61
79
  out.closing = s.closing.get();
@@ -159,6 +177,8 @@ export const hydrateTransitionState = (
159
177
  s.hasAutoSnapPoint ? s.resolvedAutoSnapPoint.get() : null,
160
178
  canDismiss,
161
179
  ),
180
+ resolvedSnapPoints,
181
+ options.sheetSnapBehavior,
162
182
  );
163
183
 
164
184
  if (s.visualProgress.get() !== out.progress) {
@@ -65,6 +65,7 @@ const areInterpolatorOptionsEqual = (
65
65
  left.gestureSnapVelocityImpact === right.gestureSnapVelocityImpact &&
66
66
  left.gestureReleaseVelocityScale === right.gestureReleaseVelocityScale &&
67
67
  left.gestureSnapLocked === right.gestureSnapLocked &&
68
+ left.sheetSnapBehavior === right.sheetSnapBehavior &&
68
69
  left.sheetScrollGestureBehavior === right.sheetScrollGestureBehavior &&
69
70
  left.backdropBehavior === right.backdropBehavior
70
71
  );
@@ -3,8 +3,7 @@ import type {
3
3
  ScreenInterpolationProps,
4
4
  ScreenTransitionTarget,
5
5
  } from "../../../types/animation.types";
6
- import { useNavigationRoute } from "../../navigation/navigation-host.provider";
7
- import { useOptionalScreenAnimationStore } from "./animation.provider";
6
+ import { useScreenAnimationStore } from "./animation.provider";
8
7
  import { useBuildTransitionAccessor } from "./helpers/accessors/use-build-transition-accessor";
9
8
  import { readScreenAnimationRevisions } from "./helpers/read-screen-animation-revisions";
10
9
  import type { ScreenAnimationTarget } from "./types";
@@ -23,18 +22,7 @@ export function useScreenAnimation(
23
22
  ):
24
23
  | DerivedValue<ScreenInterpolationProps>
25
24
  | DerivedValue<ScreenInterpolationProps | null> {
26
- const routeKey = useNavigationRoute().key;
27
- const localAnimationStore = useOptionalScreenAnimationStore();
28
- const keyedAnimationStore = useOptionalScreenAnimationStore(
29
- localAnimationStore ? null : routeKey,
30
- );
31
- const screenAnimationStore = localAnimationStore ?? keyedAnimationStore;
32
-
33
- if (!screenAnimationStore) {
34
- throw new Error(
35
- `ScreenAnimationStore is unavailable for route "${routeKey}"`,
36
- );
37
- }
25
+ const screenAnimationStore = useScreenAnimationStore();
38
26
 
39
27
  const { transitionSources } = screenAnimationStore;
40
28
  const transition = useBuildTransitionAccessor(screenAnimationStore);
@@ -13,8 +13,12 @@ import {
13
13
  resolveGestureSnapTransitionSpec,
14
14
  } from "../../shared/release";
15
15
  import {
16
+ getStepSnapProgressVelocityScale,
16
17
  primeRuntimeSnapPoint,
17
18
  resolveRuntimeGestureSnapPoints,
19
+ resolveRuntimeGestureSnapTargets,
20
+ resolveStepSnapProgress,
21
+ resolveStepSnapTargets,
18
22
  } from "../../shared/snap-points";
19
23
  import { determineDismissal, determineSnapTarget } from "../../shared/targets";
20
24
  import type {
@@ -80,6 +84,8 @@ const getPanSnapReleaseProgress = ({
80
84
  activeAxis,
81
85
  minSnapPoint,
82
86
  maxSnapPoint,
87
+ snapPoints,
88
+ sheetSnapBehavior,
83
89
  }: {
84
90
  runtime: PanGestureRuntime;
85
91
  event: PanGestureEvent;
@@ -87,6 +93,8 @@ const getPanSnapReleaseProgress = ({
87
93
  activeAxis: NonNullable<ReturnType<typeof resolveActivePanSnapAxis>>;
88
94
  minSnapPoint: number;
89
95
  maxSnapPoint: number;
96
+ snapPoints: number[];
97
+ sheetSnapBehavior: PanGestureRuntime["policy"]["sheetSnapBehavior"];
90
98
  }) => {
91
99
  "worklet";
92
100
  const isHorizontal = activeAxis.axis === "horizontal";
@@ -95,9 +103,17 @@ const getPanSnapReleaseProgress = ({
95
103
  : event.translationY;
96
104
  const axisDimension = isHorizontal ? dimensions.width : dimensions.height;
97
105
  const axisProgress = axisTranslation / Math.max(1, axisDimension);
106
+ const signedProgressDelta = activeAxis.config.progressSign * axisProgress;
107
+ if (sheetSnapBehavior === "step") {
108
+ return resolveStepSnapProgress({
109
+ baseline: runtime.stores.gestures.internal.progressBaseline.get(),
110
+ normalizedDelta: signedProgressDelta,
111
+ snapPoints,
112
+ });
113
+ }
98
114
  const progress =
99
115
  runtime.stores.gestures.internal.progressBaseline.get() +
100
- activeAxis.config.progressSign * axisProgress;
116
+ signedProgressDelta;
101
117
 
102
118
  return clamp(progress, minSnapPoint, maxSnapPoint);
103
119
  };
@@ -180,6 +196,24 @@ export const resolveSnapPanRelease = (
180
196
  );
181
197
  const { resolvedSnapPoints, resolvedMinSnapPoint, resolvedMaxSnapPoint } =
182
198
  resolveRuntimeGestureSnapPoints(runtime);
199
+ const allSnapTargets = resolveRuntimeGestureSnapTargets(runtime);
200
+ const axisTranslation =
201
+ activeAxis.axis === "horizontal" ? event.translationX : event.translationY;
202
+ const progressDirection =
203
+ activeAxis.config.progressSign * axisTranslation || -snapVelocity;
204
+ const releaseSnapPoints =
205
+ policy.sheetSnapBehavior === "step"
206
+ ? resolveStepSnapTargets({
207
+ baseline: runtime.stores.gestures.internal.progressBaseline.get(),
208
+ direction: progressDirection,
209
+ snapPoints: allSnapTargets,
210
+ })
211
+ : resolvedSnapPoints;
212
+ const canDismissToReleaseTarget =
213
+ participation.canDismiss &&
214
+ (policy.gestureSnapLocked ||
215
+ policy.sheetSnapBehavior === "continuous" ||
216
+ releaseSnapPoints.includes(0));
183
217
  const currentProgress = getPanSnapReleaseProgress({
184
218
  runtime,
185
219
  event,
@@ -187,6 +221,8 @@ export const resolveSnapPanRelease = (
187
221
  activeAxis,
188
222
  minSnapPoint: resolvedMinSnapPoint,
189
223
  maxSnapPoint: resolvedMaxSnapPoint,
224
+ snapPoints: allSnapTargets,
225
+ sheetSnapBehavior: policy.sheetSnapBehavior,
190
226
  });
191
227
  const result = determineSnapTarget({
192
228
  currentProgress,
@@ -195,24 +231,27 @@ export const resolveSnapPanRelease = (
195
231
  runtime.stores.gestures.internal.lockedSnapPoint.get() ??
196
232
  resolvedMaxSnapPoint,
197
233
  ]
198
- : resolvedSnapPoints,
234
+ : releaseSnapPoints,
199
235
  velocity: snapVelocity,
200
236
  dimension: axisDimension,
201
237
  velocityFactor: policy.gestureSnapVelocityImpact,
202
- canDismiss: participation.canDismiss,
238
+ canDismiss: canDismissToReleaseTarget,
203
239
  });
204
240
 
205
241
  const shouldDismiss = participation.canDismiss && result.shouldDismiss;
206
242
  const target = shouldDismiss ? 0 : result.targetProgress;
243
+ const progressVelocityScale =
244
+ policy.sheetSnapBehavior === "step" && !policy.gestureSnapLocked
245
+ ? getStepSnapProgressVelocityScale(releaseSnapPoints)
246
+ : 1;
207
247
 
208
248
  return {
209
249
  target,
210
250
  shouldDismiss,
211
251
  initialVelocity: getProgressVelocityTowardTarget({
212
- handoffVelocity: getPanReleaseHandoffVelocity(
213
- axisVelocity,
214
- axisDimension,
215
- ),
252
+ handoffVelocity:
253
+ getPanReleaseHandoffVelocity(axisVelocity, axisDimension) *
254
+ progressVelocityScale,
216
255
  target,
217
256
  currentProgress,
218
257
  }),
@@ -10,8 +10,12 @@ import {
10
10
  resolveGestureSnapTransitionSpec,
11
11
  } from "../../shared/release";
12
12
  import {
13
+ getStepSnapProgressVelocityScale,
13
14
  primeRuntimeSnapPoint,
14
15
  resolveRuntimeGestureSnapPoints,
16
+ resolveRuntimeGestureSnapTargets,
17
+ resolveStepSnapProgress,
18
+ resolveStepSnapTargets,
15
19
  } from "../../shared/snap-points";
16
20
  import { determineSnapTarget } from "../../shared/targets";
17
21
  import type {
@@ -56,11 +60,13 @@ const getPinchSnapReleaseProgress = ({
56
60
  normalizedScale,
57
61
  minSnapPoint,
58
62
  maxSnapPoint,
63
+ snapPoints,
59
64
  }: {
60
65
  runtime: PinchGestureRuntime;
61
66
  normalizedScale: number;
62
67
  minSnapPoint: number;
63
68
  maxSnapPoint: number;
69
+ snapPoints: number[];
64
70
  }) => {
65
71
  "worklet";
66
72
  const pinchDirection = getPinchSnapDirection(normalizedScale);
@@ -74,6 +80,13 @@ const getPinchSnapReleaseProgress = ({
74
80
  snapDirections.collapse === pinchDirection
75
81
  ? -Math.abs(normalizedScale)
76
82
  : Math.abs(normalizedScale);
83
+ if (runtime.policy.sheetSnapBehavior === "step") {
84
+ return resolveStepSnapProgress({
85
+ baseline: runtime.stores.gestures.internal.progressBaseline.get(),
86
+ normalizedDelta: progressDelta,
87
+ snapPoints,
88
+ });
89
+ }
77
90
 
78
91
  return clamp(
79
92
  runtime.stores.gestures.internal.progressBaseline.get() + progressDelta,
@@ -141,11 +154,34 @@ export const resolveSnapPinchRelease = (
141
154
 
142
155
  const { resolvedSnapPoints, resolvedMinSnapPoint, resolvedMaxSnapPoint } =
143
156
  resolveRuntimeGestureSnapPoints(runtime);
157
+ const allSnapTargets = resolveRuntimeGestureSnapTargets(runtime);
158
+ const snapVelocity = getPinchSnapVelocity(event, runtime, normalizedScale);
159
+ const pinchDirection = getPinchSnapDirection(normalizedScale);
160
+ const progressDirection =
161
+ pinchDirection && policy.snapDirections
162
+ ? policy.snapDirections.collapse === pinchDirection
163
+ ? -1
164
+ : 1
165
+ : -snapVelocity;
166
+ const releaseSnapPoints =
167
+ policy.sheetSnapBehavior === "step"
168
+ ? resolveStepSnapTargets({
169
+ baseline: runtime.stores.gestures.internal.progressBaseline.get(),
170
+ direction: progressDirection,
171
+ snapPoints: allSnapTargets,
172
+ })
173
+ : resolvedSnapPoints;
174
+ const canDismissToReleaseTarget =
175
+ participation.canDismiss &&
176
+ (policy.gestureSnapLocked ||
177
+ policy.sheetSnapBehavior === "continuous" ||
178
+ releaseSnapPoints.includes(0));
144
179
  const currentProgress = getPinchSnapReleaseProgress({
145
180
  runtime,
146
181
  normalizedScale,
147
182
  minSnapPoint: resolvedMinSnapPoint,
148
183
  maxSnapPoint: resolvedMaxSnapPoint,
184
+ snapPoints: allSnapTargets,
149
185
  });
150
186
 
151
187
  const result = determineSnapTarget({
@@ -155,16 +191,21 @@ export const resolveSnapPinchRelease = (
155
191
  runtime.stores.gestures.internal.lockedSnapPoint.get() ??
156
192
  resolvedMaxSnapPoint,
157
193
  ]
158
- : resolvedSnapPoints,
159
- velocity: getPinchSnapVelocity(event, runtime, normalizedScale),
194
+ : releaseSnapPoints,
195
+ velocity: snapVelocity,
160
196
  dimension: 1,
161
197
  velocityFactor: policy.gestureSnapVelocityImpact,
162
- canDismiss: participation.canDismiss,
198
+ canDismiss: canDismissToReleaseTarget,
163
199
  });
164
200
 
165
201
  const shouldDismiss = participation.canDismiss && result.shouldDismiss;
166
202
  const target = shouldDismiss ? 0 : result.targetProgress;
167
- const progressVelocity = getPinchReleaseHandoffVelocity(event.velocity);
203
+ const progressVelocityScale =
204
+ policy.sheetSnapBehavior === "step" && !policy.gestureSnapLocked
205
+ ? getStepSnapProgressVelocityScale(releaseSnapPoints)
206
+ : 1;
207
+ const progressVelocity =
208
+ getPinchReleaseHandoffVelocity(event.velocity) * progressVelocityScale;
168
209
  const handoffVelocity = getPinchReleaseHandoffVelocity(
169
210
  event.velocity,
170
211
  policy.gestureReleaseVelocityScale,
@@ -8,6 +8,7 @@ import {
8
8
  DEFAULT_GESTURE_TRACKING,
9
9
  DEFAULT_GESTURE_VELOCITY_IMPACT,
10
10
  DEFAULT_SHEET_SCROLL_GESTURE_BEHAVIOR,
11
+ DEFAULT_SHEET_SNAP_BEHAVIOR,
11
12
  } from "../../../../constants";
12
13
  import type {
13
14
  GestureDirectionActivationArea,
@@ -19,6 +20,7 @@ import type {
19
20
  GestureTracking,
20
21
  ScreenTransitionConfig,
21
22
  SheetScrollGestureBehavior,
23
+ SheetSnapBehavior,
22
24
  SnapPoint,
23
25
  } from "../../../../types/screen.types";
24
26
  import { computeClaimedDirections } from "../ownership/compute-claimed-directions";
@@ -50,6 +52,7 @@ export type GesturePolicyOptions = {
50
52
  gestureSnapLocked?: boolean;
51
53
  gestureSnapVelocityImpact?: number;
52
54
  gestureVelocityImpact?: number;
55
+ sheetSnapBehavior?: SheetSnapBehavior;
53
56
  sheetScrollGestureBehavior?: SheetScrollGestureBehavior;
54
57
  snapPoints?: SnapPoint[];
55
58
  transitionSpec?: ScreenTransitionConfig["transitionSpec"];
@@ -152,6 +155,7 @@ const resolveCommonGesturePolicy = (options: GesturePolicyOptions) => {
152
155
  gestureSnapVelocityImpact:
153
156
  options.gestureSnapVelocityImpact ?? DEFAULT_GESTURE_SNAP_VELOCITY_IMPACT,
154
157
  gestureSnapLocked: options.gestureSnapLocked ?? DEFAULT_GESTURE_SNAP_LOCKED,
158
+ sheetSnapBehavior: options.sheetSnapBehavior ?? DEFAULT_SHEET_SNAP_BEHAVIOR,
155
159
  gestureReleaseVelocityScale:
156
160
  options.gestureReleaseVelocityScale ??
157
161
  DEFAULT_GESTURE_RELEASE_VELOCITY_SCALE,
@@ -204,6 +204,18 @@ export const resolveRuntimeGestureSnapPoints = (
204
204
  });
205
205
  };
206
206
 
207
+ export const resolveRuntimeGestureSnapTargets = (
208
+ runtime: GestureRuntime<GesturePolicy>,
209
+ ): number[] => {
210
+ "worklet";
211
+ const { resolvedSnapPoints } = resolveRuntimeGestureSnapPoints(runtime);
212
+ const targets = runtime.participation.canDismiss
213
+ ? [0, ...resolvedSnapPoints]
214
+ : resolvedSnapPoints;
215
+
216
+ return Array.from(new Set(targets)).sort((a, b) => a - b);
217
+ };
218
+
207
219
  const findNearestSnapPoint = (
208
220
  progress: number,
209
221
  snapPoints: number[],
@@ -226,6 +238,81 @@ const findNearestSnapPoint = (
226
238
  return nearest;
227
239
  };
228
240
 
241
+ const findNearestSnapPointIndex = (
242
+ progress: number,
243
+ snapPoints: number[],
244
+ ): number => {
245
+ "worklet";
246
+ let nearestIndex = 0;
247
+ let smallestDistance = Math.abs(progress - (snapPoints[0] ?? progress));
248
+
249
+ for (let i = 1; i < snapPoints.length; i++) {
250
+ const distance = Math.abs(progress - snapPoints[i]);
251
+ if (distance < smallestDistance) {
252
+ smallestDistance = distance;
253
+ nearestIndex = i;
254
+ }
255
+ }
256
+
257
+ return nearestIndex;
258
+ };
259
+
260
+ interface ResolveStepSnapProps {
261
+ baseline: number;
262
+ direction: number;
263
+ snapPoints: number[];
264
+ }
265
+
266
+ export const resolveStepSnapTargets = ({
267
+ baseline,
268
+ direction,
269
+ snapPoints,
270
+ }: ResolveStepSnapProps): number[] => {
271
+ "worklet";
272
+ if (snapPoints.length === 0) {
273
+ return [baseline];
274
+ }
275
+
276
+ const baselineIndex = findNearestSnapPointIndex(baseline, snapPoints);
277
+ const start = snapPoints[baselineIndex] ?? baseline;
278
+ const adjacentIndex = baselineIndex + Math.sign(direction);
279
+ const adjacent = snapPoints[adjacentIndex];
280
+
281
+ if (direction === 0 || adjacent === undefined) {
282
+ return [start];
283
+ }
284
+
285
+ return direction < 0 ? [adjacent, start] : [start, adjacent];
286
+ };
287
+
288
+ export const resolveStepSnapProgress = ({
289
+ baseline,
290
+ normalizedDelta,
291
+ snapPoints,
292
+ }: Omit<ResolveStepSnapProps, "direction"> & {
293
+ normalizedDelta: number;
294
+ }): number => {
295
+ "worklet";
296
+ const targets = resolveStepSnapTargets({
297
+ baseline,
298
+ direction: normalizedDelta,
299
+ snapPoints,
300
+ });
301
+ const target = normalizedDelta < 0 ? targets[0] : targets[targets.length - 1];
302
+ const localProgress = Math.min(1, Math.abs(normalizedDelta));
303
+
304
+ return baseline + (target - baseline) * localProgress;
305
+ };
306
+
307
+ export const getStepSnapProgressVelocityScale = (targets: number[]): number => {
308
+ "worklet";
309
+ if (targets.length < 2) {
310
+ return 0;
311
+ }
312
+
313
+ return Math.abs(targets[targets.length - 1] - targets[0]);
314
+ };
315
+
229
316
  export const primeRuntimeSnapPoint = (
230
317
  runtime: GestureRuntime<GesturePolicy>,
231
318
  ) => {