react-native-screen-transitions 1.2.0 → 2.0.1

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 (344) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +211 -156
  3. package/lib/commonjs/__tests__ /geometry.test.js +178 -0
  4. package/lib/commonjs/__tests__ /geometry.test.js.map +1 -0
  5. package/lib/commonjs/components/bounds-activator.js +33 -0
  6. package/lib/commonjs/components/bounds-activator.js.map +1 -0
  7. package/lib/commonjs/components/controllers/screen-lifecycle.js +66 -0
  8. package/lib/commonjs/components/controllers/screen-lifecycle.js.map +1 -0
  9. package/lib/commonjs/components/create-transition-aware-component.js +96 -0
  10. package/lib/commonjs/components/create-transition-aware-component.js.map +1 -0
  11. package/lib/commonjs/components/root-transition-aware.js +56 -0
  12. package/lib/commonjs/components/root-transition-aware.js.map +1 -0
  13. package/lib/commonjs/configs/index.js +12 -0
  14. package/lib/commonjs/configs/index.js.map +1 -0
  15. package/lib/commonjs/configs/presets.js +206 -0
  16. package/lib/commonjs/configs/presets.js.map +1 -0
  17. package/lib/commonjs/configs/specs.js +14 -0
  18. package/lib/commonjs/configs/specs.js.map +1 -0
  19. package/lib/commonjs/hooks/animation/use-associated-style.js +36 -0
  20. package/lib/commonjs/hooks/animation/use-associated-style.js.map +1 -0
  21. package/lib/commonjs/hooks/animation/use-screen-animation.js +120 -0
  22. package/lib/commonjs/hooks/animation/use-screen-animation.js.map +1 -0
  23. package/lib/commonjs/hooks/bounds/use-bound-measurer.js +52 -0
  24. package/lib/commonjs/hooks/bounds/use-bound-measurer.js.map +1 -0
  25. package/lib/commonjs/hooks/gestures/use-build-gestures.js +239 -0
  26. package/lib/commonjs/hooks/gestures/use-build-gestures.js.map +1 -0
  27. package/lib/commonjs/hooks/gestures/use-scroll-progress.js +57 -0
  28. package/lib/commonjs/hooks/gestures/use-scroll-progress.js.map +1 -0
  29. package/lib/commonjs/hooks/use-stable-callback.js +17 -0
  30. package/lib/commonjs/hooks/use-stable-callback.js.map +1 -0
  31. package/lib/commonjs/index.js +37 -0
  32. package/lib/commonjs/index.js.map +1 -0
  33. package/lib/commonjs/integrations/native-stack/navigators/createNativeStackNavigator.js +68 -0
  34. package/lib/commonjs/integrations/native-stack/navigators/createNativeStackNavigator.js.map +1 -0
  35. package/lib/commonjs/integrations/native-stack/utils/debounce.js +16 -0
  36. package/lib/commonjs/integrations/native-stack/utils/debounce.js.map +1 -0
  37. package/lib/commonjs/integrations/native-stack/utils/getModalRoutesKeys.js +17 -0
  38. package/lib/commonjs/integrations/native-stack/utils/getModalRoutesKeys.js.map +1 -0
  39. package/lib/commonjs/integrations/native-stack/utils/useAnimatedHeaderHeight.js +18 -0
  40. package/lib/commonjs/integrations/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -0
  41. package/lib/commonjs/integrations/native-stack/utils/useDismissedRouteError.js +22 -0
  42. package/lib/commonjs/integrations/native-stack/utils/useDismissedRouteError.js.map +1 -0
  43. package/lib/commonjs/integrations/native-stack/utils/useInvalidPreventRemoveError.js +25 -0
  44. package/lib/commonjs/integrations/native-stack/utils/useInvalidPreventRemoveError.js.map +1 -0
  45. package/lib/commonjs/integrations/native-stack/views/FontProcessor.js +10 -0
  46. package/lib/commonjs/integrations/native-stack/views/FontProcessor.js.map +1 -0
  47. package/lib/commonjs/integrations/native-stack/views/FontProcessor.native.js +18 -0
  48. package/lib/commonjs/integrations/native-stack/views/FontProcessor.native.js.map +1 -0
  49. package/lib/commonjs/integrations/native-stack/views/FooterComponent.js +17 -0
  50. package/lib/commonjs/integrations/native-stack/views/FooterComponent.js.map +1 -0
  51. package/lib/commonjs/integrations/native-stack/views/NativeStackView.js +138 -0
  52. package/lib/commonjs/integrations/native-stack/views/NativeStackView.js.map +1 -0
  53. package/lib/commonjs/integrations/native-stack/views/NativeStackView.native.js +497 -0
  54. package/lib/commonjs/integrations/native-stack/views/NativeStackView.native.js.map +1 -0
  55. package/lib/commonjs/integrations/native-stack/views/useHeaderConfigProps.js +203 -0
  56. package/lib/commonjs/integrations/native-stack/views/useHeaderConfigProps.js.map +1 -0
  57. package/lib/commonjs/package.json +1 -0
  58. package/lib/commonjs/providers/gestures.js +64 -0
  59. package/lib/commonjs/providers/gestures.js.map +1 -0
  60. package/lib/commonjs/providers/keys.js +35 -0
  61. package/lib/commonjs/providers/keys.js.map +1 -0
  62. package/lib/commonjs/stores/animations.js +39 -0
  63. package/lib/commonjs/stores/animations.js.map +1 -0
  64. package/lib/commonjs/stores/bounds.js +64 -0
  65. package/lib/commonjs/stores/bounds.js.map +1 -0
  66. package/lib/commonjs/stores/gestures.js +38 -0
  67. package/lib/commonjs/stores/gestures.js.map +1 -0
  68. package/lib/commonjs/stores/navigator-dismiss-state.js +23 -0
  69. package/lib/commonjs/stores/navigator-dismiss-state.js.map +1 -0
  70. package/lib/commonjs/stores/utils/reset-stores-for-screen.js +20 -0
  71. package/lib/commonjs/stores/utils/reset-stores-for-screen.js.map +1 -0
  72. package/lib/commonjs/types/animation.js +6 -0
  73. package/lib/commonjs/types/animation.js.map +1 -0
  74. package/lib/commonjs/types/bounds.js +6 -0
  75. package/lib/commonjs/types/bounds.js.map +1 -0
  76. package/lib/commonjs/types/core.js +6 -0
  77. package/lib/commonjs/types/core.js.map +1 -0
  78. package/lib/commonjs/types/gesture.js +2 -0
  79. package/lib/commonjs/types/gesture.js.map +1 -0
  80. package/lib/commonjs/types/navigator.js +6 -0
  81. package/lib/commonjs/types/navigator.js.map +1 -0
  82. package/lib/commonjs/types/utils.js +2 -0
  83. package/lib/commonjs/types/utils.js.map +1 -0
  84. package/lib/commonjs/utils/animation/animate.js +18 -0
  85. package/lib/commonjs/utils/animation/animate.js.map +1 -0
  86. package/lib/commonjs/utils/animation/run-transition.js +48 -0
  87. package/lib/commonjs/utils/animation/run-transition.js.map +1 -0
  88. package/lib/commonjs/utils/bounds/_types/builder.js +6 -0
  89. package/lib/commonjs/utils/bounds/_types/builder.js.map +1 -0
  90. package/lib/commonjs/utils/bounds/_types/geometry.js +2 -0
  91. package/lib/commonjs/utils/bounds/_types/geometry.js.map +1 -0
  92. package/lib/commonjs/utils/bounds/_types/get-bounds.js +6 -0
  93. package/lib/commonjs/utils/bounds/_types/get-bounds.js.map +1 -0
  94. package/lib/commonjs/utils/bounds/build-bound-styles.js +145 -0
  95. package/lib/commonjs/utils/bounds/build-bound-styles.js.map +1 -0
  96. package/lib/commonjs/utils/bounds/constants.js +31 -0
  97. package/lib/commonjs/utils/bounds/constants.js.map +1 -0
  98. package/lib/commonjs/utils/bounds/flatten-styles.js +27 -0
  99. package/lib/commonjs/utils/bounds/flatten-styles.js.map +1 -0
  100. package/lib/commonjs/utils/bounds/geometry.js +94 -0
  101. package/lib/commonjs/utils/bounds/geometry.js.map +1 -0
  102. package/lib/commonjs/utils/bounds/get-bounds.js +51 -0
  103. package/lib/commonjs/utils/bounds/get-bounds.js.map +1 -0
  104. package/lib/commonjs/utils/bounds/index.js +38 -0
  105. package/lib/commonjs/utils/bounds/index.js.map +1 -0
  106. package/lib/commonjs/utils/bounds/style-composers.js +199 -0
  107. package/lib/commonjs/utils/bounds/style-composers.js.map +1 -0
  108. package/lib/commonjs/utils/gesture/apply-gesture-activation-criteria.js +81 -0
  109. package/lib/commonjs/utils/gesture/apply-gesture-activation-criteria.js.map +1 -0
  110. package/lib/commonjs/utils/gesture/map-gesture-to-progress.js +17 -0
  111. package/lib/commonjs/utils/gesture/map-gesture-to-progress.js.map +1 -0
  112. package/lib/commonjs/utils/gesture/normalize-gesture-translation.js +21 -0
  113. package/lib/commonjs/utils/gesture/normalize-gesture-translation.js.map +1 -0
  114. package/lib/commonjs/utils/index.js +17 -0
  115. package/lib/commonjs/utils/index.js.map +1 -0
  116. package/lib/module/__tests__ /geometry.test.js +178 -0
  117. package/lib/module/__tests__ /geometry.test.js.map +1 -0
  118. package/lib/module/components/bounds-activator.js +28 -0
  119. package/lib/module/components/bounds-activator.js.map +1 -0
  120. package/lib/module/components/controllers/screen-lifecycle.js +60 -0
  121. package/lib/module/components/controllers/screen-lifecycle.js.map +1 -0
  122. package/lib/module/components/create-transition-aware-component.js +91 -0
  123. package/lib/module/components/create-transition-aware-component.js.map +1 -0
  124. package/lib/module/components/root-transition-aware.js +51 -0
  125. package/lib/module/components/root-transition-aware.js.map +1 -0
  126. package/lib/module/configs/index.js +5 -0
  127. package/lib/module/configs/index.js.map +1 -0
  128. package/lib/module/configs/presets.js +197 -0
  129. package/lib/module/configs/presets.js.map +1 -0
  130. package/lib/module/configs/specs.js +10 -0
  131. package/lib/module/configs/specs.js.map +1 -0
  132. package/lib/module/hooks/animation/use-associated-style.js +32 -0
  133. package/lib/module/hooks/animation/use-associated-style.js.map +1 -0
  134. package/lib/module/hooks/animation/use-screen-animation.js +115 -0
  135. package/lib/module/hooks/animation/use-screen-animation.js.map +1 -0
  136. package/lib/module/hooks/bounds/use-bound-measurer.js +47 -0
  137. package/lib/module/hooks/bounds/use-bound-measurer.js.map +1 -0
  138. package/lib/module/hooks/gestures/use-build-gestures.js +234 -0
  139. package/lib/module/hooks/gestures/use-build-gestures.js.map +1 -0
  140. package/lib/module/hooks/gestures/use-scroll-progress.js +52 -0
  141. package/lib/module/hooks/gestures/use-scroll-progress.js.map +1 -0
  142. package/lib/module/hooks/use-stable-callback.js +13 -0
  143. package/lib/module/hooks/use-stable-callback.js.map +1 -0
  144. package/lib/module/index.js +21 -0
  145. package/lib/module/index.js.map +1 -0
  146. package/lib/module/integrations/native-stack/navigators/createNativeStackNavigator.js +63 -0
  147. package/lib/module/integrations/native-stack/navigators/createNativeStackNavigator.js.map +1 -0
  148. package/lib/module/integrations/native-stack/utils/debounce.js +12 -0
  149. package/lib/module/integrations/native-stack/utils/debounce.js.map +1 -0
  150. package/lib/module/integrations/native-stack/utils/getModalRoutesKeys.js +12 -0
  151. package/lib/module/integrations/native-stack/utils/getModalRoutesKeys.js.map +1 -0
  152. package/lib/module/integrations/native-stack/utils/useAnimatedHeaderHeight.js +12 -0
  153. package/lib/module/integrations/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -0
  154. package/lib/module/integrations/native-stack/utils/useDismissedRouteError.js +17 -0
  155. package/lib/module/integrations/native-stack/utils/useDismissedRouteError.js.map +1 -0
  156. package/lib/module/integrations/native-stack/utils/useInvalidPreventRemoveError.js +20 -0
  157. package/lib/module/integrations/native-stack/utils/useInvalidPreventRemoveError.js.map +1 -0
  158. package/lib/module/integrations/native-stack/views/FontProcessor.js +6 -0
  159. package/lib/module/integrations/native-stack/views/FontProcessor.js.map +1 -0
  160. package/lib/module/integrations/native-stack/views/FontProcessor.native.js +12 -0
  161. package/lib/module/integrations/native-stack/views/FontProcessor.native.js.map +1 -0
  162. package/lib/module/integrations/native-stack/views/FooterComponent.js +13 -0
  163. package/lib/module/integrations/native-stack/views/FooterComponent.js.map +1 -0
  164. package/lib/module/integrations/native-stack/views/NativeStackView.js +133 -0
  165. package/lib/module/integrations/native-stack/views/NativeStackView.js.map +1 -0
  166. package/lib/module/integrations/native-stack/views/NativeStackView.native.js +492 -0
  167. package/lib/module/integrations/native-stack/views/NativeStackView.native.js.map +1 -0
  168. package/lib/module/integrations/native-stack/views/useHeaderConfigProps.js +199 -0
  169. package/lib/module/integrations/native-stack/views/useHeaderConfigProps.js.map +1 -0
  170. package/lib/module/providers/gestures.js +58 -0
  171. package/lib/module/providers/gestures.js.map +1 -0
  172. package/lib/module/providers/keys.js +29 -0
  173. package/lib/module/providers/keys.js.map +1 -0
  174. package/lib/module/stores/animations.js +33 -0
  175. package/lib/module/stores/animations.js.map +1 -0
  176. package/lib/module/stores/bounds.js +60 -0
  177. package/lib/module/stores/bounds.js.map +1 -0
  178. package/lib/module/stores/gestures.js +34 -0
  179. package/lib/module/stores/gestures.js.map +1 -0
  180. package/lib/module/stores/navigator-dismiss-state.js +19 -0
  181. package/lib/module/stores/navigator-dismiss-state.js.map +1 -0
  182. package/lib/module/stores/utils/reset-stores-for-screen.js +16 -0
  183. package/lib/module/stores/utils/reset-stores-for-screen.js.map +1 -0
  184. package/lib/module/types/animation.js +4 -0
  185. package/lib/module/types/animation.js.map +1 -0
  186. package/lib/module/types/bounds.js +4 -0
  187. package/lib/module/types/bounds.js.map +1 -0
  188. package/lib/module/types/core.js +4 -0
  189. package/lib/module/types/core.js.map +1 -0
  190. package/lib/module/types/gesture.js +2 -0
  191. package/lib/module/types/gesture.js.map +1 -0
  192. package/lib/module/types/navigator.js +4 -0
  193. package/lib/module/types/navigator.js.map +1 -0
  194. package/lib/module/types/utils.js +2 -0
  195. package/lib/module/types/utils.js.map +1 -0
  196. package/lib/module/utils/animation/animate.js +13 -0
  197. package/lib/module/utils/animation/animate.js.map +1 -0
  198. package/lib/module/utils/animation/run-transition.js +43 -0
  199. package/lib/module/utils/animation/run-transition.js.map +1 -0
  200. package/lib/module/utils/bounds/_types/builder.js +4 -0
  201. package/lib/module/utils/bounds/_types/builder.js.map +1 -0
  202. package/lib/module/utils/bounds/_types/geometry.js +2 -0
  203. package/lib/module/utils/bounds/_types/geometry.js.map +1 -0
  204. package/lib/module/utils/bounds/_types/get-bounds.js +4 -0
  205. package/lib/module/utils/bounds/_types/get-bounds.js.map +1 -0
  206. package/lib/module/utils/bounds/build-bound-styles.js +141 -0
  207. package/lib/module/utils/bounds/build-bound-styles.js.map +1 -0
  208. package/lib/module/utils/bounds/constants.js +26 -0
  209. package/lib/module/utils/bounds/constants.js.map +1 -0
  210. package/lib/module/utils/bounds/flatten-styles.js +23 -0
  211. package/lib/module/utils/bounds/flatten-styles.js.map +1 -0
  212. package/lib/module/utils/bounds/geometry.js +89 -0
  213. package/lib/module/utils/bounds/geometry.js.map +1 -0
  214. package/lib/module/utils/bounds/get-bounds.js +46 -0
  215. package/lib/module/utils/bounds/get-bounds.js.map +1 -0
  216. package/lib/module/utils/bounds/index.js +33 -0
  217. package/lib/module/utils/bounds/index.js.map +1 -0
  218. package/lib/module/utils/bounds/style-composers.js +191 -0
  219. package/lib/module/utils/bounds/style-composers.js.map +1 -0
  220. package/lib/module/utils/gesture/apply-gesture-activation-criteria.js +76 -0
  221. package/lib/module/utils/gesture/apply-gesture-activation-criteria.js.map +1 -0
  222. package/lib/module/utils/gesture/map-gesture-to-progress.js +12 -0
  223. package/lib/module/utils/gesture/map-gesture-to-progress.js.map +1 -0
  224. package/lib/module/utils/gesture/normalize-gesture-translation.js +16 -0
  225. package/lib/module/utils/gesture/normalize-gesture-translation.js.map +1 -0
  226. package/lib/module/utils/index.js +4 -0
  227. package/lib/module/utils/index.js.map +1 -0
  228. package/lib/typescript/components/bounds-activator.d.ts +8 -0
  229. package/lib/typescript/components/bounds-activator.d.ts.map +1 -0
  230. package/lib/typescript/components/controllers/screen-lifecycle.d.ts +6 -0
  231. package/lib/typescript/components/controllers/screen-lifecycle.d.ts.map +1 -0
  232. package/lib/typescript/components/create-transition-aware-component.d.ts +9 -0
  233. package/lib/typescript/components/create-transition-aware-component.d.ts.map +1 -0
  234. package/lib/typescript/components/root-transition-aware.d.ts +6 -0
  235. package/lib/typescript/components/root-transition-aware.d.ts.map +1 -0
  236. package/lib/typescript/configs/index.d.ts +3 -0
  237. package/lib/typescript/configs/index.d.ts.map +1 -0
  238. package/lib/typescript/configs/presets.d.ts +9 -0
  239. package/lib/typescript/configs/presets.d.ts.map +1 -0
  240. package/lib/typescript/configs/specs.d.ts +3 -0
  241. package/lib/typescript/configs/specs.d.ts.map +1 -0
  242. package/lib/typescript/hooks/animation/use-associated-style.d.ts +11 -0
  243. package/lib/typescript/hooks/animation/use-associated-style.d.ts.map +1 -0
  244. package/lib/typescript/hooks/animation/use-screen-animation.d.ts +7 -0
  245. package/lib/typescript/hooks/animation/use-screen-animation.d.ts.map +1 -0
  246. package/lib/typescript/hooks/bounds/use-bound-measurer.d.ts +18 -0
  247. package/lib/typescript/hooks/bounds/use-bound-measurer.d.ts.map +1 -0
  248. package/lib/typescript/hooks/gestures/use-build-gestures.d.ts +11 -0
  249. package/lib/typescript/hooks/gestures/use-build-gestures.d.ts.map +1 -0
  250. package/lib/typescript/hooks/gestures/use-scroll-progress.d.ts +14 -0
  251. package/lib/typescript/hooks/gestures/use-scroll-progress.d.ts.map +1 -0
  252. package/lib/typescript/hooks/use-stable-callback.d.ts +2 -0
  253. package/lib/typescript/hooks/use-stable-callback.d.ts.map +1 -0
  254. package/lib/typescript/index.d.ts +1275 -0
  255. package/lib/typescript/index.d.ts.map +1 -0
  256. package/lib/typescript/integrations/native-stack/navigators/createNativeStackNavigator.d.ts +16 -0
  257. package/lib/typescript/integrations/native-stack/navigators/createNativeStackNavigator.d.ts.map +1 -0
  258. package/lib/typescript/integrations/native-stack/utils/debounce.d.ts +2 -0
  259. package/lib/typescript/integrations/native-stack/utils/debounce.d.ts.map +1 -0
  260. package/lib/typescript/integrations/native-stack/utils/getModalRoutesKeys.d.ts +4 -0
  261. package/lib/typescript/integrations/native-stack/utils/getModalRoutesKeys.d.ts.map +1 -0
  262. package/lib/typescript/integrations/native-stack/utils/useAnimatedHeaderHeight.d.ts +5 -0
  263. package/lib/typescript/integrations/native-stack/utils/useAnimatedHeaderHeight.d.ts.map +1 -0
  264. package/lib/typescript/integrations/native-stack/utils/useDismissedRouteError.d.ts +6 -0
  265. package/lib/typescript/integrations/native-stack/utils/useDismissedRouteError.d.ts.map +1 -0
  266. package/lib/typescript/integrations/native-stack/utils/useInvalidPreventRemoveError.d.ts +3 -0
  267. package/lib/typescript/integrations/native-stack/utils/useInvalidPreventRemoveError.d.ts.map +1 -0
  268. package/lib/typescript/integrations/native-stack/views/FontProcessor.d.ts +2 -0
  269. package/lib/typescript/integrations/native-stack/views/FontProcessor.d.ts.map +1 -0
  270. package/lib/typescript/integrations/native-stack/views/FontProcessor.native.d.ts +2 -0
  271. package/lib/typescript/integrations/native-stack/views/FontProcessor.native.d.ts.map +1 -0
  272. package/lib/typescript/integrations/native-stack/views/FooterComponent.d.ts +7 -0
  273. package/lib/typescript/integrations/native-stack/views/FooterComponent.d.ts.map +1 -0
  274. package/lib/typescript/integrations/native-stack/views/NativeStackView.d.ts +11 -0
  275. package/lib/typescript/integrations/native-stack/views/NativeStackView.d.ts.map +1 -0
  276. package/lib/typescript/integrations/native-stack/views/NativeStackView.native.d.ts +11 -0
  277. package/lib/typescript/integrations/native-stack/views/NativeStackView.native.d.ts.map +1 -0
  278. package/lib/typescript/integrations/native-stack/views/useHeaderConfigProps.d.ts +44 -0
  279. package/lib/typescript/integrations/native-stack/views/useHeaderConfigProps.d.ts.map +1 -0
  280. package/lib/typescript/providers/gestures.d.ts +22 -0
  281. package/lib/typescript/providers/gestures.d.ts.map +1 -0
  282. package/lib/typescript/providers/keys.d.ts +16 -0
  283. package/lib/typescript/providers/keys.d.ts.map +1 -0
  284. package/lib/typescript/stores/animations.d.ts +17 -0
  285. package/lib/typescript/stores/animations.d.ts.map +1 -0
  286. package/lib/typescript/stores/bounds.d.ts +21 -0
  287. package/lib/typescript/stores/bounds.d.ts.map +1 -0
  288. package/lib/typescript/stores/gestures.d.ts +21 -0
  289. package/lib/typescript/stores/gestures.d.ts.map +1 -0
  290. package/lib/typescript/stores/navigator-dismiss-state.d.ts +7 -0
  291. package/lib/typescript/stores/navigator-dismiss-state.d.ts.map +1 -0
  292. package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts +6 -0
  293. package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts.map +1 -0
  294. package/lib/typescript/types/animation.d.ts +65 -0
  295. package/lib/typescript/types/animation.d.ts.map +1 -0
  296. package/lib/typescript/types/bounds.d.ts +73 -0
  297. package/lib/typescript/types/bounds.d.ts.map +1 -0
  298. package/lib/typescript/types/core.d.ts +47 -0
  299. package/lib/typescript/types/core.d.ts.map +1 -0
  300. package/lib/typescript/types/gesture.d.ts +28 -0
  301. package/lib/typescript/types/gesture.d.ts.map +1 -0
  302. package/lib/typescript/types/navigator.d.ts +683 -0
  303. package/lib/typescript/types/navigator.d.ts.map +1 -0
  304. package/lib/typescript/types/utils.d.ts +5 -0
  305. package/lib/typescript/types/utils.d.ts.map +1 -0
  306. package/lib/typescript/utils/animation/animate.d.ts +4 -0
  307. package/lib/typescript/utils/animation/animate.d.ts.map +1 -0
  308. package/lib/typescript/utils/animation/run-transition.d.ts +11 -0
  309. package/lib/typescript/utils/animation/run-transition.d.ts.map +1 -0
  310. package/lib/typescript/utils/bounds/_types/builder.d.ts +36 -0
  311. package/lib/typescript/utils/bounds/_types/builder.d.ts.map +1 -0
  312. package/lib/typescript/utils/bounds/_types/geometry.d.ts +16 -0
  313. package/lib/typescript/utils/bounds/_types/geometry.d.ts.map +1 -0
  314. package/lib/typescript/utils/bounds/_types/get-bounds.d.ts +10 -0
  315. package/lib/typescript/utils/bounds/_types/get-bounds.d.ts.map +1 -0
  316. package/lib/typescript/utils/bounds/build-bound-styles.d.ts +4 -0
  317. package/lib/typescript/utils/bounds/build-bound-styles.d.ts.map +1 -0
  318. package/lib/typescript/utils/bounds/constants.d.ts +7 -0
  319. package/lib/typescript/utils/bounds/constants.d.ts.map +1 -0
  320. package/lib/typescript/utils/bounds/flatten-styles.d.ts +2 -0
  321. package/lib/typescript/utils/bounds/flatten-styles.d.ts.map +1 -0
  322. package/lib/typescript/utils/bounds/geometry.d.ts +24 -0
  323. package/lib/typescript/utils/bounds/geometry.d.ts.map +1 -0
  324. package/lib/typescript/utils/bounds/get-bounds.d.ts +4 -0
  325. package/lib/typescript/utils/bounds/get-bounds.d.ts.map +1 -0
  326. package/lib/typescript/utils/bounds/index.d.ts +15 -0
  327. package/lib/typescript/utils/bounds/index.d.ts.map +1 -0
  328. package/lib/typescript/utils/bounds/style-composers.d.ts +40 -0
  329. package/lib/typescript/utils/bounds/style-composers.d.ts.map +1 -0
  330. package/lib/typescript/utils/gesture/apply-gesture-activation-criteria.d.ts +17 -0
  331. package/lib/typescript/utils/gesture/apply-gesture-activation-criteria.d.ts.map +1 -0
  332. package/lib/typescript/utils/gesture/map-gesture-to-progress.d.ts +5 -0
  333. package/lib/typescript/utils/gesture/map-gesture-to-progress.d.ts.map +1 -0
  334. package/lib/typescript/utils/gesture/normalize-gesture-translation.d.ts +6 -0
  335. package/lib/typescript/utils/gesture/normalize-gesture-translation.d.ts.map +1 -0
  336. package/lib/typescript/utils/index.d.ts +2 -0
  337. package/lib/typescript/utils/index.d.ts.map +1 -0
  338. package/package.json +67 -54
  339. package/dist/index.d.mts +0 -1513
  340. package/dist/index.d.ts +0 -1513
  341. package/dist/index.js +0 -1283
  342. package/dist/index.js.map +0 -1
  343. package/dist/index.mjs +0 -1279
  344. package/dist/index.mjs.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,22 +1,5 @@
