react-native-screen-transitions 2.4.0 → 2.4.2-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 (270) hide show
  1. package/lib/commonjs/__configs__/presets.js.map +1 -1
  2. package/lib/commonjs/components/root-transition-aware.js.map +1 -1
  3. package/lib/commonjs/constants.js.map +1 -1
  4. package/lib/commonjs/hooks/animation/use-screen-animation.js +9 -5
  5. package/lib/commonjs/hooks/animation/use-screen-animation.js.map +1 -1
  6. package/lib/commonjs/index.js +7 -0
  7. package/lib/commonjs/index.js.map +1 -1
  8. package/lib/commonjs/integrations/blank-stack/components/Header.js +142 -0
  9. package/lib/commonjs/integrations/blank-stack/components/Header.js.map +1 -0
  10. package/lib/commonjs/integrations/blank-stack/components/Screens.js +64 -0
  11. package/lib/commonjs/integrations/blank-stack/components/Screens.js.map +1 -0
  12. package/lib/commonjs/integrations/blank-stack/components/StackView.js +94 -0
  13. package/lib/commonjs/integrations/blank-stack/components/StackView.js.map +1 -0
  14. package/lib/commonjs/integrations/blank-stack/navigators/createBlankStackNavigator.js +74 -0
  15. package/lib/commonjs/integrations/blank-stack/navigators/createBlankStackNavigator.js.map +1 -0
  16. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js +66 -0
  17. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js.map +1 -0
  18. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js +16 -0
  19. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js.map +1 -0
  20. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js +208 -0
  21. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js.map +1 -0
  22. package/lib/commonjs/{types/navigator.js → integrations/blank-stack/utils/with-stack-navigation/_types.js} +1 -1
  23. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_types.js.map +1 -0
  24. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js +15 -0
  25. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js.map +1 -0
  26. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.js +23 -0
  27. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.js.map +1 -0
  28. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js +15 -0
  29. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js.map +1 -0
  30. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js +14 -0
  31. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js.map +1 -0
  32. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js +13 -0
  33. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js.map +1 -0
  34. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/index.js +71 -0
  35. package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/index.js.map +1 -0
  36. package/lib/commonjs/integrations/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  37. package/lib/commonjs/integrations/native-stack/utils/getModalRoutesKeys.js.map +1 -1
  38. package/lib/commonjs/integrations/native-stack/utils/useInvalidPreventRemoveError.js.map +1 -1
  39. package/lib/commonjs/integrations/native-stack/views/NativeStackView.js.map +1 -1
  40. package/lib/commonjs/integrations/native-stack/views/NativeStackView.native.js.map +1 -1
  41. package/lib/commonjs/integrations/native-stack/views/useHeaderConfigProps.js.map +1 -1
  42. package/lib/commonjs/providers/keys.js.map +1 -1
  43. package/lib/commonjs/providers/screen-transition-provider.js.map +1 -1
  44. package/lib/commonjs/providers/transition-styles.js +18 -4
  45. package/lib/commonjs/providers/transition-styles.js.map +1 -1
  46. package/lib/commonjs/stores/animations.js.map +1 -1
  47. package/lib/commonjs/stores/bounds/index.js.map +1 -1
  48. package/lib/commonjs/stores/gestures.js.map +1 -1
  49. package/lib/commonjs/stores/utils/reset-stores-for-screen.js.map +1 -1
  50. package/lib/commonjs/types/blank-stack.navigator.js +6 -0
  51. package/lib/commonjs/types/{navigator.js.map → blank-stack.navigator.js.map} +1 -1
  52. package/lib/commonjs/types/native-stack.navigator.js +6 -0
  53. package/lib/commonjs/types/native-stack.navigator.js.map +1 -0
  54. package/lib/commonjs/utils/animation/derivations.js +1 -14
  55. package/lib/commonjs/utils/animation/derivations.js.map +1 -1
  56. package/lib/commonjs/utils/bounds/_utils/styles.js.map +1 -1
  57. package/lib/commonjs/utils/bounds/constants.js.map +1 -1
  58. package/lib/commonjs/utils/bounds/index.js +23 -90
  59. package/lib/commonjs/utils/bounds/index.js.map +1 -1
  60. package/lib/commonjs/utils/gesture/apply-offset-rules.js.map +1 -1
  61. package/lib/commonjs/utils/gesture/check-gesture-activation.js.map +1 -1
  62. package/lib/commonjs/utils/gesture/reset-gesture-values.js.map +1 -1
  63. package/lib/commonjs/utils/gesture/velocity.js +2 -2
  64. package/lib/commonjs/utils/gesture/velocity.js.map +1 -1
  65. package/lib/module/__configs__/presets.js.map +1 -1
  66. package/lib/module/components/root-transition-aware.js.map +1 -1
  67. package/lib/module/constants.js.map +1 -1
  68. package/lib/module/hooks/animation/use-screen-animation.js +9 -5
  69. package/lib/module/hooks/animation/use-screen-animation.js.map +1 -1
  70. package/lib/module/index.js +1 -0
  71. package/lib/module/index.js.map +1 -1
  72. package/lib/module/integrations/blank-stack/components/Header.js +138 -0
  73. package/lib/module/integrations/blank-stack/components/Header.js.map +1 -0
  74. package/lib/module/integrations/blank-stack/components/Screens.js +58 -0
  75. package/lib/module/integrations/blank-stack/components/Screens.js.map +1 -0
  76. package/lib/module/integrations/blank-stack/components/StackView.js +90 -0
  77. package/lib/module/integrations/blank-stack/components/StackView.js.map +1 -0
  78. package/lib/module/integrations/blank-stack/navigators/createBlankStackNavigator.js +68 -0
  79. package/lib/module/integrations/blank-stack/navigators/createBlankStackNavigator.js.map +1 -0
  80. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js +60 -0
  81. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js.map +1 -0
  82. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js +11 -0
  83. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js.map +1 -0
  84. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js +202 -0
  85. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js.map +1 -0
  86. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_types.js +4 -0
  87. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_types.js.map +1 -0
  88. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js +10 -0
  89. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js.map +1 -0
  90. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.js +19 -0
  91. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.js.map +1 -0
  92. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js +10 -0
  93. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js.map +1 -0
  94. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js +9 -0
  95. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js.map +1 -0
  96. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js +8 -0
  97. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js.map +1 -0
  98. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/index.js +65 -0
  99. package/lib/module/integrations/blank-stack/utils/with-stack-navigation/index.js.map +1 -0
  100. package/lib/module/integrations/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  101. package/lib/module/integrations/native-stack/utils/getModalRoutesKeys.js.map +1 -1
  102. package/lib/module/integrations/native-stack/utils/useInvalidPreventRemoveError.js.map +1 -1
  103. package/lib/module/integrations/native-stack/views/NativeStackView.js.map +1 -1
  104. package/lib/module/integrations/native-stack/views/NativeStackView.native.js.map +1 -1
  105. package/lib/module/integrations/native-stack/views/useHeaderConfigProps.js.map +1 -1
  106. package/lib/module/providers/keys.js.map +1 -1
  107. package/lib/module/providers/screen-transition-provider.js.map +1 -1
  108. package/lib/module/providers/transition-styles.js +19 -5
  109. package/lib/module/providers/transition-styles.js.map +1 -1
  110. package/lib/module/stores/animations.js.map +1 -1
  111. package/lib/module/stores/bounds/index.js.map +1 -1
  112. package/lib/module/stores/gestures.js.map +1 -1
  113. package/lib/module/stores/utils/reset-stores-for-screen.js.map +1 -1
  114. package/lib/module/types/blank-stack.navigator.js +4 -0
  115. package/lib/module/types/{navigator.js.map → blank-stack.navigator.js.map} +1 -1
  116. package/lib/module/types/native-stack.navigator.js +4 -0
  117. package/lib/module/types/native-stack.navigator.js.map +1 -0
  118. package/lib/module/utils/animation/derivations.js +1 -14
  119. package/lib/module/utils/animation/derivations.js.map +1 -1
  120. package/lib/module/utils/bounds/_utils/styles.js.map +1 -1
  121. package/lib/module/utils/bounds/constants.js.map +1 -1
  122. package/lib/module/utils/bounds/index.js +24 -91
  123. package/lib/module/utils/bounds/index.js.map +1 -1
  124. package/lib/module/utils/gesture/apply-offset-rules.js.map +1 -1
  125. package/lib/module/utils/gesture/check-gesture-activation.js.map +1 -1
  126. package/lib/module/utils/gesture/reset-gesture-values.js.map +1 -1
  127. package/lib/module/utils/gesture/velocity.js +2 -2
  128. package/lib/module/utils/gesture/velocity.js.map +1 -1
  129. package/lib/typescript/__configs__/index.d.ts +9 -9
  130. package/lib/typescript/__configs__/index.d.ts.map +1 -1
  131. package/lib/typescript/__configs__/presets.d.ts +1 -1
  132. package/lib/typescript/__configs__/presets.d.ts.map +1 -1
  133. package/lib/typescript/components/root-transition-aware.d.ts.map +1 -1
  134. package/lib/typescript/constants.d.ts +2 -2
  135. package/lib/typescript/constants.d.ts.map +1 -1
  136. package/lib/typescript/hooks/animation/use-screen-animation.d.ts +1 -1
  137. package/lib/typescript/hooks/animation/use-screen-animation.d.ts.map +1 -1
  138. package/lib/typescript/index.d.ts +20 -18
  139. package/lib/typescript/index.d.ts.map +1 -1
  140. package/lib/typescript/integrations/blank-stack/components/Header.d.ts +5 -0
  141. package/lib/typescript/integrations/blank-stack/components/Header.d.ts.map +1 -0
  142. package/lib/typescript/integrations/blank-stack/components/Screens.d.ts +15 -0
  143. package/lib/typescript/integrations/blank-stack/components/Screens.d.ts.map +1 -0
  144. package/lib/typescript/integrations/blank-stack/components/StackView.d.ts +2 -0
  145. package/lib/typescript/integrations/blank-stack/components/StackView.d.ts.map +1 -0
  146. package/lib/typescript/integrations/blank-stack/navigators/createBlankStackNavigator.d.ts +109 -0
  147. package/lib/typescript/integrations/blank-stack/navigators/createBlankStackNavigator.d.ts.map +1 -0
  148. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.d.ts +8 -0
  149. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.d.ts.map +1 -0
  150. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.d.ts +2 -0
  151. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.d.ts.map +1 -0
  152. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.d.ts +20 -0
  153. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.d.ts.map +1 -0
  154. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_types.d.ts +23 -0
  155. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_types.d.ts.map +1 -0
  156. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.d.ts +3 -0
  157. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.d.ts.map +1 -0
  158. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.d.ts +4 -0
  159. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.d.ts.map +1 -0
  160. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.d.ts +4 -0
  161. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.d.ts.map +1 -0
  162. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.d.ts +3 -0
  163. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.d.ts.map +1 -0
  164. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.d.ts +3 -0
  165. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.d.ts.map +1 -0
  166. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/index.d.ts +6 -0
  167. package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/index.d.ts.map +1 -0
  168. package/lib/typescript/integrations/native-stack/navigators/createNativeStackNavigator.d.ts +1 -1
  169. package/lib/typescript/integrations/native-stack/navigators/createNativeStackNavigator.d.ts.map +1 -1
  170. package/lib/typescript/integrations/native-stack/utils/getModalRoutesKeys.d.ts +1 -1
  171. package/lib/typescript/integrations/native-stack/utils/getModalRoutesKeys.d.ts.map +1 -1
  172. package/lib/typescript/integrations/native-stack/utils/useInvalidPreventRemoveError.d.ts +1 -1
  173. package/lib/typescript/integrations/native-stack/utils/useInvalidPreventRemoveError.d.ts.map +1 -1
  174. package/lib/typescript/integrations/native-stack/views/NativeStackView.d.ts +1 -1
  175. package/lib/typescript/integrations/native-stack/views/NativeStackView.d.ts.map +1 -1
  176. package/lib/typescript/integrations/native-stack/views/NativeStackView.native.d.ts +1 -1
  177. package/lib/typescript/integrations/native-stack/views/NativeStackView.native.d.ts.map +1 -1
  178. package/lib/typescript/integrations/native-stack/views/useHeaderConfigProps.d.ts +1 -1
  179. package/lib/typescript/integrations/native-stack/views/useHeaderConfigProps.d.ts.map +1 -1
  180. package/lib/typescript/providers/keys.d.ts +1 -1
  181. package/lib/typescript/providers/keys.d.ts.map +1 -1
  182. package/lib/typescript/providers/screen-transition-provider.d.ts +1 -1
  183. package/lib/typescript/providers/screen-transition-provider.d.ts.map +1 -1
  184. package/lib/typescript/providers/transition-styles.d.ts.map +1 -1
  185. package/lib/typescript/stores/animations.d.ts +1 -1
  186. package/lib/typescript/stores/animations.d.ts.map +1 -1
  187. package/lib/typescript/stores/bounds/index.d.ts +1 -1
  188. package/lib/typescript/stores/bounds/index.d.ts.map +1 -1
  189. package/lib/typescript/stores/gestures.d.ts +1 -1
  190. package/lib/typescript/stores/gestures.d.ts.map +1 -1
  191. package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts +1 -1
  192. package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts.map +1 -1
  193. package/lib/typescript/types/animation.d.ts +2 -4
  194. package/lib/typescript/types/animation.d.ts.map +1 -1
  195. package/lib/typescript/types/blank-stack.navigator.d.ts +219 -0
  196. package/lib/typescript/types/blank-stack.navigator.d.ts.map +1 -0
  197. package/lib/typescript/types/bounds.d.ts +0 -57
  198. package/lib/typescript/types/bounds.d.ts.map +1 -1
  199. package/lib/typescript/types/{navigator.d.ts → native-stack.navigator.d.ts} +5 -1
  200. package/lib/typescript/types/native-stack.navigator.d.ts.map +1 -0
  201. package/lib/typescript/types/utils.d.ts.map +1 -1
  202. package/lib/typescript/utils/animation/derivations.d.ts +1 -4
  203. package/lib/typescript/utils/animation/derivations.d.ts.map +1 -1
  204. package/lib/typescript/utils/bounds/_types/builder.d.ts +2 -2
  205. package/lib/typescript/utils/bounds/_types/builder.d.ts.map +1 -1
  206. package/lib/typescript/utils/bounds/_utils/geometry.d.ts +2 -2
  207. package/lib/typescript/utils/bounds/_utils/geometry.d.ts.map +1 -1
  208. package/lib/typescript/utils/bounds/_utils/styles.d.ts +2 -1
  209. package/lib/typescript/utils/bounds/_utils/styles.d.ts.map +1 -1
  210. package/lib/typescript/utils/bounds/constants.d.ts +2 -2
  211. package/lib/typescript/utils/bounds/constants.d.ts.map +1 -1
  212. package/lib/typescript/utils/bounds/index.d.ts +4 -4
  213. package/lib/typescript/utils/bounds/index.d.ts.map +1 -1
  214. package/lib/typescript/utils/gesture/apply-offset-rules.d.ts +2 -2
  215. package/lib/typescript/utils/gesture/apply-offset-rules.d.ts.map +1 -1
  216. package/lib/typescript/utils/gesture/check-gesture-activation.d.ts +2 -2
  217. package/lib/typescript/utils/gesture/check-gesture-activation.d.ts.map +1 -1
  218. package/lib/typescript/utils/gesture/reset-gesture-values.d.ts.map +1 -1
  219. package/lib/typescript/utils/gesture/velocity.d.ts +1 -1
  220. package/lib/typescript/utils/gesture/velocity.d.ts.map +1 -1
  221. package/package.json +1 -1
  222. package/src/__configs__/presets.ts +590 -590
  223. package/src/components/root-transition-aware.tsx +27 -27
  224. package/src/constants.ts +47 -47
  225. package/src/hooks/animation/use-screen-animation.tsx +52 -47
  226. package/src/index.ts +33 -22
  227. package/src/integrations/blank-stack/components/Header.tsx +143 -0
  228. package/src/integrations/blank-stack/components/Screens.tsx +96 -0
  229. package/src/integrations/blank-stack/components/StackView.tsx +106 -0
  230. package/src/integrations/blank-stack/navigators/createBlankStackNavigator.tsx +122 -0
  231. package/src/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.tsx +62 -0
  232. package/src/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.tsx +11 -0
  233. package/src/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.tsx +280 -0
  234. package/src/integrations/blank-stack/utils/with-stack-navigation/_types.ts +36 -0
  235. package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.ts +15 -0
  236. package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.ts +29 -0
  237. package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.ts +17 -0
  238. package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.ts +12 -0
  239. package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.ts +11 -0
  240. package/src/integrations/blank-stack/utils/with-stack-navigation/index.tsx +93 -0
  241. package/src/integrations/native-stack/navigators/createNativeStackNavigator.tsx +95 -95
  242. package/src/integrations/native-stack/utils/getModalRoutesKeys.ts +14 -14
  243. package/src/integrations/native-stack/utils/useInvalidPreventRemoveError.tsx +23 -23
  244. package/src/integrations/native-stack/views/NativeStackView.native.tsx +608 -608
  245. package/src/integrations/native-stack/views/NativeStackView.tsx +188 -188
  246. package/src/integrations/native-stack/views/useHeaderConfigProps.tsx +260 -260
  247. package/src/providers/keys.tsx +22 -22
  248. package/src/providers/screen-transition-provider.tsx +20 -20
  249. package/src/providers/transition-styles.tsx +24 -11
  250. package/src/stores/animations.ts +23 -23
  251. package/src/stores/bounds/index.ts +82 -82
  252. package/src/stores/gestures.ts +36 -36
  253. package/src/stores/utils/reset-stores-for-screen.ts +4 -4
  254. package/src/types/animation.ts +2 -4
  255. package/src/types/blank-stack.navigator.ts +271 -0
  256. package/src/types/bounds.ts +0 -64
  257. package/src/types/{navigator.ts → native-stack.navigator.ts} +5 -0
  258. package/src/types/utils.ts +1 -0
  259. package/src/utils/animation/derivations.ts +3 -20
  260. package/src/utils/bounds/_types/builder.ts +111 -111
  261. package/src/utils/bounds/_utils/geometry.ts +2 -2
  262. package/src/utils/bounds/_utils/styles.ts +2 -1
  263. package/src/utils/bounds/constants.ts +29 -29
  264. package/src/utils/bounds/index.ts +35 -105
  265. package/src/utils/gesture/apply-offset-rules.ts +271 -271
  266. package/src/utils/gesture/check-gesture-activation.ts +260 -260
  267. package/src/utils/gesture/reset-gesture-values.ts +1 -0
  268. package/src/utils/gesture/velocity.ts +1 -2
  269. package/lib/module/types/navigator.js +0 -4
  270. package/lib/typescript/types/navigator.d.ts.map +0 -1