1
1
  # react-native-screen-transitions
2
2
 
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
3
  | iOS | Android |
21
4
  |---|---|
22
5
  | <video src="https://github.com/user-attachments/assets/81f39391-80c0-4ce4-b6ff-76de85d2cf03" width="300" height="600" controls></video> | <video src="https://github.com/user-attachments/assets/c2b4c6ca-2b0c-4cf4-a164-f7e68cee0c32" width="300" controls></video> |
@@ -39,94 +22,80 @@ bun add react-native-screen-transitions
39
22
 
40
23
  ## Peer Dependencies
41
24
  ```bash
42
- npm install react-native-reanimated react-native-gesture-handler @react-navigation/native-stack
25
+ npm install react-native-reanimated react-native-gesture-handler \
26
+ @react-navigation/native @react-navigation/native-stack \
27
+ @react-navigation/elements react-native-screens \
28
+ react-native-safe-area-context
43
29
  ```
44
30
 
45
31
  ## Setup
46
32
 
47
- ### 1. React Navigation
48
- ```tsx
49
- import { NavigationContainer } from '@react-navigation/native';
50
- import { GestureHandlerRootView } from 'react-native-gesture-handler';
51
- import Transition from 'react-native-screen-transitions';
33
+ ### 1. Expo Router
52
34
 
53
- const Stack = Transition.createTransitionableStackNavigator();
35
+ ```tsx
36
+ import type {
37
+ ParamListBase,
38
+ StackNavigationState,
39
+ } from "@react-navigation/native";
40
+ import { withLayoutContext } from "expo-router";
41
+ import {
42
+ createNativeStackNavigator,
43
+ type NativeStackNavigationEventMap,
44
+ type NativeStackNavigationOptions,
45
+ } from "react-native-screen-transitions";
46
+
47
+ const { Navigator } = createNativeStackNavigator();
54
48
 
55
- export default function App() {
56
- return (
57
- <GestureHandlerRootView>
58
- <NavigationContainer>
59
- <Stack.Navigator>
60
- <Stack.Screen
61
- name="Home"
62
- component={Home}
63
- options={{
64
- skipDefaultScreenOptions: true, // prevents transparent-modal default
65
- }}
66
- />
67
- <Stack.Screen
68
- name="A"
69
- component={ScreenA}
70
- options={{
71
- ...Transition.presets.SlideFromTop(),
72
- }}
73
- />
74
- </Stack.Navigator>
75
- </NavigationContainer>
76
- </GestureHandlerRootView>
77
- );
78
- }
49
+ export const Stack = withLayoutContext<
50
+ NativeStackNavigationOptions,
51
+ typeof Navigator,
52
+ StackNavigationState<ParamListBase>,
53
+ NativeStackNavigationEventMap
54
+ >(Navigator);
79
55
  ```
80
56
 
81
- ### 2. Expo Router
82
- Use the withLayoutContext to convert it into an expo router compatible navigator.
57
+ That’s it you’re ready to go.
58
+
59
+ ### 2. React Navigation (bare)
60
+
61
+ If you’re using **React Navigation** directly (not Expo Router), the navigator is already configured.
62
+ No extra setup is required—just import and use as usual:
83
63
 
84
64
  ```tsx