@@ -1,628 +1,628 @@
1
1
  import { Platform } from "react-native";
2
2
  import {
3
- Extrapolation,
4
- interpolate,
5
- interpolateColor,
3
+ Extrapolation,
4
+ interpolate,
5
+ interpolateColor,
6
6
  } from "react-native-reanimated";
7
- import type { ScreenTransitionConfig } from "../types/navigator";
7
+ import type { ScreenTransitionConfig } from "../types/native-stack.navigator";
8
8
  import { DefaultSpec } from "./specs";
9
9
 
10
10
  const platform = Platform.OS;
11
11
 
12
12
  export const SlideFromTop = (
13
- config: Partial<ScreenTransitionConfig> = {},
13
+ config: Partial<ScreenTransitionConfig> = {}
14
14
  ): ScreenTransitionConfig => {
15
- return {
16
- enableTransitions: true,
17
- gestureEnabled: true,
18
- gestureDirection: "vertical-inverted",
19
- screenStyleInterpolator: ({
20
- progress,
21
- layouts: {
22
- screen: { height },
23
- },
24
- }) => {
25
- "worklet";
26
-
27
- const y = interpolate(progress, [0, 1, 2], [-height, 0, height]);
28
-
29
- return {
30
- contentStyle: {
31
- transform: [{ translateY: y }],
32
- },
33
- };
34
- },
35
- transitionSpec: {
36
- open: DefaultSpec,
37
- close: DefaultSpec,
38
- },
39
-
40
- ...config,
41
- };
15
+ return {
16
+ enableTransitions: true,
17
+ gestureEnabled: true,
18
+ gestureDirection: "vertical-inverted",
19
+ screenStyleInterpolator: ({
20
+ progress,
21
+ layouts: {
22
+ screen: { height },
23
+ },
24
+ }) => {
25
+ "worklet";
26
+
27
+ const y = interpolate(progress, [0, 1, 2], [-height, 0, height]);
28
+
29
+ return {
30
+ contentStyle: {
31
+ transform: [{ translateY: y }],
32
+ },
33
+ };
34
+ },
35
+ transitionSpec: {
36
+ open: DefaultSpec,
37
+ close: DefaultSpec,
38
+ },
39
+
40
+ ...config,
41
+ };
42
42
  };