85
- import { withLayoutContext } from 'expo-router';
86
- import Transition, {
87
- type TransitionStackNavigatorTypeBag,
88
- } from 'react-native-screen-transitions';
65
+ import { createNativeStackNavigator } from 'react-native-screen-transitions';
89
66
 
90
- const TransitionableNativeStack =
91
- Transition.createTransitionableStackNavigator();
67
+ const Stack = createNativeStackNavigator();
92
68
 
93
- export const Stack = withLayoutContext<
94
- TransitionStackNavigatorTypeBag['ScreenOptions'],
95
- typeof TransitionableNativeStack.Navigator,
96
- TransitionStackNavigatorTypeBag['State'],
97
- TransitionStackNavigatorTypeBag['EventMap']
98
- >(TransitionableNativeStack.Navigator);
69
+ // Use Stack.Navigator and Stack.Screen as normal
99
70
  ```
100
71
 
101
- Use it exactly like any other Expo Router layout:
72
+ ### Extended native-stack options
102
73
 
103
- ```tsx
104
- import { Stack } from './layouts/stack.tsx'
105
-
106
- export default function RootLayout(){
107
- return(
108
- <GestureHandlerRootView>
109
- <Stack>
110
- <Stack.Screen
111
- name="a"
112
- options={{
113
- // You usually don't want your first screen to be a transparent modal.
114
- skipDefaultScreenOptions: true,
115
- }}
116
- />
117
- <Stack.Screen
118
- name="b"
119
- options={{
120
- ...Transition.presets.SlideFromTop(),
121
- }}
122
- />
123
- </Stack>
124
- </GestureHandlerRootView>
125
- )
126
- }
127
- ```
74
+ This package ships an **extended native stack** built on top of React Navigation’s native stack.
75
+ All the usual native-stack options are available, plus the following extras:
128
76
 
129
- > **Note**: `Transition.createTransitionableStackNavigator()` returns a Native Stack Navigator that's been injected with the necessary functionality for screen transitions to work.
77
+ | Option | Type | Description |
78
+ |---|---|---|
79
+ | `enableTransitions` | `boolean` | Switches the screen to a transparent modal and disables the header so custom transitions can take over. |
80
+ | `screenStyleInterpolator` | `ScreenStyleInterpolator` | Function that returns animated styles based on transition progress. |
81
+ | `transitionSpec` | `TransitionSpec` | Reanimated timing/spring config for open/close animations. |
82
+ | `gestureEnabled` | `boolean` | Whether swipe-to-dismiss is allowed. |
83
+ | `gestureDirection` | `GestureDirection \| GestureDirection[]` | Allowed swipe directions (`vertical`, `horizontal`, etc.). |
84
+ | `gestureVelocityImpact` | `number` | How much the gesture’s velocity affects dismissal. |
85
+ | `gestureResponseDistance` | `number` | Distance from screen where the gesture is recognized. |
86
+ | `gestureDrivesProgress` | `boolean` | Whether the gesture directly drives the transition progress. |
87
+
88
+ ### Renamed native options (extended stack)
89
+
90
+ To avoid collisions with the new options above, the built-in React Navigation gesture props are renamed:
91
+
92
+ | React Navigation prop | Renamed to |
93
+ |---|---|
94
+ | `gestureDirection` | `nativeGestureDirection` |
95
+ | `gestureEnabled` | `nativeGestureEnabled` |
96
+ | `gestureResponseDistance` | `nativeGestureResponseDistance` |
97
+
98
+ All other React Navigation native-stack options keep their original names.
130
99
 
131
100
 
132
101
  ## Creating your screen animations
@@ -140,10 +109,6 @@ The incoming screen automatically controls the previous screen.
140
109
  <Stack>
141
110
  <Stack.Screen
142
111
  name="a"
143
- options={{
144
- // avoids transparent-modal default for first screen
145
- skipDefaultScreenOptions: true,
146
- }}
147
112
  />
148
113
  <Stack.Screen
149
114
  name="b"
@@ -160,45 +125,35 @@ The incoming screen automatically controls the previous screen.
160
125
  </Stack>
161
126
  ```