43
43
 
44
44
  export const ZoomIn = (
45
- config: Partial<ScreenTransitionConfig> = {},
45
+ config: Partial<ScreenTransitionConfig> = {}
46
46
  ): ScreenTransitionConfig => {
47
- return {
48
- enableTransitions: true,
49
- gestureEnabled: false,
50
- screenStyleInterpolator: ({ progress }) => {
51
- "worklet";
52
-
53
- const scale = interpolate(
54
- progress,
55
- [0, 1, 2],
56
- [0.5, 1, 0.5],
57
- Extrapolation.CLAMP,
58
- );
59
-
60
- const opacity = interpolate(
61
- progress,
62
- [0, 1, 2],
63
- [0, 1, 0],
64
- Extrapolation.CLAMP,
65
- );
66
-
67
- return {
68
- contentStyle: {
69
- transform: [{ scale }],
70
- opacity,
71
- },
72
- };
73
- },
74
- transitionSpec: {
75
- open: DefaultSpec,
76
- close: DefaultSpec,
77
- },
78
- ...config,
79
- };
47
+ return {
48
+ enableTransitions: true,
49
+ gestureEnabled: false,
50
+ screenStyleInterpolator: ({ progress }) => {
51
+ "worklet";
52
+
53
+ const scale = interpolate(
54
+ progress,
55
+ [0, 1, 2],
56
+ [0.5, 1, 0.5],
57
+ Extrapolation.CLAMP
58
+ );
59
+
60
+ const opacity = interpolate(
61
+ progress,
62
+ [0, 1, 2],
63
+ [0, 1, 0],
64
+ Extrapolation.CLAMP
65
+ );
66
+
67
+ return {
68
+ contentStyle: {
69
+ transform: [{ scale }],
70
+ opacity,
71
+ },
72
+ };
73
+ },
74
+ transitionSpec: {
75
+ open: DefaultSpec,
76
+ close: DefaultSpec,
77
+ },
78
+ ...config,
79
+ };
80
80
  };