162
127
 
163
- > ⚠️ **Important**
164
- > Any screen that **must** participate in a transition (i.e., be animated) **must** be wrapped in a transition-aware component.
165
- > For example, if both `a` and `b` are meant to animate, wrap each screen’s root like this:
166
-
167
- ```tsx
168
- // a.tsx
169
- <Transition.View>
170
- ...
171
- </Transition.View>
172
-
173
- // b.tsx
174
- <Transition.View>
175
- ...
176
- </Transition.View>
177
- ```
178
-
179
- Without this wrapper, the transition system cannot animate the screen and the animation will appear broken or skipped.
180
-
181
-
182
-
183
128
  ### Navigator-level custom animations
184
129
 
185
130
  Instead of presets, you can define a custom transition directly on the screen’s options.
186
- The `screenStyleInterpolator` receives the current and next screen’s progress and lets you animate both at once.
131
+ `screenStyleInterpolator` receives an object with the following useful fields:
132
+
133
+ - `progress` – overall transition progress (`0 → 2`).
134
+ - `current` – state for the current screen (includes `progress`, `closing`, `gesture`, `route`, etc.).
135
+ - `previous` – state for the previous screen (may be `undefined`).
136
+ - `next` – state for the next screen (may be `undefined`).
137
+ - `layouts.screen` – `{ width, height }` of the container.
138
+ - `insets` – `{ top, right, bottom, left }` safe-area insets.
139
+ - `bounds(id)` – helper to compute shared-element transforms (see IntelliSense for chainable methods).
140
+ - `activeBoundId` – id of the active bound.
141
+ - `focused` – state of the current screen
142
+
187
143
 