81
81
 
82
82
  export const SlideFromBottom = (
83
- config: Partial<ScreenTransitionConfig> = {},
83
+ config: Partial<ScreenTransitionConfig> = {}
84
84
  ): ScreenTransitionConfig => {
85
- return {
86
- enableTransitions: true,
87
- gestureEnabled: true,
88
- gestureDirection: "vertical",
89
- screenStyleInterpolator: ({
90
- layouts: {
91
- screen: { height },
92
- },
93
- progress,
94
- }) => {
95
- "worklet";
96
-
97
- const y = interpolate(progress, [0, 1, 2], [height, 0, -height]);
98
-
99
- return {
100
- contentStyle: {
101
- transform: [{ translateY: y }],
102
- },
103
- };
104
- },
105
- transitionSpec: {
106
- open: DefaultSpec,
107
- close: DefaultSpec,
108
- },
109
- ...config,
110
- };
85
+ return {
86
+ enableTransitions: true,
87
+ gestureEnabled: true,
88
+ gestureDirection: "vertical",
89
+ screenStyleInterpolator: ({
90
+ layouts: {
91
+ screen: { height },
92
+ },
93
+ progress,
94
+ }) => {
95
+ "worklet";
96
+
97
+ const y = interpolate(progress, [0, 1, 2], [height, 0, -height]);
98
+
99
+ return {
100
+ contentStyle: {
101
+ transform: [{ translateY: y }],
102
+ },
103
+ };
104
+ },
105
+ transitionSpec: {
106
+ open: DefaultSpec,
107
+ close: DefaultSpec,
108
+ },
109
+ ...config,
110
+ };
111
111
  };
112
112
 
113
113
  export const DraggableCard = (
114
- config: Partial<ScreenTransitionConfig> = {},
114
+ config: Partial<ScreenTransitionConfig> = {}
115
115
  ): ScreenTransitionConfig => {
116
- return {
117
- enableTransitions: true,
118
- gestureEnabled: true,
119
- gestureDirection: ["horizontal", "vertical"],
120
- screenStyleInterpolator: ({ current, progress, layouts: { screen } }) => {
121
- "worklet";
122
-
123
- /** Combined */
124
- const scale = interpolate(progress, [0, 1, 2], [0, 1, 0.75]);
125
-
126
- /** Vertical */
127
- const translateY = interpolate(
128
- current.gesture.normalizedY,
129
- [-1, 1],
130
- [-screen.height * 0.5, screen.height * 0.5],
131
- "clamp",
132
- );
133
-
134
- /** Horizontal */
135
- const translateX = interpolate(
136
- current.gesture.normalizedX,
137
- [-1, 1],
138
- [-screen.width * 0.5, screen.width * 0.5],
139
- "clamp",
140
- );
141
-
142
- return {
143
- contentStyle: {
144
- transform: [{ scale }, { translateY: translateY }, { translateX }],
145
- },
146
- };
147
- },
148
- transitionSpec: {
149
- open: DefaultSpec,
150
- close: DefaultSpec,
151
- },
152
- ...config,
153
- };
116
+ return {
117
+ enableTransitions: true,
118
+ gestureEnabled: true,
119
+ gestureDirection: ["horizontal", "vertical"],
120
+ screenStyleInterpolator: ({ current, progress, layouts: { screen } }) => {
121
+ "worklet";
122
+
123
+ /** Combined */
124
+ const scale = interpolate(progress, [0, 1, 2], [0, 1, 0.75]);
125
+
126
+ /** Vertical */
127
+ const translateY = interpolate(
128
+ current.gesture.normalizedY,
129
+ [-1, 1],
130
+ [-screen.height * 0.5, screen.height * 0.5],
131
+ "clamp"
132
+ );
133
+
134
+ /** Horizontal */
135
+ const translateX = interpolate(
136
+ current.gesture.normalizedX,
137
+ [-1, 1],
138
+ [-screen.width * 0.5, screen.width * 0.5],
139
+ "clamp"
140
+ );
141
+
142
+ return {
143
+ contentStyle: {
144
+ transform: [{ scale }, { translateY: translateY }, { translateX }],
145
+ },
146
+ };
147
+ },
148
+ transitionSpec: {
149
+ open: DefaultSpec,
150
+ close: DefaultSpec,
151
+ },
152
+ ...config,
153
+ };
154
154
  };
155
155
 
156
156
  export const ElasticCard = (
157
- config: Partial<ScreenTransitionConfig> & {
158
- elasticFactor?: number;
159
- } = { elasticFactor: 0.5 },
157
+ config: Partial<ScreenTransitionConfig> & {
158
+ elasticFactor?: number;
159
+ } = { elasticFactor: 0.5 }
160
160
  ): ScreenTransitionConfig => {
161
- return {
162
- enableTransitions: true,
163
- gestureEnabled: true,
164
- gestureDirection: "bidirectional",
165
- screenStyleInterpolator: ({
166
- current,
167
- next,
168
- layouts: { screen },
169
- progress,
170
- }) => {
171
- "worklet";
172
-
173
- /**
174
- * Applies to both screens ( previous and incoming)
175
- */
176
- const scale = interpolate(progress, [0, 1, 2], [0, 1, 0.8]);
177
-
178
- // applies to current screen
179
- const maxElasticityX = screen.width * (config.elasticFactor ?? 0.5);
180
- const maxElasticityY = screen.height * (config.elasticFactor ?? 0.5);
181
- const translateX = interpolate(
182
- current.gesture.normalizedX,
183
- [-1, 0, 1],
184
- [-maxElasticityX, 0, maxElasticityX],
185
- "clamp",
186
- );
187
-
188
- const translateY = interpolate(
189
- current.gesture.normalizedY,
190
- [-1, 0, 1],
191
- [-maxElasticityY, 0, maxElasticityY],
192
- "clamp",
193
- );
194
-
195
- // applies to unfocused screen ( previous screen )
196
- const overlayColor = interpolateColor(
197
- progress,
198
- [0, 1],
199
- ["rgba(0,0,0,0)", "rgba(0,0,0,0.5)"],
200
- );
201
-
202
- return {
203
- contentStyle: {
204
- transform: [{ scale }, { translateX }, { translateY }],
205
- },
206
- overlayStyle: {
207
- backgroundColor: !next ? overlayColor : "rgba(0,0,0,0)",
208
- },
209
- };
210
- },
211
- transitionSpec: {
212
- open: DefaultSpec,
213
- close: DefaultSpec,
214
- },
215
- ...config,
216
- };
161
+ return {
162
+ enableTransitions: true,
163
+ gestureEnabled: true,
164
+ gestureDirection: "bidirectional",
165
+ screenStyleInterpolator: ({
166
+ current,
167
+ next,
168
+ layouts: { screen },
169
+ progress,
170
+ }) => {
171
+ "worklet";
172
+
173
+ /**
174
+ * Applies to both screens ( previous and incoming)
175
+ */
176
+ const scale = interpolate(progress, [0, 1, 2], [0, 1, 0.8]);
177
+
178
+ // applies to current screen
179
+ const maxElasticityX = screen.width * (config.elasticFactor ?? 0.5);
180
+ const maxElasticityY = screen.height * (config.elasticFactor ?? 0.5);
181
+ const translateX = interpolate(
182
+ current.gesture.normalizedX,
183
+ [-1, 0, 1],
184
+ [-maxElasticityX, 0, maxElasticityX],
185
+ "clamp"
186
+ );
187
+
188
+ const translateY = interpolate(
189
+ current.gesture.normalizedY,
190
+ [-1, 0, 1],
191
+ [-maxElasticityY, 0, maxElasticityY],
192
+ "clamp"
193
+ );
194
+
195
+ // applies to unfocused screen ( previous screen )
196
+ const overlayColor = interpolateColor(
197
+ progress,
198
+ [0, 1],
199
+ ["rgba(0,0,0,0)", "rgba(0,0,0,0.5)"]
200
+ );
201
+
202
+ return {
203
+ contentStyle: {
204
+ transform: [{ scale }, { translateX }, { translateY }],
205
+ },
206
+ overlayStyle: {
207
+ backgroundColor: !next ? overlayColor : "rgba(0,0,0,0)",
208
+ },
209
+ };
210
+ },
211
+ transitionSpec: {
212
+ open: DefaultSpec,
213
+ close: DefaultSpec,
214
+ },
215
+ ...config,
216
+ };
217
217
  };
218
218
 
219
219
  export const SharedIGImage = (
220
- config: Partial<ScreenTransitionConfig> = {},
220
+ config: Partial<ScreenTransitionConfig> = {}
221
221
  ): ScreenTransitionConfig => {
222
- return {
223
- gestureEnabled: true,
224
- gestureDirection: ["vertical", "horizontal"],
225
- enableTransitions: true,
226
- gestureDrivesProgress: false,
227
- screenStyleInterpolator: ({
228
- current,
229
- layouts: {
230
- screen: { height, width },
231
- },
232
- bounds,
233
- progress,
234
- focused,
235
- activeBoundId,
236
- active,
237
- }) => {
238
- "worklet";
239
-
240
- const normX = active.gesture.normalizedX;
241
- const normY = active.gesture.normalizedY;
242
-
243
- // animations for both bounds
244
- const dragX = interpolate(
245
- normX,
246
- [-1, 0, 1],
247
- [-width * 0.7, 0, width * 0.7],
248
- "clamp",
249
- );
250
- const dragY = interpolate(
251
- normY,
252
- [-1, 0, 1],
253
- [-height * 0.4, 0, height * 0.4],
254
- "clamp",
255
- );
256
- const dragXScale = interpolate(normX, [0, 1], [1, 0.8]);
257
- const dragYScale = interpolate(normY, [0, 1], [1, 0.8]);
258
-
259
- const boundValues = bounds({
260
- method: focused ? "content" : "transform",
261
- scaleMode: "uniform",
262
- raw: true,
263
- });
264
-
265
- // focused specific animations
266
- if (focused) {
267
- const maskedValues = bounds({
268
- space: "absolute",
269
- target: "fullscreen",
270
- method: "size",
271
- raw: true,
272
- });
273
-
274
- return {
275
- overlayStyle: {
276
- backgroundColor: "black",
277
- opacity: interpolate(progress, [0, 1], [0, 0.5]),
278
- },
279
- contentStyle: {
280
- transform: [
281
- { translateX: dragX },
282
- { translateY: dragY },
283
- { scale: dragXScale },
284
- { scale: dragYScale },
285
- ],
286
- },
287
-
288
- _ROOT_CONTAINER: {
289
- transform: [
290
- { translateX: boundValues.translateX || 0 },
291
- { translateY: boundValues.translateY || 0 },
292
- //@ts-expect-error
293
- { scale: boundValues.scale || 1 },
294
- ],
295
- },
296
- _ROOT_MASKED: {
297
- width: maskedValues.width,
298
- height: maskedValues.height,
299
- transform: [
300
- { translateX: maskedValues.translateX || 0 },
301
- { translateY: maskedValues.translateY || 0 },
302
- ],
303
- borderRadius: interpolate(progress, [0, 1], [0, 24]),
304
- },
305
- };
306
- }
307
-
308
- return {
309
- contentStyle: {
310
- pointerEvents: current.gesture.isDismissing ? "none" : "auto",
311
- },
312
- [activeBoundId]: {
313
- transform: [
314
- { translateX: dragX || 0 },
315
- { translateY: dragY || 0 },
316
- { translateX: boundValues.translateX || 0 },
317
- { translateY: boundValues.translateY || 0 },
318
- { scaleX: boundValues.scaleX || 1 },
319
- { scaleY: boundValues.scaleY || 1 },
320
- { scale: dragXScale },
321
- { scale: dragYScale },
322
- ],
323
- },
324
- };
325
- },
326
- transitionSpec: {
327
- open: {
328
- stiffness: 1500,
329
- damping: 1000,
330
- mass: 3,
331
- overshootClamping: true,
332
- //@ts-expect-error
333
- restSpeedThreshold: 0.02,
334
- },
335
- close: {
336
- stiffness: 1500,
337
- damping: 1000,
338
- mass: 3,
339
- overshootClamping: true,
340
- //@ts-expect-error
341
- restSpeedThreshold: 0.02,
342
- },
343
- },
344
- ...config,
345
- };
222
+ return {
223
+ gestureEnabled: true,
224
+ gestureDirection: ["vertical", "horizontal"],
225
+ enableTransitions: true,
226
+ gestureDrivesProgress: false,
227
+ screenStyleInterpolator: ({
228
+ current,
229
+ layouts: {
230
+ screen: { height, width },
231
+ },
232
+ bounds,
233
+ progress,
234
+ focused,
235
+ activeBoundId,
236
+ active,
237
+ }) => {
238
+ "worklet";
239
+
240
+ const normX = active.gesture.normalizedX;
241
+ const normY = active.gesture.normalizedY;
242
+
243
+ // animations for both bounds
244
+ const dragX = interpolate(
245
+ normX,
246
+ [-1, 0, 1],
247
+ [-width * 0.7, 0, width * 0.7],
248
+ "clamp"
249
+ );
250
+ const dragY = interpolate(
251
+ normY,
252
+ [-1, 0, 1],
253
+ [-height * 0.4, 0, height * 0.4],
254
+ "clamp"
255
+ );
256
+ const dragXScale = interpolate(normX, [0, 1], [1, 0.8]);
257
+ const dragYScale = interpolate(normY, [0, 1], [1, 0.8]);
258
+
259
+ const boundValues = bounds({
260
+ method: focused ? "content" : "transform",
261
+ scaleMode: "uniform",
262
+ raw: true,
263
+ });
264
+
265
+ // focused specific animations
266
+ if (focused) {
267
+ const maskedValues = bounds({
268
+ space: "absolute",
269
+ target: "fullscreen",
270
+ method: "size",
271
+ raw: true,
272
+ });
273
+
274
+ return {
275
+ overlayStyle: {
276
+ backgroundColor: "black",
277
+ opacity: interpolate(progress, [0, 1], [0, 0.5]),
278
+ },
279
+ contentStyle: {
280
+ transform: [
281
+ { translateX: dragX },
282
+ { translateY: dragY },
283
+ { scale: dragXScale },
284
+ { scale: dragYScale },
285
+ ],
286
+ },
287
+
288
+ _ROOT_CONTAINER: {
289
+ transform: [
290
+ { translateX: boundValues.translateX || 0 },
291
+ { translateY: boundValues.translateY || 0 },
292
+ //@ts-expect-error
293
+ { scale: boundValues.scale || 1 },
294
+ ],
295
+ },
296
+ _ROOT_MASKED: {
297
+ width: maskedValues.width,
298
+ height: maskedValues.height,
299
+ transform: [
300
+ { translateX: maskedValues.translateX || 0 },
301
+ { translateY: maskedValues.translateY || 0 },
302
+ ],
303
+ borderRadius: interpolate(progress, [0, 1], [0, 24]),
304
+ },
305
+ };
306
+ }
307
+
308
+ return {
309
+ contentStyle: {
310
+ pointerEvents: current.gesture.isDismissing ? "none" : "auto",
311
+ },
312
+ [activeBoundId]: {
313
+ transform: [
314
+ { translateX: dragX || 0 },
315
+ { translateY: dragY || 0 },
316
+ { translateX: boundValues.translateX || 0 },
317
+ { translateY: boundValues.translateY || 0 },
318
+ { scaleX: boundValues.scaleX || 1 },
319
+ { scaleY: boundValues.scaleY || 1 },
320
+ { scale: dragXScale },
321
+ { scale: dragYScale },
322
+ ],
323
+ },
324
+ };
325
+ },
326
+ transitionSpec: {
327
+ open: {
328
+ stiffness: 1500,
329
+ damping: 1000,
330
+ mass: 3,
331
+ overshootClamping: true,
332
+ //@ts-expect-error
333
+ restSpeedThreshold: 0.02,
334
+ },
335
+ close: {
336
+ stiffness: 1500,
337
+ damping: 1000,
338
+ mass: 3,
339
+ overshootClamping: true,
340
+ //@ts-expect-error
341
+ restSpeedThreshold: 0.02,
342
+ },
343
+ },
344
+ ...config,
345
+ };
346
346
  };