188
144
  ```tsx
189
145
  import { interpolate } from 'react-native-reanimated'
146
+
190
147
  <Stack.Screen
191
148
  name="b"
192
149
  options={{
150
+ enableTransitions: true,
193
151
  screenStyleInterpolator: ({
194
- current,
195
- next,
196
152
  layouts: { screen: { width } },
153
+ progress,
197
154
  }) => {
198
155
  "worklet";
199
156
 
200
- const progress = current.progress.value + (next?.progress.value ?? 0);
201
-
202
157
  const x = interpolate(progress, [0, 1, 2], [width, 0, -width]);
203
158
  return {
204
159
  contentStyle: {
@@ -225,11 +180,12 @@ import { useScreenAnimation } from 'react-native-screen-transitions';
225
180
  import Animated, { useAnimatedStyle, interpolate } from 'react-native-reanimated';
226
181
 
227
182
  export default function BScreen() {
228
- const { current } = useScreenAnimation();
183
+ const props = useScreenAnimation();
229
184
 
230
185
  const animatedStyle = useAnimatedStyle(() => {
186
+ const { current: { progress } } = props.value
231
187
  return {
232
- opacity: current.progress.value
188
+ opacity: progress
233
189
  };
234
190
  });
235
191
 
@@ -241,29 +197,6 @@ export default function BScreen() {
241
197
  }
242
198
  ```
243
199
 
244
- ## Apply screen transitions to nested navigators
245
-
246
- When a screen contains its own stack (e.g., `b` is a nested navigator), wrap the nested `Stack` in a `Transition.View`.
247
-
248
- ```tsx
249
- // app/b/_layout.tsx (nested stack for screen "b")
250
- import { Stack } from 'expo-router';
251
- import Transition from 'react-native-screen-transitions';
252
-
253
- export default function BLayout() {
254
- return (
255
- <Transition.View>
256
- <Stack>
257
- <Stack.Screen name="index" options={{ headerShown: false }} />
258
- <Stack.Screen name="details" options={{ headerShown: false }} />
259
- </Stack>
260
- </Transition.View>
261
- );
262
- }
263
- ```
264
-
265
- The outer transition now treats the entire nested stack as a single animatable view while each inner screen can still function normally—whether you keep the native stack or swap it for the Transitionable Stack.
266
-
267
200
  ## Swipe-to-dismiss with scrollables
268
201
 
269
202
  You can drag a screen away even when it contains a scroll view.
@@ -276,14 +209,14 @@ import { FlashList } from "@shopify/flash-list";
276
209
 
277
210
  // Drop-in replacements
278
211
  const ScrollView = Transition.ScrollView;
279
- const FlatList = Transition.FlatList;
212
+ const FlatList = Transition.FlatList;
280
213
 
281
214
  // Or wrap any list you like
282
215
  const TransitionFlashList =
283
- Transition.createTransitionAwareScrollable(FlashList);
216
+ Transition.createTransitionAwareScrollable(FlashList, { isScrollable: true });
284
217
 
285
218
  const TransitionLegendList =