347
347
 
348
348
  export const SharedAppleMusic = (
349
- config: Partial<ScreenTransitionConfig> = {},
349
+ config: Partial<ScreenTransitionConfig> = {}
350
350
  ): ScreenTransitionConfig => {
351
- return {
352
- enableTransitions: true,
353
- gestureEnabled: true,
354
- gestureDirection: ["vertical", "horizontal"],
355
- gestureDrivesProgress: false,
356
- screenStyleInterpolator: ({
357
- bounds,
358
- activeBoundId,
359
- focused,
360
- progress,
361
- layouts: { screen },
362
- current,
363
- active,
364
- }) => {
365
- "worklet";
366
-
367
- const normX = active.gesture.normalizedX;
368
- const normY = active.gesture.normalizedY;
369
- const initialDirection = active.gesture.direction;
370
-
371
- /**
372
- * ===============================
373
- * Animations for both bounds
374
- * ===============================
375
- */
376
- const xResistance = initialDirection === "horizontal" ? 0.7 : 0.4;
377
- const yResistance = initialDirection === "vertical" ? 0.7 : 0.4;
378
-
379
- const xScaleOuput = initialDirection === "horizontal" ? [1, 0.5] : [1, 1];
380
- const yScaleOuput = initialDirection === "vertical" ? [1, 0.5] : [1, 1];
381
-
382
- const dragX = interpolate(
383
- normX,
384
- [-1, 0, 1],
385
- [-screen.width * xResistance, 0, screen.width * xResistance],
386
- "clamp",
387
- );
388
- const dragY = interpolate(
389
- normY,
390
- [-1, 0, 1],
391
- [-screen.height * yResistance, 0, screen.height * yResistance],
392
- "clamp",
393
- );
394
- const dragXScale = interpolate(normX, [0, 1], xScaleOuput);
395
- const dragYScale = interpolate(normY, [0, 1], yScaleOuput);
396
-
397
- const boundValues = bounds({
398
- method: focused ? "content" : "transform",
399
- anchor: "top",
400
- scaleMode: "uniform",
401
- raw: true,
402
- });
403
-
404
- const opacity = interpolate(
405
- progress,
406
- [0, 0.25, 1.25, 2],
407
- [0, 1, 1, 0],
408
- "clamp",
409
- );
410
-
411
- /**
412
- * ===============================
413
- * Focused specific animations
414
- * ===============================
415
- */
416
- if (focused) {
417
- const maskedValues = bounds({
418
- space: "absolute",
419
- method: "size",
420
- target: "fullscreen",
421
- raw: true,
422
- });
423
-
424
- // Apple Music style drop shadow that increases with drag magnitude
425
- const dragMagnitude = Math.max(Math.abs(normX), Math.abs(normY));
426
- const shadowOpacity = interpolate(
427
- dragMagnitude,
428
- [0, 1],
429
- [0, 0.25],
430
- "clamp",
431
- );
432
- const shadowRadius = interpolate(
433
- dragMagnitude,
434
- [0, 1],
435
- [0, 24],
436
- "clamp",
437
- );
438
- const shadowOffsetY = interpolate(
439
- dragMagnitude,
440
- [0, 1],
441
- [0, 20],
442
- "clamp",
443
- );
444
- const elevation = interpolate(dragMagnitude, [0, 1], [0, 24], "clamp");
445
-
446
- const IOSShadowStyle = {
447
- shadowColor: "#000",
448
- shadowOpacity,
449
- shadowRadius,
450
- shadowOffset: { width: 0, height: shadowOffsetY },
451
- };
452
-
453
- const AndroidShadowStyle = {
454
- elevation,
455
- shadowColor: "#000",
456
- };
457
-
458
- return {
459
- contentStyle: {
460
- pointerEvents: current.animating ? "none" : "auto",
461
- transform: [
462
- { translateX: dragX || 0 },
463
- { translateY: dragY || 0 },
464
- { scale: dragXScale },
465
- { scale: dragYScale },
466
- ],
467
- opacity,
468
- ...(platform === "ios" ? IOSShadowStyle : AndroidShadowStyle),
469
- },
470
- _ROOT_CONTAINER: {
471
- transform: [
472
- { translateX: boundValues.translateX || 0 },
473
- { translateY: boundValues.translateY || 0 },
474
- //@ts-expect-error
475
- { scale: boundValues.scale || 1 },
476
- ],
477
- },
478
- _ROOT_MASKED: {
479
- width: maskedValues.width,
480
- height: maskedValues.height,
481
- transform: [
482
- { translateX: maskedValues.translateX || 0 },
483
- { translateY: maskedValues.translateY || 0 },
484
- ],
485
- borderRadius: interpolate(progress, [0, 1], [0, 24]),
486
- },
487
- };
488
- }
489
-
490
- /**
491
- * ===============================
492
- * Unfocused specific animations
493
- * ===============================
494
- */
495
-
496
- const scaledBoundTranslateX = (boundValues.translateX || 0) * dragXScale;
497
- const scaledBoundTranslateY = (boundValues.translateY || 0) * dragYScale;
498
- const scaledBoundScaleX = (boundValues.scaleX || 1) * dragXScale;
499
- const scaledBoundScaleY = (boundValues.scaleY || 1) * dragYScale;
500
-
501
- const contentScale = interpolate(progress, [1, 2], [1, 0.9], "clamp");
502
-
503
- return {
504
- [activeBoundId]: {
505
- transform: [
506
- { translateX: dragX || 0 },
507
- { translateY: dragY || 0 },
508
- { translateX: scaledBoundTranslateX },
509
- { translateY: scaledBoundTranslateY },
510
- { scale: dragXScale },
511
- { scale: dragYScale },
512
- { scaleX: scaledBoundScaleX },
513
- { scaleY: scaledBoundScaleY },
514
- ],
515
- opacity,
516
- zIndex: current.animating ? 999 : -1,
517
- position: "relative",
518
- },
519
- contentStyle: {
520
- transform: [{ scale: contentScale }],
521
- },
522
- };
523
- },
524
- transitionSpec: {
525
- open: {
526
- stiffness: 1000,
527
- damping: 500,
528
- mass: 3,
529
- overshootClamping: true,
530
- //@ts-expect-error
531
- restSpeedThreshold: 0.02,
532
- },
533
- close: {
534
- stiffness: 600,
535
- damping: 60,
536
- mass: 4,
537
- overshootClamping: false,
538
- //@ts-expect-error
539
- restSpeedThreshold: 0.02,
540
- restDisplacementThreshold: 0.002,
541
- },
542
- },
543
- ...config,
544
- };
351
+ return {
352
+ enableTransitions: true,
353
+ gestureEnabled: true,
354
+ gestureDirection: ["vertical", "horizontal"],
355
+ gestureDrivesProgress: false,
356
+ screenStyleInterpolator: ({
357
+ bounds,
358
+ activeBoundId,
359
+ focused,
360
+ progress,
361
+ layouts: { screen },
362
+ current,
363
+ active,
364
+ }) => {
365
+ "worklet";
366
+
367
+ const normX = active.gesture.normalizedX;
368
+ const normY = active.gesture.normalizedY;
369
+ const initialDirection = active.gesture.direction;
370
+
371
+ /**
372
+ * ===============================
373
+ * Animations for both bounds
374
+ * ===============================
375
+ */
376
+ const xResistance = initialDirection === "horizontal" ? 0.7 : 0.4;
377
+ const yResistance = initialDirection === "vertical" ? 0.7 : 0.4;
378
+
379
+ const xScaleOuput = initialDirection === "horizontal" ? [1, 0.5] : [1, 1];
380
+ const yScaleOuput = initialDirection === "vertical" ? [1, 0.5] : [1, 1];
381
+
382
+ const dragX = interpolate(
383
+ normX,
384
+ [-1, 0, 1],
385
+ [-screen.width * xResistance, 0, screen.width * xResistance],
386
+ "clamp"
387
+ );
388
+ const dragY = interpolate(
389
+ normY,
390
+ [-1, 0, 1],
391
+ [-screen.height * yResistance, 0, screen.height * yResistance],
392
+ "clamp"
393
+ );
394
+ const dragXScale = interpolate(normX, [0, 1], xScaleOuput);
395
+ const dragYScale = interpolate(normY, [0, 1], yScaleOuput);
396
+
397
+ const boundValues = bounds({
398
+ method: focused ? "content" : "transform",
399
+ anchor: "top",
400
+ scaleMode: "uniform",
401
+ raw: true,
402
+ });
403
+
404
+ const opacity = interpolate(
405
+ progress,
406
+ [0, 0.25, 1.25, 2],
407
+ [0, 1, 1, 0],
408
+ "clamp"
409
+ );
410
+
411
+ /**
412
+ * ===============================
413
+ * Focused specific animations
414
+ * ===============================
415
+ */
416
+ if (focused) {
417
+ const maskedValues = bounds({
418
+ space: "absolute",
419
+ method: "size",
420
+ target: "fullscreen",
421
+ raw: true,
422
+ });
423
+
424
+ // Apple Music style drop shadow that increases with drag magnitude
425
+ const dragMagnitude = Math.max(Math.abs(normX), Math.abs(normY));
426
+ const shadowOpacity = interpolate(
427
+ dragMagnitude,
428
+ [0, 1],
429
+ [0, 0.25],
430
+ "clamp"
431
+ );
432
+ const shadowRadius = interpolate(
433
+ dragMagnitude,
434
+ [0, 1],
435
+ [0, 24],
436
+ "clamp"
437
+ );
438
+ const shadowOffsetY = interpolate(
439
+ dragMagnitude,
440
+ [0, 1],
441
+ [0, 20],
442
+ "clamp"
443
+ );
444
+ const elevation = interpolate(dragMagnitude, [0, 1], [0, 24], "clamp");
445
+
446
+ const IOSShadowStyle = {
447
+ shadowColor: "#000",
448
+ shadowOpacity,
449
+ shadowRadius,
450
+ shadowOffset: { width: 0, height: shadowOffsetY },
451
+ };
452
+
453
+ const AndroidShadowStyle = {
454
+ elevation,
455
+ shadowColor: "#000",
456
+ };
457
+
458
+ return {
459
+ contentStyle: {
460
+ pointerEvents: current.animating ? "none" : "auto",
461
+ transform: [
462
+ { translateX: dragX || 0 },
463
+ { translateY: dragY || 0 },
464
+ { scale: dragXScale },
465
+ { scale: dragYScale },
466
+ ],
467
+ opacity,
468
+ ...(platform === "ios" ? IOSShadowStyle : AndroidShadowStyle),
469
+ },
470
+ _ROOT_CONTAINER: {
471
+ transform: [
472
+ { translateX: boundValues.translateX || 0 },
473
+ { translateY: boundValues.translateY || 0 },
474
+ //@ts-expect-error
475
+ { scale: boundValues.scale || 1 },
476
+ ],
477
+ },
478
+ _ROOT_MASKED: {
479
+ width: maskedValues.width,
480
+ height: maskedValues.height,
481
+ transform: [
482
+ { translateX: maskedValues.translateX || 0 },
483
+ { translateY: maskedValues.translateY || 0 },
484
+ ],
485
+ borderRadius: interpolate(progress, [0, 1], [0, 24]),
486
+ },
487
+ };
488
+ }
489
+
490
+ /**
491
+ * ===============================
492
+ * Unfocused specific animations
493
+ * ===============================
494
+ */
495
+
496
+ const scaledBoundTranslateX = (boundValues.translateX || 0) * dragXScale;
497
+ const scaledBoundTranslateY = (boundValues.translateY || 0) * dragYScale;
498
+ const scaledBoundScaleX = (boundValues.scaleX || 1) * dragXScale;
499
+ const scaledBoundScaleY = (boundValues.scaleY || 1) * dragYScale;
500
+
501
+ const contentScale = interpolate(progress, [1, 2], [1, 0.9], "clamp");
502
+
503
+ return {
504
+ [activeBoundId]: {
505
+ transform: [
506
+ { translateX: dragX || 0 },
507
+ { translateY: dragY || 0 },
508
+ { translateX: scaledBoundTranslateX },
509
+ { translateY: scaledBoundTranslateY },
510
+ { scale: dragXScale },
511
+ { scale: dragYScale },
512
+ { scaleX: scaledBoundScaleX },
513
+ { scaleY: scaledBoundScaleY },
514
+ ],
515
+ opacity,
516
+ zIndex: current.animating ? 999 : -1,
517
+ position: "relative",
518
+ },
519
+ contentStyle: {
520
+ transform: [{ scale: contentScale }],
521
+ },
522
+ };
523
+ },
524
+ transitionSpec: {
525
+ open: {
526
+ stiffness: 1000,
527
+ damping: 500,
528
+ mass: 3,
529
+ overshootClamping: true,
530
+ //@ts-expect-error
531
+ restSpeedThreshold: 0.02,
532
+ },
533
+ close: {
534
+ stiffness: 600,
535
+ damping: 60,
536
+ mass: 4,
537
+ overshootClamping: false,
538
+ //@ts-expect-error
539
+ restSpeedThreshold: 0.02,
540
+ restDisplacementThreshold: 0.002,
541
+ },
542
+ },
543
+ ...config,
544
+ };
545
545
  };