286
- Transition.createTransitionAwareScrollable(LegendList);
219
+ Transition.createTransitionAwareScrollable(LegendList, { isScrollable: true} );
287
220
  ```
288
221
 
289
222
  Enable the gesture on the screen:
@@ -292,6 +225,7 @@ Enable the gesture on the screen:
292
225
  <Stack.Screen
293
226
  name="gallery"
294
227
  options={{
228
+ enableTransitions: true,
295
229
  gestureEnabled: true,
296
230
  gestureDirection: 'vertical', // or 'horizontal', ['vertical', 'horizontal'], etc.
297
231
  }}
@@ -316,22 +250,140 @@ Gesture rules (handled automatically):
316
250
  - **vertical-inverted** – only starts when the list is at the very bottom
317
251
  - **horizontal** / **horizontal-inverted** – only starts when the list is at the left or right edge
318
252
 
319
- These rules apply **only when the screen contains a nested scrollable**.
253
+ These rules apply **only when the screen contains a scrollable**.
320
254
  If no scroll view is present, the gesture can begin from **anywhere on the screen**—not restricted to the edges.
321
255
 
322
- ## Performance tips
256
+ ## Bounds (measure-driven screen transitions)
257
+
258
+ Bounds let you animate **any component** between two screens by measuring its start and end positions.
259
+ They are **not shared elements**—they’re just measurements.
260
+ Tag the component you want to animate with `sharedBoundTag`, then describe how it should move when the screen transition starts.
261
+
262
+ 1. Tag the source component
263
+
264
+ ```tsx
265
+ <Transition.View sharedBoundTag="hero" style={{ width: 100, height: 100 }}>
266
+ <Image source={uri} style={{ width: '100%', height: '100%' }} resizeMode="cover" />
267
+ </Transition.View>
268
+ ```
269
+
270
+ 2. Tag the destination component (same id)
271
+
272
+ ```tsx
273
+ <Transition.View sharedBoundTag="hero" style={{ width: 200, height: 200 }}>
274
+ <Image source={uri} style={{ width: '100%', height: '100%' }} resizeMode="cover" />
275
+ </Transition.View>
276
+ ```
277
+
278
+ 3. Drive the animation in `screenStyleInterpolator`
279
+
280
+ ```tsx
281
+ screenStyleInterpolator: ({
282
+ activeBoundId,
283
+ bounds,
284
+ focused,
285
+ current,
286
+ next,
287
+ }) => {
288
+ "worklet";
289
+
290
+ const animatedBoundStyles = bounds()
291
+ .relative()
292
+ .transform()
293
+ .build();
294
+
295
+ return {
296
+ [activeBoundId]: animatedBoundStyles,
297
+ };
298
+ };
299
+ ```
300
+
301
+ That’s it—the bounds helper works alongside focused and unfocused screens.
302
+ For further customization, separate logic by the `focused` prop:
323
303
 
324
- Keep animations smooth and responsive:
304
+ ```tsx
305
+ screenStyleInterpolator: ({
306
+ activeBoundId,
307
+ bounds,
308
+ focused,
309
+ current,
310
+ next,
311
+ }) => {
312
+ "worklet";
313
+
314
+
315
+ if (focused) {
316
+ const focusedBoundStyles = bounds()
317
+ .relative()
318
+ .transform()
319
+ .build();
320
+
321
+ return {
322
+ [activeBoundId]: focusedBoundStyles,
323
+ };
324
+ }
325
+
326
+ return {}
327
+ };
328
+ ```
329
+
330
+
331
+ ### Choosing the right modifier
332
+
333
+ | Modifier | When to use |
334
+ |---|---|
335
+ | `gestures({x,y})` | Sync the bound with live gesture deltas (drag, swipe). |
336
+ | `toFullscreen()` | Destination has no `sharedBoundTag`; animate to full-screen size. |
337
+ | `absolute()` | Element is not constrained by parent layout (uses pageX/pageY). |
338
+ | `relative()` | Element is inside layout constraints (default). |
339
+ | `transform()` | Animate with `translateX/Y` + `scaleX/Y` (default). |
340
+ | `size()` | Animate `translateX/Y` + `width/height` (no scale). |
341
+ | `content()` | Center the container so its bound aligns with the source at progress start. |
342
+ | `contentFill()` / `contentFit()` | Control how the content scales inside the container. |
343
+ | `build()` | Finalize the animated style object. |
344
+
345
+ ### Quick access: `bounds.get()`
346
+
347
+ Need the raw measurements or styles for a specific bound?
348
+ Call `bounds.get(boundId, phase)` to retrieve the exact dimensions and style object for any bound tag and screen phase (`current`, `next`, or `previous`).
349
+
350
+ ```tsx
351
+ const heroMetrics = bounds.get('hero', 'current');
352
+ // heroMetrics = { bounds: { x, y, width, height, pageX, pageY }, styles: { ... } }
353
+ ```
354
+
355
+ Use this when you want explicit control over which bound’s data you animate, regardless of the current screen focus.
356
+
357
+ ### Animating individual components with `styleId`
358
+
359
+ Use `styleId` to animate a single view inside a screen.
360
+
361
+ 1. Tag the element:
362
+
363
+ ```tsx
364
+ <Transition.View styleId="fade-box" style={{ width: 100, height: 100, backgroundColor: 'crimson' }} />
365
+ ```
366
+
367
+ 2. Drive it from the interpolator:
368
+
369
+ ```tsx
370
+ screenStyleInterpolator: ({ progress }) => {
371
+ "worklet";
372
+
373
+ return {
374
+ 'fade-box': {
375
+ opacity: interpolate(progress, [0, 1, 2],[0, 1, 0])
376
+ }
377
+ };
378
+ };
379
+ ```
325
380
 
326
- - **Optimize screen content** avoid heavy computations, complex layouts, or expensive renders in screens that animate
327
- - **Use GPU-friendly properties** – stick to `transform` and `opacity` which are hardware-accelerated; avoid animating `width`, `height`, `padding`, large `borderRadius`, and complex shadows
328
- - **Choose appropriate timing** – use natural easing curves and durations that feel responsive without being jarring
381
+ The red square fades in as the screen opens.
329
382
 
330
- ## Roadmap
383
+ ## Known Issues
331
384
 
332
- - **Shared element transitions** – seamless hand-off of components between screens
333
- - **Gesture-driven forward navigation** – allow gestures to trigger push navigation events
334
- - **Performance maximization** – further reduce JS thread work and leverage Reanimated 3’s new APIs for even smoother 60 fps animations
385
+ - **Delayed Touch Events** – There’s a noticeable delay in touch events, likely caused by the `beforeRemove` listener in the native stack. If this affects your app, please hold off on using this package until a fix is available.
386
+ - **Deeply nested navigators with scrollables** – Behavior is currently unstable. We recommend using programmatic dismissal for deeply nested navigators that contain scrollables, as the gesture-driven dismissal logic needs an overhaul.
335
387
 
336
388
 
337
389
  ## Support and Development
@@ -343,6 +395,9 @@ This package is provided as-is and is developed in my free time. While I strive
343
395
 
344
396
  I apologize for any inconvenience this may cause. If you encounter issues or have suggestions, please feel free to open an issue on the repository.
345
397
 
398
+ ### Support the project
399
+ I’ve estimated I downed around 60 cups of coffee while building this.
400
+ If you’d like to fuel the next release, [buy me a coffee](https://buymeacoffee.com/trpfsu)
346
401
 
347
402
 
348
403
 
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+
3
+ var _bunTest = require("bun:test");
4
+ var _geometry = require("../utils/bounds/geometry");
5
+ (0, _bunTest.describe)("computeRelativeGeometry", () => {
6
+ (0, _bunTest.it)("calculates correct relative geometry when entering", () => {
7
+ const start = {
8
+ x: 10,
9
+ y: 20,
10
+ pageX: 10,
11
+ pageY: 20,
12
+ width: 100,
13
+ height: 200
14
+ };
15
+ const end = {
16
+ x: 50,
17
+ y: 100,
18
+ pageX: 50,
19
+ pageY: 100,
20
+ width: 200,
21
+ height: 400
22
+ };
23
+ const result = (0, _geometry.computeRelativeGeometry)({
24
+ start,
25
+ end,
26
+ entering: true
27
+ });
28
+ (0, _bunTest.expect)(result.dx).toBe(-90); // center diff X
29
+ (0, _bunTest.expect)(result.dy).toBe(-180); // center diff Y
30
+ (0, _bunTest.expect)(result.scaleX).toBe(0.5); // width ratio
31
+ (0, _bunTest.expect)(result.scaleY).toBe(0.5); // height ratio
32
+ (0, _bunTest.expect)(result.ranges).toEqual([0, 1]);
33
+ (0, _bunTest.expect)(result.entering).toBe(true);
34
+ });
35
+ (0, _bunTest.it)("calculates correct relative geometry when exiting", () => {
36
+ const start = {
37
+ x: 0,
38
+ y: 0,
39
+ pageX: 10,
40
+ pageY: 20,
41
+ width: 100,
42
+ height: 200
43
+ };
44
+ const end = {
45
+ x: 0,
46
+ y: 0,
47
+ pageX: 50,
48
+ pageY: 100,
49
+ width: 200,
50
+ height: 400
51
+ };
52
+ const result = (0, _geometry.computeRelativeGeometry)({
53
+ start,
54
+ end,
55
+ entering: false
56
+ });
57
+ (0, _bunTest.expect)(result.ranges).toEqual([1, 2]);
58
+ (0, _bunTest.expect)(result.entering).toBe(false);
59
+ });
60
+ });
61
+ (0, _bunTest.describe)("computeContentTransformGeometry", () => {
62
+ const dimensions = {
63
+ width: 375,
64
+ height: 812,
65
+ scale: 1,
66
+ fontScale: 1
67
+ };
68
+ (0, _bunTest.it)("calculates transform with aspectFit mode", () => {
69
+ const start = {
70
+ x: 0,
71
+ y: 0,
72
+ pageX: 50,
73
+ pageY: 100,
74
+ width: 100,
75
+ height: 100
76
+ };
77
+ const end = {
78
+ x: 0,
79
+ y: 0,
80
+ pageX: 100,
81
+ pageY: 200,
82
+ width: 200,
83
+ height: 50
84
+ };
85
+ const result = (0, _geometry.computeContentTransformGeometry)({
86
+ start,
87
+ end,
88
+ entering: true,
89
+ dimensions,
90
+ contentScaleMode: "aspectFit"
91
+ });
92
+ (0, _bunTest.expect)(result.s).toBe(0.5);
93
+ (0, _bunTest.expect)(result.entering).toBe(true);
94
+ (0, _bunTest.expect)(result.ranges).toEqual([0, 1]);
95
+ });
96
+ (0, _bunTest.it)("calculates transform with aspectFill mode", () => {
97
+ const start = {
98
+ x: 0,
99
+ y: 0,
100
+ pageX: 50,
101
+ pageY: 100,
102
+ width: 100,
103
+ height: 100
104
+ };
105
+ const end = {
106
+ x: 0,
107
+ y: 0,
108
+ pageX: 100,
109
+ pageY: 200,
110
+ width: 200,
111
+ height: 50
112
+ };
113
+ const result = (0, _geometry.computeContentTransformGeometry)({
114
+ start,
115
+ end,
116
+ entering: true,
117
+ dimensions,
118
+ contentScaleMode: "aspectFill"
119
+ });
120
+ (0, _bunTest.expect)(result.s).toBe(2);
121
+ });
122
+ (0, _bunTest.it)("handles auto mode based on aspect ratio difference", () => {
123
+ const start = {
124
+ x: 0,
125
+ y: 0,
126
+ pageX: 0,
127
+ pageY: 0,
128
+ width: 100,
129
+ height: 100
130
+ };
131
+ const end = {
132
+ x: 0,
133
+ y: 0,
134
+ pageX: 0,
135
+ pageY: 0,
136
+ width: 200,
137
+ height: 195
138
+ };
139
+ const result = (0, _geometry.computeContentTransformGeometry)({
140
+ start,
141
+ end,
142
+ entering: true,
143
+ dimensions,
144
+ contentScaleMode: "auto"
145
+ });
146
+ (0, _bunTest.expect)(result.s).toBeCloseTo(0.512, 2);
147
+ });
148
+ (0, _bunTest.it)("handles zero dimensions safely", () => {
149
+ const start = {
150
+ x: 0,
151
+ y: 0,
152
+ pageX: 0,
153
+ pageY: 0,
154
+ width: 0,
155
+ height: 100
156
+ };
157
+ const end = {
158
+ x: 0,
159
+ y: 0,
160
+ pageX: 0,
161
+ pageY: 0,
162
+ width: 200,
163
+ height: 200
164
+ };
165
+
166
+ // Should not throw and use safe fallback
167
+ const result = (0, _geometry.computeContentTransformGeometry)({
168
+ start,
169
+ end,
170
+ entering: true,
171
+ dimensions,
172
+ contentScaleMode: "aspectFit"
173
+ });
174
+ (0, _bunTest.expect)(result.s).toBeDefined();
175
+ (0, _bunTest.expect)(Number.isFinite(result.s)).toBe(true);
176
+ });
177
+ });
178
+ //# sourceMappingURL=geometry.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_bunTest","require","_geometry","describe","it","start","x","y","pageX","pageY","width","height","end","result","computeRelativeGeometry","entering","expect","dx","toBe","dy","scaleX","scaleY","ranges","toEqual","dimensions","scale","fontScale","computeContentTransformGeometry","contentScaleMode","s","toBeCloseTo","toBeDefined","Number","isFinite"],"sourceRoot":"../../../src","sources":["__tests__ /geometry.test.ts"],"mappings":";;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAQ,EAAC,yBAAyB,EAAE,MAAM;EACzC,IAAAC,WAAE,EAAC,oDAAoD,EAAE,MAAM;IAC9D,MAAMC,KAAK,GAAG;MACbC,CAAC,EAAE,EAAE;MACLC,CAAC,EAAE,EAAE;MACLC,KAAK,EAAE,EAAE;MACTC,KAAK,EAAE,EAAE;MACTC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE;IACT,CAAC;IACD,MAAMC,GAAG,GAAG;MACXN,CAAC,EAAE,EAAE;MACLC,CAAC,EAAE,GAAG;MACNC,KAAK,EAAE,EAAE;MACTC,KAAK,EAAE,GAAG;MACVC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE;IACT,CAAC;IAED,MAAME,MAAM,GAAG,IAAAC,iCAAuB,EAAC;MAAET,KAAK;MAAEO,GAAG;MAAEG,QAAQ,EAAE;IAAK,CAAC,CAAC;IAEtE,IAAAC,eAAM,EAACH,MAAM,CAACI,EAAE,CAAC,CAACC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,IAAAF,eAAM,EAACH,MAAM,CAACM,EAAE,CAAC,CAACD,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,IAAAF,eAAM,EAACH,MAAM,CAACO,MAAM,CAAC,CAACF,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,IAAAF,eAAM,EAACH,MAAM,CAACQ,MAAM,CAAC,CAACH,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,IAAAF,eAAM,EAACH,MAAM,CAACS,MAAM,CAAC,CAACC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,IAA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