546
546
 
547
547
  export const SharedXImage = (
548
- config: Partial<ScreenTransitionConfig> = {},
548
+ config: Partial<ScreenTransitionConfig> = {}
549
549
  ): ScreenTransitionConfig => {
550
- return {
551
- enableTransitions: true,
552
- gestureEnabled: true,
553
- gestureDirection: ["vertical", "vertical-inverted"],
554
- gestureDrivesProgress: false,
555
- screenStyleInterpolator: ({
556
- focused,
557
- activeBoundId,
558
- bounds,
559
- current,
560
- layouts: { screen },
561
- progress,
562
- }) => {
563
- "worklet";
564
-
565
- // twitter doesn't animate the unfocused screen
566
- if (!focused) return {};
567
-
568
- const boundValues = bounds({ method: "transform", raw: true });
569
-
570
- // content styles
571
- const dragY = interpolate(
572
- current.gesture.normalizedY,
573
- [-1, 0, 1],
574
- [-screen.height, 0, screen.height],
575
- );
576
-
577
- // dynamically changes direction based on the drag direction
578
- const contentY = interpolate(
579
- progress,
580
- [0, 1],
581
- [dragY >= 0 ? screen.height : -screen.height, 0],
582
- );
583
-
584
- const overlayClr = interpolateColor(
585
- current.progress - Math.abs(current.gesture.normalizedY),
586
- [0, 1],
587
- ["rgba(0,0,0,0)", "rgba(0,0,0,1)"],
588
- );
589
-
590
- const borderRadius = interpolate(current.progress, [0, 1], [12, 0]);
591
-
592
- // bound styles - only enter animation
593
- const x = !current.closing ? boundValues.translateX : 0;
594
- const y = !current.closing ? boundValues.translateY : 0;
595
- const scaleX = !current.closing ? boundValues.scaleX : 1;
596
- const scaleY = !current.closing ? boundValues.scaleY : 1;
597
-
598
- return {
599
- [activeBoundId]: {
600
- transform: [
601
- {
602
- translateX: x,
603
- },
604
- {
605
- translateY: y,
606
- },
607
- { scaleX: scaleX },
608
- { scaleY: scaleY },
609
- ],
610
- borderRadius,
611
- overflow: "hidden",
612
- },
613
- contentStyle: {
614
- transform: [{ translateY: contentY }, { translateY: dragY }],
615
- pointerEvents: current.animating ? "none" : "auto",
616
- },
617
- overlayStyle: {
618
- backgroundColor: overlayClr,
619
- },
620
- };
621
- },
622
- transitionSpec: {
623
- open: DefaultSpec,
624
- close: DefaultSpec,
625
- },
626
- ...config,
627
- };
550
+ return {
551
+ enableTransitions: true,
552
+ gestureEnabled: true,
553
+ gestureDirection: ["vertical", "vertical-inverted"],
554
+ gestureDrivesProgress: false,
555
+ screenStyleInterpolator: ({
556
+ focused,
557
+ activeBoundId,
558
+ bounds,
559
+ current,
560
+ layouts: { screen },
561
+ progress,
562
+ }) => {
563
+ "worklet";
564
+
565
+ // twitter doesn't animate the unfocused screen
566
+ if (!focused) return {};
567
+
568
+ const boundValues = bounds({ method: "transform", raw: true });
569
+
570
+ // content styles
571
+ const dragY = interpolate(
572
+ current.gesture.normalizedY,
573
+ [-1, 0, 1],
574
+ [-screen.height, 0, screen.height]
575
+ );
576
+
577
+ // dynamically changes direction based on the drag direction
578
+ const contentY = interpolate(
579
+ progress,
580
+ [0, 1],
581
+ [dragY >= 0 ? screen.height : -screen.height, 0]
582
+ );
583
+
584
+ const overlayClr = interpolateColor(
585
+ current.progress - Math.abs(current.gesture.normalizedY),
586
+ [0, 1],
587
+ ["rgba(0,0,0,0)", "rgba(0,0,0,1)"]
588
+ );
589
+
590
+ const borderRadius = interpolate(current.progress, [0, 1], [12, 0]);
591
+
592
+ // bound styles - only enter animation
593
+ const x = !current.closing ? boundValues.translateX : 0;
594
+ const y = !current.closing ? boundValues.translateY : 0;
595
+ const scaleX = !current.closing ? boundValues.scaleX : 1;
596
+ const scaleY = !current.closing ? boundValues.scaleY : 1;
597
+
598
+ return {
599
+ [activeBoundId]: {
600
+ transform: [
601
+ {
602
+ translateX: x,
603
+ },
604
+ {
605
+ translateY: y,
606
+ },
607
+ { scaleX: scaleX },
608
+ { scaleY: scaleY },
609
+ ],
610
+ borderRadius,
611
+ overflow: "hidden",
612
+ },
613
+ contentStyle: {
614
+ transform: [{ translateY: contentY }, { translateY: dragY }],
615
+ pointerEvents: current.animating ? "none" : "auto",
616
+ },
617
+ overlayStyle: {
618
+ backgroundColor: overlayClr,
619
+ },
620
+ };
621
+ },
622
+ transitionSpec: {
623
+ open: DefaultSpec,
624
+ close: DefaultSpec,
625
+ },
626
+ ...config,
627
+ };
628
628
  };