react-native-reanimated-carousel 5.0.0-beta.7 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/README.md +60 -28
  2. package/lib/commonjs/components/Carousel.js +1 -1
  3. package/lib/commonjs/components/Carousel.js.map +1 -1
  4. package/lib/commonjs/components/CarouselLayout.js +1 -1
  5. package/lib/commonjs/components/CarouselLayout.js.map +1 -1
  6. package/lib/commonjs/components/ItemLayout.js +1 -1
  7. package/lib/commonjs/components/ItemLayout.js.map +1 -1
  8. package/lib/commonjs/components/ItemRenderer.js +1 -1
  9. package/lib/commonjs/components/ItemRenderer.js.map +1 -1
  10. package/lib/commonjs/components/Pagination/PaginationItem.js +2 -0
  11. package/lib/commonjs/components/Pagination/PaginationItem.js.map +1 -0
  12. package/lib/commonjs/components/Pagination/index.js +1 -1
  13. package/lib/commonjs/components/Pagination/index.js.map +1 -1
  14. package/lib/commonjs/components/ScrollViewGesture.js +1 -1
  15. package/lib/commonjs/components/ScrollViewGesture.js.map +1 -1
  16. package/lib/commonjs/hooks/useAutoPlay.js +1 -1
  17. package/lib/commonjs/hooks/useAutoPlay.js.map +1 -1
  18. package/lib/commonjs/hooks/useCarouselController.js +1 -1
  19. package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
  20. package/lib/commonjs/hooks/useCommonVariables.js +1 -1
  21. package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
  22. package/lib/commonjs/hooks/useInitProps.js +1 -1
  23. package/lib/commonjs/hooks/useInitProps.js.map +1 -1
  24. package/lib/commonjs/hooks/useLayoutConfig.js +1 -1
  25. package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -1
  26. package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
  27. package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
  28. package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
  29. package/lib/commonjs/hooks/usePanGestureProxy.js.map +1 -1
  30. package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
  31. package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
  32. package/lib/commonjs/hooks/useUpdateGestureConfig.js.map +1 -1
  33. package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
  34. package/lib/commonjs/index.js +1 -1
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/commonjs/layouts/index.js.map +1 -1
  37. package/lib/commonjs/layouts/normal.js +1 -1
  38. package/lib/commonjs/layouts/normal.js.map +1 -1
  39. package/lib/commonjs/layouts/parallax.js +1 -1
  40. package/lib/commonjs/layouts/parallax.js.map +1 -1
  41. package/lib/commonjs/layouts/stack.js +1 -1
  42. package/lib/commonjs/layouts/stack.js.map +1 -1
  43. package/lib/commonjs/public-types.js +2 -0
  44. package/lib/commonjs/public-types.js.map +1 -0
  45. package/lib/commonjs/store/index.js.map +1 -1
  46. package/lib/commonjs/utils/carousel-direction.js +2 -0
  47. package/lib/commonjs/utils/carousel-direction.js.map +1 -0
  48. package/lib/commonjs/utils/carousel-math.js +2 -0
  49. package/lib/commonjs/utils/carousel-math.js.map +1 -0
  50. package/lib/commonjs/utils/deal-with-animation.js +1 -1
  51. package/lib/commonjs/utils/deal-with-animation.js.map +1 -1
  52. package/lib/module/components/Carousel.js +1 -1
  53. package/lib/module/components/Carousel.js.map +1 -1
  54. package/lib/module/components/CarouselLayout.js +1 -1
  55. package/lib/module/components/CarouselLayout.js.map +1 -1
  56. package/lib/module/components/ItemLayout.js +1 -1
  57. package/lib/module/components/ItemLayout.js.map +1 -1
  58. package/lib/module/components/ItemRenderer.js +1 -1
  59. package/lib/module/components/ItemRenderer.js.map +1 -1
  60. package/lib/module/components/LazyView.js +1 -1
  61. package/lib/module/components/LazyView.js.map +1 -1
  62. package/lib/module/components/Pagination/PaginationItem.js +2 -0
  63. package/lib/module/components/Pagination/PaginationItem.js.map +1 -0
  64. package/lib/module/components/Pagination/index.js +1 -1
  65. package/lib/module/components/Pagination/index.js.map +1 -1
  66. package/lib/module/components/ScrollViewGesture.js +1 -1
  67. package/lib/module/components/ScrollViewGesture.js.map +1 -1
  68. package/lib/module/constants/index.js +1 -1
  69. package/lib/module/constants/index.js.map +1 -1
  70. package/lib/module/hooks/useAutoPlay.js +1 -1
  71. package/lib/module/hooks/useAutoPlay.js.map +1 -1
  72. package/lib/module/hooks/useCarouselController.js +1 -1
  73. package/lib/module/hooks/useCarouselController.js.map +1 -1
  74. package/lib/module/hooks/useCheckMounted.js +1 -1
  75. package/lib/module/hooks/useCheckMounted.js.map +1 -1
  76. package/lib/module/hooks/useCommonVariables.js +1 -1
  77. package/lib/module/hooks/useCommonVariables.js.map +1 -1
  78. package/lib/module/hooks/useInitProps.js +1 -1
  79. package/lib/module/hooks/useInitProps.js.map +1 -1
  80. package/lib/module/hooks/useLayoutConfig.js +1 -1
  81. package/lib/module/hooks/useLayoutConfig.js.map +1 -1
  82. package/lib/module/hooks/useOffsetX.js +1 -1
  83. package/lib/module/hooks/useOffsetX.js.map +1 -1
  84. package/lib/module/hooks/useOnProgressChange.js +1 -1
  85. package/lib/module/hooks/useOnProgressChange.js.map +1 -1
  86. package/lib/module/hooks/usePanGestureProxy.js +1 -1
  87. package/lib/module/hooks/usePanGestureProxy.js.map +1 -1
  88. package/lib/module/hooks/usePropsErrorBoundary.js +1 -1
  89. package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
  90. package/lib/module/hooks/useUpdateGestureConfig.js +1 -1
  91. package/lib/module/hooks/useUpdateGestureConfig.js.map +1 -1
  92. package/lib/module/hooks/useVisibleRanges.js +1 -1
  93. package/lib/module/hooks/useVisibleRanges.js.map +1 -1
  94. package/lib/module/index.js +1 -1
  95. package/lib/module/index.js.map +1 -1
  96. package/lib/module/layouts/index.js +1 -1
  97. package/lib/module/layouts/index.js.map +1 -1
  98. package/lib/module/layouts/normal.js +1 -1
  99. package/lib/module/layouts/normal.js.map +1 -1
  100. package/lib/module/layouts/parallax.js +1 -1
  101. package/lib/module/layouts/parallax.js.map +1 -1
  102. package/lib/module/layouts/stack.js +1 -1
  103. package/lib/module/layouts/stack.js.map +1 -1
  104. package/lib/module/package.json +1 -0
  105. package/lib/module/public-types.js +2 -0
  106. package/lib/module/public-types.js.map +1 -0
  107. package/lib/module/store/index.js +1 -1
  108. package/lib/module/store/index.js.map +1 -1
  109. package/lib/module/types.js +1 -1
  110. package/lib/module/utils/carousel-direction.js +2 -0
  111. package/lib/module/utils/carousel-direction.js.map +1 -0
  112. package/lib/module/utils/carousel-math.js +2 -0
  113. package/lib/module/utils/carousel-math.js.map +1 -0
  114. package/lib/module/utils/compute-gesture-translation.js +1 -1
  115. package/lib/module/utils/compute-gesture-translation.js.map +1 -1
  116. package/lib/module/utils/compute-offset-if-size-changed.js +1 -1
  117. package/lib/module/utils/compute-offset-if-size-changed.js.map +1 -1
  118. package/lib/module/utils/computed-with-auto-fill-data.js +1 -1
  119. package/lib/module/utils/computed-with-auto-fill-data.js.map +1 -1
  120. package/lib/module/utils/deal-with-animation.js +1 -1
  121. package/lib/module/utils/deal-with-animation.js.map +1 -1
  122. package/lib/module/utils/log.js +1 -1
  123. package/lib/module/utils/log.js.map +1 -1
  124. package/lib/module/utils/sanitize-animation-style.js +1 -1
  125. package/lib/module/utils/sanitize-animation-style.js.map +1 -1
  126. package/lib/typescript/commonjs/components/Carousel.d.ts +8 -0
  127. package/lib/typescript/commonjs/components/Carousel.d.ts.map +1 -0
  128. package/lib/typescript/{components → commonjs/components}/CarouselLayout.d.ts +5 -8
  129. package/lib/typescript/commonjs/components/CarouselLayout.d.ts.map +1 -0
  130. package/lib/typescript/{components → commonjs/components}/ItemLayout.d.ts +7 -6
  131. package/lib/typescript/commonjs/components/ItemLayout.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/components/ItemRenderer.d.ts +24 -0
  133. package/lib/typescript/commonjs/components/ItemRenderer.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/components/LazyView.d.ts.map +1 -0
  135. package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts +14 -0
  136. package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts.map +1 -0
  137. package/lib/typescript/commonjs/components/Pagination/index.d.ts +4 -0
  138. package/lib/typescript/commonjs/components/Pagination/index.d.ts.map +1 -0
  139. package/lib/typescript/{components → commonjs/components}/ScrollViewGesture.d.ts +3 -4
  140. package/lib/typescript/commonjs/components/ScrollViewGesture.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/constants/index.d.ts.map +1 -0
  142. package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts +12 -0
  143. package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts.map +1 -0
  144. package/lib/typescript/commonjs/hooks/useCarouselController.d.ts +29 -0
  145. package/lib/typescript/commonjs/hooks/useCarouselController.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/hooks/useCheckMounted.d.ts.map +1 -0
  147. package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts +18 -0
  148. package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts.map +1 -0
  149. package/lib/typescript/commonjs/hooks/useInitProps.d.ts +25 -0
  150. package/lib/typescript/commonjs/hooks/useInitProps.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts +8 -0
  152. package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts.map +1 -0
  153. package/lib/typescript/commonjs/hooks/useOffsetX.d.ts +13 -0
  154. package/lib/typescript/commonjs/hooks/useOffsetX.d.ts.map +1 -0
  155. package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts +12 -0
  156. package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts.map +1 -0
  157. package/lib/typescript/{hooks → commonjs/hooks}/usePanGestureProxy.d.ts +3 -2
  158. package/lib/typescript/commonjs/hooks/usePanGestureProxy.d.ts.map +1 -0
  159. package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts +3 -0
  160. package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts.map +1 -0
  161. package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts +9 -0
  162. package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts.map +1 -0
  163. package/lib/typescript/{hooks → commonjs/hooks}/useVisibleRanges.d.ts +2 -2
  164. package/lib/typescript/commonjs/hooks/useVisibleRanges.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/index.d.ts +4 -0
  166. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  167. package/lib/typescript/{layouts → commonjs/layouts}/index.d.ts +0 -1
  168. package/lib/typescript/commonjs/layouts/index.d.ts.map +1 -0
  169. package/lib/typescript/{layouts → commonjs/layouts}/normal.d.ts +3 -1
  170. package/lib/typescript/commonjs/layouts/normal.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/layouts/parallax.d.ts +27 -0
  172. package/lib/typescript/commonjs/layouts/parallax.d.ts.map +1 -0
  173. package/lib/typescript/commonjs/layouts/stack.d.ts +10 -0
  174. package/lib/typescript/commonjs/layouts/stack.d.ts.map +1 -0
  175. package/lib/typescript/commonjs/package.json +1 -0
  176. package/lib/typescript/commonjs/public-types.d.ts +161 -0
  177. package/lib/typescript/commonjs/public-types.d.ts.map +1 -0
  178. package/lib/typescript/{store → commonjs/store}/index.d.ts +8 -8
  179. package/lib/typescript/commonjs/store/index.d.ts.map +1 -0
  180. package/lib/typescript/commonjs/types.d.ts +15 -0
  181. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  182. package/lib/typescript/commonjs/utils/carousel-direction.d.ts +9 -0
  183. package/lib/typescript/commonjs/utils/carousel-direction.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/utils/carousel-math.d.ts +28 -0
  185. package/lib/typescript/commonjs/utils/carousel-math.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/utils/compute-gesture-translation.d.ts.map +1 -0
  187. package/lib/typescript/commonjs/utils/compute-offset-if-size-changed.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/utils/computed-with-auto-fill-data.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/utils/deal-with-animation.d.ts +3 -0
  190. package/lib/typescript/commonjs/utils/deal-with-animation.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/utils/log.d.ts.map +1 -0
  192. package/lib/typescript/commonjs/utils/sanitize-animation-style.d.ts.map +1 -0
  193. package/lib/typescript/module/components/Carousel.d.ts +8 -0
  194. package/lib/typescript/module/components/Carousel.d.ts.map +1 -0
  195. package/lib/typescript/module/components/CarouselLayout.d.ts +14 -0
  196. package/lib/typescript/module/components/CarouselLayout.d.ts.map +1 -0
  197. package/lib/typescript/module/components/ItemLayout.d.ts +21 -0
  198. package/lib/typescript/module/components/ItemLayout.d.ts.map +1 -0
  199. package/lib/typescript/module/components/ItemRenderer.d.ts +24 -0
  200. package/lib/typescript/module/components/ItemRenderer.d.ts.map +1 -0
  201. package/lib/typescript/module/components/LazyView.d.ts +8 -0
  202. package/lib/typescript/module/components/LazyView.d.ts.map +1 -0
  203. package/lib/typescript/module/components/Pagination/PaginationItem.d.ts +14 -0
  204. package/lib/typescript/module/components/Pagination/PaginationItem.d.ts.map +1 -0
  205. package/lib/typescript/module/components/Pagination/index.d.ts +4 -0
  206. package/lib/typescript/module/components/Pagination/index.d.ts.map +1 -0
  207. package/lib/typescript/module/components/ScrollViewGesture.d.ts +18 -0
  208. package/lib/typescript/module/components/ScrollViewGesture.d.ts.map +1 -0
  209. package/lib/typescript/module/constants/index.d.ts +9 -0
  210. package/lib/typescript/module/constants/index.d.ts.map +1 -0
  211. package/lib/typescript/module/hooks/useAutoPlay.d.ts +12 -0
  212. package/lib/typescript/module/hooks/useAutoPlay.d.ts.map +1 -0
  213. package/lib/typescript/module/hooks/useCarouselController.d.ts +29 -0
  214. package/lib/typescript/module/hooks/useCarouselController.d.ts.map +1 -0
  215. package/lib/typescript/module/hooks/useCheckMounted.d.ts +3 -0
  216. package/lib/typescript/module/hooks/useCheckMounted.d.ts.map +1 -0
  217. package/lib/typescript/module/hooks/useCommonVariables.d.ts +18 -0
  218. package/lib/typescript/module/hooks/useCommonVariables.d.ts.map +1 -0
  219. package/lib/typescript/module/hooks/useInitProps.d.ts +25 -0
  220. package/lib/typescript/module/hooks/useInitProps.d.ts.map +1 -0
  221. package/lib/typescript/module/hooks/useLayoutConfig.d.ts +8 -0
  222. package/lib/typescript/module/hooks/useLayoutConfig.d.ts.map +1 -0
  223. package/lib/typescript/module/hooks/useOffsetX.d.ts +13 -0
  224. package/lib/typescript/module/hooks/useOffsetX.d.ts.map +1 -0
  225. package/lib/typescript/module/hooks/useOnProgressChange.d.ts +12 -0
  226. package/lib/typescript/module/hooks/useOnProgressChange.d.ts.map +1 -0
  227. package/lib/typescript/module/hooks/usePanGestureProxy.d.ts +11 -0
  228. package/lib/typescript/module/hooks/usePanGestureProxy.d.ts.map +1 -0
  229. package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts +3 -0
  230. package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts.map +1 -0
  231. package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts +9 -0
  232. package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts.map +1 -0
  233. package/lib/typescript/module/hooks/useVisibleRanges.d.ts +22 -0
  234. package/lib/typescript/module/hooks/useVisibleRanges.d.ts.map +1 -0
  235. package/lib/typescript/module/index.d.ts +4 -0
  236. package/lib/typescript/module/index.d.ts.map +1 -0
  237. package/lib/typescript/module/layouts/index.d.ts +10 -0
  238. package/lib/typescript/module/layouts/index.d.ts.map +1 -0
  239. package/lib/typescript/module/layouts/normal.d.ts +15 -0
  240. package/lib/typescript/module/layouts/normal.d.ts.map +1 -0
  241. package/lib/typescript/module/layouts/parallax.d.ts +27 -0
  242. package/lib/typescript/module/layouts/parallax.d.ts.map +1 -0
  243. package/lib/typescript/module/layouts/stack.d.ts +10 -0
  244. package/lib/typescript/module/layouts/stack.d.ts.map +1 -0
  245. package/lib/typescript/module/package.json +1 -0
  246. package/lib/typescript/module/public-types.d.ts +161 -0
  247. package/lib/typescript/module/public-types.d.ts.map +1 -0
  248. package/lib/typescript/module/store/index.d.ts +35 -0
  249. package/lib/typescript/module/store/index.d.ts.map +1 -0
  250. package/lib/typescript/module/types.d.ts +15 -0
  251. package/lib/typescript/module/types.d.ts.map +1 -0
  252. package/lib/typescript/module/utils/carousel-direction.d.ts +9 -0
  253. package/lib/typescript/module/utils/carousel-direction.d.ts.map +1 -0
  254. package/lib/typescript/module/utils/carousel-math.d.ts +28 -0
  255. package/lib/typescript/module/utils/carousel-math.d.ts.map +1 -0
  256. package/lib/typescript/module/utils/compute-gesture-translation.d.ts +9 -0
  257. package/lib/typescript/module/utils/compute-gesture-translation.d.ts.map +1 -0
  258. package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts +6 -0
  259. package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts.map +1 -0
  260. package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts +23 -0
  261. package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts.map +1 -0
  262. package/lib/typescript/module/utils/deal-with-animation.d.ts +3 -0
  263. package/lib/typescript/module/utils/deal-with-animation.d.ts.map +1 -0
  264. package/lib/typescript/module/utils/log.d.ts +7 -0
  265. package/lib/typescript/module/utils/log.d.ts.map +1 -0
  266. package/lib/typescript/module/utils/sanitize-animation-style.d.ts +3 -0
  267. package/lib/typescript/module/utils/sanitize-animation-style.d.ts.map +1 -0
  268. package/package.json +34 -7
  269. package/scripts/codemods/v5.mjs +502 -0
  270. package/src/components/Carousel.tsx +5 -5
  271. package/src/components/CarouselLayout.tsx +53 -91
  272. package/src/components/ItemLayout.tsx +55 -46
  273. package/src/components/ItemRenderer.tsx +29 -18
  274. package/src/components/Pagination/PaginationItem.tsx +162 -0
  275. package/src/components/Pagination/index.tsx +105 -6
  276. package/src/components/ScrollViewGesture.tsx +92 -177
  277. package/src/hooks/useAutoPlay.ts +23 -18
  278. package/src/hooks/useCarouselController.tsx +194 -340
  279. package/src/hooks/useCommonVariables.ts +159 -71
  280. package/src/hooks/useInitProps.ts +161 -71
  281. package/src/hooks/useLayoutConfig.ts +21 -12
  282. package/src/hooks/useOffsetX.ts +3 -3
  283. package/src/hooks/useOnProgressChange.ts +23 -48
  284. package/src/hooks/usePanGestureProxy.ts +2 -2
  285. package/src/hooks/usePropsErrorBoundary.ts +32 -90
  286. package/src/hooks/useUpdateGestureConfig.ts +5 -2
  287. package/src/hooks/useVisibleRanges.tsx +2 -2
  288. package/src/index.tsx +14 -9
  289. package/src/layouts/index.tsx +0 -2
  290. package/src/layouts/normal.ts +14 -4
  291. package/src/layouts/parallax.ts +32 -59
  292. package/src/layouts/stack.ts +30 -70
  293. package/src/public-types.ts +198 -0
  294. package/src/store/index.tsx +7 -7
  295. package/src/types.ts +30 -322
  296. package/src/utils/carousel-direction.ts +39 -0
  297. package/src/utils/carousel-math.ts +156 -0
  298. package/src/utils/deal-with-animation.ts +11 -9
  299. package/lib/commonjs/components/Pagination/Basic/PaginationItem.js +0 -2
  300. package/lib/commonjs/components/Pagination/Basic/PaginationItem.js.map +0 -1
  301. package/lib/commonjs/components/Pagination/Basic/index.js +0 -2
  302. package/lib/commonjs/components/Pagination/Basic/index.js.map +0 -1
  303. package/lib/commonjs/components/Pagination/Custom/PaginationItem.js +0 -2
  304. package/lib/commonjs/components/Pagination/Custom/PaginationItem.js.map +0 -1
  305. package/lib/commonjs/components/Pagination/Custom/index.js +0 -2
  306. package/lib/commonjs/components/Pagination/Custom/index.js.map +0 -1
  307. package/lib/commonjs/utils/compute-offset-if-data-changed.js +0 -2
  308. package/lib/commonjs/utils/compute-offset-if-data-changed.js.map +0 -1
  309. package/lib/commonjs/utils/handleroffset-direction.js +0 -2
  310. package/lib/commonjs/utils/handleroffset-direction.js.map +0 -1
  311. package/lib/module/components/Pagination/Basic/PaginationItem.js +0 -2
  312. package/lib/module/components/Pagination/Basic/PaginationItem.js.map +0 -1
  313. package/lib/module/components/Pagination/Basic/index.js +0 -2
  314. package/lib/module/components/Pagination/Basic/index.js.map +0 -1
  315. package/lib/module/components/Pagination/Custom/PaginationItem.js +0 -2
  316. package/lib/module/components/Pagination/Custom/PaginationItem.js.map +0 -1
  317. package/lib/module/components/Pagination/Custom/index.js +0 -2
  318. package/lib/module/components/Pagination/Custom/index.js.map +0 -1
  319. package/lib/module/utils/compute-offset-if-data-changed.js +0 -2
  320. package/lib/module/utils/compute-offset-if-data-changed.js.map +0 -1
  321. package/lib/module/utils/handleroffset-direction.js +0 -2
  322. package/lib/module/utils/handleroffset-direction.js.map +0 -1
  323. package/lib/typescript/components/Carousel.d.ts +0 -8
  324. package/lib/typescript/components/Carousel.d.ts.map +0 -1
  325. package/lib/typescript/components/CarouselLayout.d.ts.map +0 -1
  326. package/lib/typescript/components/ItemLayout.d.ts.map +0 -1
  327. package/lib/typescript/components/ItemRenderer.d.ts +0 -23
  328. package/lib/typescript/components/ItemRenderer.d.ts.map +0 -1
  329. package/lib/typescript/components/LazyView.d.ts.map +0 -1
  330. package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts +0 -29
  331. package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts.map +0 -1
  332. package/lib/typescript/components/Pagination/Basic/index.d.ts +0 -23
  333. package/lib/typescript/components/Pagination/Basic/index.d.ts.map +0 -1
  334. package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts +0 -35
  335. package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts.map +0 -1
  336. package/lib/typescript/components/Pagination/Custom/index.d.ts +0 -26
  337. package/lib/typescript/components/Pagination/Custom/index.d.ts.map +0 -1
  338. package/lib/typescript/components/Pagination/index.d.ts +0 -5
  339. package/lib/typescript/components/Pagination/index.d.ts.map +0 -1
  340. package/lib/typescript/components/ScrollViewGesture.d.ts.map +0 -1
  341. package/lib/typescript/constants/index.d.ts.map +0 -1
  342. package/lib/typescript/hooks/useAutoPlay.d.ts +0 -12
  343. package/lib/typescript/hooks/useAutoPlay.d.ts.map +0 -1
  344. package/lib/typescript/hooks/useCarouselController.d.ts +0 -28
  345. package/lib/typescript/hooks/useCarouselController.d.ts.map +0 -1
  346. package/lib/typescript/hooks/useCheckMounted.d.ts.map +0 -1
  347. package/lib/typescript/hooks/useCommonVariables.d.ts +0 -13
  348. package/lib/typescript/hooks/useCommonVariables.d.ts.map +0 -1
  349. package/lib/typescript/hooks/useInitProps.d.ts +0 -10
  350. package/lib/typescript/hooks/useInitProps.d.ts.map +0 -1
  351. package/lib/typescript/hooks/useLayoutConfig.d.ts +0 -8
  352. package/lib/typescript/hooks/useLayoutConfig.d.ts.map +0 -1
  353. package/lib/typescript/hooks/useOffsetX.d.ts +0 -13
  354. package/lib/typescript/hooks/useOffsetX.d.ts.map +0 -1
  355. package/lib/typescript/hooks/useOnProgressChange.d.ts +0 -11
  356. package/lib/typescript/hooks/useOnProgressChange.d.ts.map +0 -1
  357. package/lib/typescript/hooks/usePanGestureProxy.d.ts.map +0 -1
  358. package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +0 -5
  359. package/lib/typescript/hooks/usePropsErrorBoundary.d.ts.map +0 -1
  360. package/lib/typescript/hooks/useUpdateGestureConfig.d.ts +0 -6
  361. package/lib/typescript/hooks/useUpdateGestureConfig.d.ts.map +0 -1
  362. package/lib/typescript/hooks/useVisibleRanges.d.ts.map +0 -1
  363. package/lib/typescript/index.d.ts +0 -7
  364. package/lib/typescript/index.d.ts.map +0 -1
  365. package/lib/typescript/layouts/index.d.ts.map +0 -1
  366. package/lib/typescript/layouts/normal.d.ts.map +0 -1
  367. package/lib/typescript/layouts/parallax.d.ts +0 -47
  368. package/lib/typescript/layouts/parallax.d.ts.map +0 -1
  369. package/lib/typescript/layouts/stack.d.ts +0 -38
  370. package/lib/typescript/layouts/stack.d.ts.map +0 -1
  371. package/lib/typescript/store/index.d.ts.map +0 -1
  372. package/lib/typescript/types.d.ts +0 -302
  373. package/lib/typescript/types.d.ts.map +0 -1
  374. package/lib/typescript/utils/compute-gesture-translation.d.ts.map +0 -1
  375. package/lib/typescript/utils/compute-offset-if-data-changed.d.ts +0 -9
  376. package/lib/typescript/utils/compute-offset-if-data-changed.d.ts.map +0 -1
  377. package/lib/typescript/utils/compute-offset-if-size-changed.d.ts.map +0 -1
  378. package/lib/typescript/utils/computed-with-auto-fill-data.d.ts.map +0 -1
  379. package/lib/typescript/utils/deal-with-animation.d.ts +0 -3
  380. package/lib/typescript/utils/deal-with-animation.d.ts.map +0 -1
  381. package/lib/typescript/utils/handleroffset-direction.d.ts +0 -4
  382. package/lib/typescript/utils/handleroffset-direction.d.ts.map +0 -1
  383. package/lib/typescript/utils/log.d.ts.map +0 -1
  384. package/lib/typescript/utils/sanitize-animation-style.d.ts.map +0 -1
  385. package/src/components/Carousel.test.tsx +0 -1215
  386. package/src/components/LazyView.test.tsx +0 -61
  387. package/src/components/Pagination/Basic/PaginationItem.tsx +0 -149
  388. package/src/components/Pagination/Basic/index.tsx +0 -98
  389. package/src/components/Pagination/Custom/PaginationItem.tsx +0 -166
  390. package/src/components/Pagination/Custom/index.tsx +0 -111
  391. package/src/components/Pagination/Pagination.test.tsx +0 -178
  392. package/src/components/ScrollViewGesture.test.tsx +0 -155
  393. package/src/components/issue-899-parallax-reverse-loop.test.tsx +0 -131
  394. package/src/components/rnr-demo.test.tsx +0 -53
  395. package/src/hooks/useAutoPlay.test.ts +0 -194
  396. package/src/hooks/useCarouselController.test.tsx +0 -1158
  397. package/src/hooks/useCheckMounted.test.ts +0 -47
  398. package/src/hooks/useCommonVariables.test.tsx +0 -384
  399. package/src/hooks/useInitProps.test.tsx +0 -134
  400. package/src/hooks/useLayoutConfig.test.tsx +0 -247
  401. package/src/hooks/useOffsetX.test.ts +0 -54
  402. package/src/hooks/useOnProgressChange.test.tsx +0 -270
  403. package/src/hooks/usePanGestureProxy.test.tsx +0 -368
  404. package/src/hooks/usePropsErrorBoundary.test.tsx +0 -57
  405. package/src/hooks/useUpdateGestureConfig.test.ts +0 -89
  406. package/src/hooks/useVisibleRanges.test.tsx +0 -347
  407. package/src/layouts/parallax.test.ts +0 -239
  408. package/src/layouts/stack.test.ts +0 -252
  409. package/src/store/index.test.tsx +0 -314
  410. package/src/utils/compute-gesture-translation.test.ts +0 -70
  411. package/src/utils/compute-offset-if-data-changed.test.ts +0 -133
  412. package/src/utils/compute-offset-if-data-changed.ts +0 -44
  413. package/src/utils/compute-offset-if-size-changed.test.ts +0 -78
  414. package/src/utils/computed-with-auto-fill-data.test.ts +0 -298
  415. package/src/utils/deal-with-animation.test.ts +0 -181
  416. package/src/utils/handleroffset-direction.test.ts +0 -124
  417. package/src/utils/handleroffset-direction.ts +0 -18
  418. package/src/utils/index.test.ts +0 -90
  419. package/src/utils/log.test.ts +0 -134
  420. package/src/utils/sanitize-animation-style.test.ts +0 -40
  421. /package/lib/typescript/{components → commonjs/components}/LazyView.d.ts +0 -0
  422. /package/lib/typescript/{constants → commonjs/constants}/index.d.ts +0 -0
  423. /package/lib/typescript/{hooks → commonjs/hooks}/useCheckMounted.d.ts +0 -0
  424. /package/lib/typescript/{utils → commonjs/utils}/compute-gesture-translation.d.ts +0 -0
  425. /package/lib/typescript/{utils → commonjs/utils}/compute-offset-if-size-changed.d.ts +0 -0
  426. /package/lib/typescript/{utils → commonjs/utils}/computed-with-auto-fill-data.d.ts +0 -0
  427. /package/lib/typescript/{utils → commonjs/utils}/log.d.ts +0 -0
  428. /package/lib/typescript/{utils → commonjs/utils}/sanitize-animation-style.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { PropsWithChildren } from "react";
2
2
  import React, { useCallback } from "react";
3
- import type { LayoutChangeEvent, StyleProp, ViewStyle } from "react-native";
3
+ import type { LayoutChangeEvent, ViewProps } from "react-native";
4
4
  import type {
5
5
  GestureStateChangeEvent,
6
6
  PanGestureHandlerEventPayload,
@@ -13,13 +13,12 @@ import Animated, {
13
13
  useSharedValue,
14
14
  withDecay,
15
15
  } from "react-native-reanimated";
16
- import type { SharedValue } from "react-native-reanimated";
16
+ import type { AnimatedProps, SharedValue } from "react-native-reanimated";
17
17
  import { scheduleOnRN } from "react-native-worklets";
18
18
 
19
- import { Easing } from "../constants";
20
19
  import { usePanGestureProxy } from "../hooks/usePanGestureProxy";
21
20
  import { useGlobalState } from "../store";
22
- import type { WithTimingAnimation } from "../types";
21
+ import { toLogicalGestureValue } from "../utils/carousel-direction";
23
22
  import { computeGestureTranslation } from "../utils/compute-gesture-translation";
24
23
  import { dealWithAnimation } from "../utils/deal-with-animation";
25
24
 
@@ -27,9 +26,8 @@ interface Props {
27
26
  size: number;
28
27
  infinite?: boolean;
29
28
  testID?: string;
30
- style?: StyleProp<ViewStyle>;
29
+ style?: AnimatedProps<ViewProps>["style"];
31
30
  translation: SharedValue<number>;
32
- onLayout?: (e: LayoutChangeEvent) => void;
33
31
  onScrollStart?: () => void;
34
32
  onScrollEnd?: () => void;
35
33
  onTouchBegin?: () => void;
@@ -40,18 +38,14 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
40
38
  const {
41
39
  props: {
42
40
  onConfigurePanGesture,
43
- vertical,
44
- pagingEnabled,
45
- snapEnabled,
41
+ orientation,
42
+ snapMode,
46
43
  loop,
47
- scrollAnimationDuration,
48
- withAnimation,
49
- enabled,
44
+ animation,
45
+ scrollEnabled,
50
46
  dataLength,
51
47
  overscrollEnabled,
52
- maxScrollDistancePerSwipe,
53
- minScrollDistancePerSwipe,
54
- fixedDirection,
48
+ directionSign,
55
49
  },
56
50
  common: { size, resolvedSize, sizePhase, sizeExplicit },
57
51
  layout: { containerSize, updateContainerSize },
@@ -66,17 +60,17 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
66
60
  onTouchBegin,
67
61
  onTouchEnd,
68
62
  } = props;
63
+ const isVertical = orientation === "vertical";
69
64
 
70
65
  const maxPage = dataLength;
71
- const isHorizontal = useDerivedValue(() => !vertical, [vertical]);
66
+ const isHorizontal = useDerivedValue(() => !isVertical, [isVertical]);
72
67
  const max = useSharedValue(0);
73
68
  const panOffset = useSharedValue<number | undefined>(undefined); // set to undefined when not actively in a pan gesture
74
69
  const touching = useSharedValue(false);
75
70
  const validStart = useSharedValue(false);
71
+ const hasStartedMovement = useSharedValue(false);
76
72
  const scrollEndTranslation = useSharedValue(0);
77
73
  const scrollEndVelocity = useSharedValue(0);
78
- const maxScrollDistancePerSwipeIsSet = typeof maxScrollDistancePerSwipe === "number";
79
- const minScrollDistancePerSwipeIsSet = typeof minScrollDistancePerSwipe === "number";
80
74
  const sizeReady = useDerivedValue(() => {
81
75
  const currentSize = resolvedSize.value ?? 0;
82
76
  return sizePhase.value === "ready" && currentSize > 0;
@@ -89,7 +83,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
89
83
  if (size <= 0) return 0;
90
84
 
91
85
  if (!loop && !overscrollEnabled) {
92
- const containerMainAxisSize = vertical
86
+ const containerMainAxisSize = isVertical
93
87
  ? containerSize.value.height
94
88
  : containerSize.value.width;
95
89
 
@@ -101,28 +95,17 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
101
95
  }
102
96
 
103
97
  return dataLength * size;
104
- }, [loop, size, dataLength, overscrollEnabled, vertical, containerSize]);
98
+ }, [loop, size, dataLength, overscrollEnabled, isVertical, containerSize]);
105
99
 
106
100
  const withSpring = React.useCallback(
107
101
  (toValue: number, onFinished?: () => void) => {
108
102
  "worklet";
109
- const defaultWithAnimation: WithTimingAnimation = {
110
- type: "timing",
111
- config: {
112
- duration: scrollAnimationDuration + 100,
113
- easing: Easing.easeOutQuart,
114
- },
115
- };
116
-
117
- return dealWithAnimation(withAnimation ?? defaultWithAnimation)(
118
- toValue,
119
- (isFinished: boolean) => {
120
- "worklet";
121
- if (isFinished) onFinished && scheduleOnRN(onFinished);
122
- }
123
- );
103
+ return dealWithAnimation(animation)(toValue, (isFinished: boolean) => {
104
+ "worklet";
105
+ if (isFinished) onFinished && scheduleOnRN(onFinished);
106
+ });
124
107
  },
125
- [scrollAnimationDuration, withAnimation]
108
+ [animation]
126
109
  );
127
110
 
128
111
  const endWithSpring = React.useCallback(
@@ -141,66 +124,54 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
141
124
  const origin = translation.value;
142
125
  const velocity = scrollEndVelocityValue;
143
126
  // Default to scroll in the direction of the slide (with deceleration)
144
- let finalTranslation: number = withDecay({ velocity, deceleration: 0.999 });
145
-
146
- // If the distance of the swipe exceeds the max scroll distance, keep the view at the current position
147
- if (
148
- maxScrollDistancePerSwipeIsSet &&
149
- Math.abs(scrollEndTranslationValue) > maxScrollDistancePerSwipe
150
- ) {
151
- finalTranslation = origin;
152
- } else {
153
- /**
154
- * The page size is the same as the item size.
155
- * If direction is vertical, the page size is the height of the item.
156
- * If direction is horizontal, the page size is the width of the item.
157
- *
158
- * `page size` equals to `currentSize` variable.
159
- * */
160
-
161
- // calculate target "nextPage" based on the final pan position and the velocity of
162
- // the pan gesture at termination; this allows for a quick "flick" to indicate a far
163
- // off page change.
164
- const nextPage = -Math.round((origin + velocity * 2) / currentSize);
165
-
166
- if (pagingEnabled) {
167
- // we'll never go further than a single page away from the current page when paging
168
- // is enabled.
169
-
170
- // distance with direction
171
- const offset = -(scrollEndTranslationValue >= 0 ? 1 : -1); // 1 or -1
172
- const computed = offset < 0 ? Math.ceil : Math.floor;
173
- const page = computed(-origin / currentSize);
174
-
175
- const velocityDirection = -Math.sign(velocity);
176
- if (page === nextPage || velocityDirection !== offset) {
177
- // not going anywhere! Velocity was insufficient to overcome the distance to get to a
178
- // further page. Let's reset gently to the current page.
179
- finalTranslation = withSpring(withProcessTranslation(-page * currentSize), onFinished);
180
- } else if (loop) {
181
- const finalPage = page + offset;
182
- finalTranslation = withSpring(
183
- withProcessTranslation(-finalPage * currentSize),
184
- onFinished
185
- );
186
- } else {
187
- const finalPage = Math.min(maxPage - 1, Math.max(0, page + offset));
188
- finalTranslation = withSpring(
189
- withProcessTranslation(-finalPage * currentSize),
190
- onFinished
191
- );
192
- }
193
- }
127
+ let finalTranslation: number = withDecay({ velocity, deceleration: 0.999 }, (isFinished) => {
128
+ if (isFinished && onFinished) scheduleOnRN(onFinished);
129
+ });
130
+
131
+ /**
132
+ * The page size is the same as the item size.
133
+ * If direction is vertical, the page size is the height of the item.
134
+ * If direction is horizontal, the page size is the width of the item.
135
+ *
136
+ * `page size` equals to `currentSize` variable.
137
+ */
194
138
 
195
- if (!pagingEnabled && snapEnabled) {
196
- // scroll to the nearest item
139
+ // Calculate target based on final pan position and velocity.
140
+ const nextPage = -Math.round((origin + velocity * 2) / currentSize);
141
+
142
+ if (snapMode === "page") {
143
+ // we'll never go further than a single page away from the current page when paging
144
+ // is enabled.
145
+
146
+ // distance with direction
147
+ const offset = -(scrollEndTranslationValue >= 0 ? 1 : -1); // 1 or -1
148
+ const computed = offset < 0 ? Math.ceil : Math.floor;
149
+ const page = computed(-origin / currentSize);
150
+
151
+ const velocityDirection = -Math.sign(velocity);
152
+ if (page === nextPage || velocityDirection !== offset) {
153
+ // not going anywhere! Velocity was insufficient to overcome the distance to get to a
154
+ // further page. Let's reset gently to the current page.
155
+ finalTranslation = withSpring(withProcessTranslation(-page * currentSize), onFinished);
156
+ } else if (loop) {
157
+ const finalPage = page + offset;
158
+ finalTranslation = withSpring(
159
+ withProcessTranslation(-finalPage * currentSize),
160
+ onFinished
161
+ );
162
+ } else {
163
+ const finalPage = Math.min(maxPage - 1, Math.max(0, page + offset));
197
164
  finalTranslation = withSpring(
198
- withProcessTranslation(-nextPage * currentSize),
165
+ withProcessTranslation(-finalPage * currentSize),
199
166
  onFinished
200
167
  );
201
168
  }
202
169
  }
203
170
 
171
+ if (snapMode === "nearest") {
172
+ finalTranslation = withSpring(withProcessTranslation(-nextPage * currentSize), onFinished);
173
+ }
174
+
204
175
  translation.value = finalTranslation;
205
176
 
206
177
  function withProcessTranslation(translation: number) {
@@ -212,17 +183,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
212
183
  return translation;
213
184
  }
214
185
  },
215
- [
216
- withSpring,
217
- resolvedSize,
218
- maxPage,
219
- loop,
220
- snapEnabled,
221
- translation,
222
- pagingEnabled,
223
- maxScrollDistancePerSwipe,
224
- maxScrollDistancePerSwipeIsSet,
225
- ]
186
+ [withSpring, resolvedSize, maxPage, loop, snapMode, translation]
226
187
  );
227
188
 
228
189
  const onFinish = React.useCallback(
@@ -270,36 +231,16 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
270
231
  }
271
232
  if (!loop) translation.value = withSpring(-((maxPage - 1) * currentSize));
272
233
  }
273
- }, [
274
- touching,
275
- translation,
276
- maxPage,
277
- resolvedSize,
278
- scrollEndTranslation,
279
- loop,
280
- activeDecay,
281
- withSpring,
282
- ]);
234
+ }, [touching, translation, resolvedSize, scrollEndTranslation, loop, activeDecay, withSpring]);
283
235
 
284
236
  useAnimatedReaction(
285
237
  () => translation.value,
286
238
  () => {
287
- if (!pagingEnabled) resetBoundary();
239
+ if (snapMode !== "page") resetBoundary();
288
240
  },
289
- [pagingEnabled, resetBoundary]
241
+ [resetBoundary, snapMode]
290
242
  );
291
243
 
292
- function withProcessTranslation(translation: number) {
293
- "worklet";
294
-
295
- if (!loop && !overscrollEnabled) {
296
- const limit = getLimit();
297
- return Math.min(0, Math.max(-limit, translation));
298
- }
299
-
300
- return translation;
301
- }
302
-
303
244
  const onGestureStart = useCallback(
304
245
  (_: PanGestureHandlerEventPayload) => {
305
246
  "worklet";
@@ -311,7 +252,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
311
252
  }
312
253
  touching.value = true;
313
254
  validStart.value = true;
314
- onScrollStart && scheduleOnRN(onScrollStart);
255
+ hasStartedMovement.value = false;
315
256
 
316
257
  max.value = (maxPage - 1) * currentSize;
317
258
  if (!loop && !overscrollEnabled) max.value = getLimit();
@@ -328,7 +269,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
328
269
  translation,
329
270
  overscrollEnabled,
330
271
  getLimit,
331
- onScrollStart,
272
+ hasStartedMovement,
332
273
  sizeReady,
333
274
  resolvedSize,
334
275
  ]
@@ -362,10 +303,12 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
362
303
  touching.value = true;
363
304
  const { translationX, translationY } = e;
364
305
 
365
- let panTranslation = isHorizontal.value ? translationX : translationY;
366
-
367
- if (fixedDirection === "negative") panTranslation = -Math.abs(panTranslation);
368
- else if (fixedDirection === "positive") panTranslation = +Math.abs(panTranslation);
306
+ const physicalPanTranslation = isHorizontal.value ? translationX : translationY;
307
+ const panTranslation = toLogicalGestureValue(physicalPanTranslation, directionSign);
308
+ if (!hasStartedMovement.value && panTranslation !== 0) {
309
+ hasStartedMovement.value = true;
310
+ if (onScrollStart) scheduleOnRN(onScrollStart);
311
+ }
369
312
 
370
313
  translation.value = computeGestureTranslation({
371
314
  loop,
@@ -382,12 +325,14 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
382
325
  panOffset,
383
326
  loop,
384
327
  overscrollEnabled,
385
- fixedDirection,
328
+ hasStartedMovement,
329
+ onScrollStart,
386
330
  translation,
387
331
  validStart,
388
332
  touching,
389
333
  sizeReady,
390
334
  resolvedSize,
335
+ directionSign,
391
336
  ]
392
337
  );
393
338
 
@@ -407,50 +352,23 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
407
352
  return;
408
353
  }
409
354
 
355
+ if (!hasStartedMovement.value) {
356
+ touching.value = false;
357
+ panOffset.value = undefined;
358
+ return;
359
+ }
360
+
410
361
  const { velocityX, velocityY, translationX, translationY } = e;
411
- const scrollEndVelocityValue = isHorizontal.value ? velocityX : velocityY;
362
+ const physicalVelocity = isHorizontal.value ? velocityX : velocityY;
363
+ const scrollEndVelocityValue = toLogicalGestureValue(physicalVelocity, directionSign);
412
364
  scrollEndVelocity.value = scrollEndVelocityValue; // may update async: see https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue#remarks
413
365
 
414
- let panTranslation = isHorizontal.value ? translationX : translationY;
415
-
416
- if (fixedDirection === "negative") panTranslation = -Math.abs(panTranslation);
417
- else if (fixedDirection === "positive") panTranslation = +Math.abs(panTranslation);
366
+ const physicalPanTranslation = isHorizontal.value ? translationX : translationY;
367
+ const panTranslation = toLogicalGestureValue(physicalPanTranslation, directionSign);
418
368
 
419
369
  scrollEndTranslation.value = panTranslation; // may update async: see https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue#remarks
420
370
 
421
- const totalTranslation = scrollEndVelocityValue + panTranslation;
422
-
423
- /**
424
- * If the maximum scroll distance is set and the translation `exceeds the maximum scroll distance`,
425
- * the carousel will keep the view at the current position.
426
- */
427
- if (
428
- maxScrollDistancePerSwipeIsSet &&
429
- Math.abs(totalTranslation) > maxScrollDistancePerSwipe
430
- ) {
431
- const nextPage =
432
- Math.round(
433
- (panOffset.value + maxScrollDistancePerSwipe * Math.sign(totalTranslation)) /
434
- currentSize
435
- ) * currentSize;
436
- translation.value = withSpring(withProcessTranslation(nextPage), onScrollEnd);
437
- } else if (
438
- /**
439
- * If the minimum scroll distance is set and the translation `didn't exceeds the minimum scroll distance`,
440
- * the carousel will keep the view at the current position.
441
- */
442
- minScrollDistancePerSwipeIsSet &&
443
- Math.abs(totalTranslation) < minScrollDistancePerSwipe
444
- ) {
445
- const nextPage =
446
- Math.round(
447
- (panOffset.value + minScrollDistancePerSwipe * Math.sign(totalTranslation)) /
448
- currentSize
449
- ) * currentSize;
450
- translation.value = withSpring(withProcessTranslation(nextPage), onScrollEnd);
451
- } else {
452
- endWithSpring(panTranslation, scrollEndVelocityValue, onScrollEnd);
453
- }
371
+ endWithSpring(panTranslation, scrollEndVelocityValue, onScrollEnd);
454
372
 
455
373
  if (!loop) touching.value = false;
456
374
 
@@ -464,16 +382,12 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
464
382
  isHorizontal,
465
383
  scrollEndVelocity,
466
384
  scrollEndTranslation,
467
- fixedDirection,
468
- maxScrollDistancePerSwipeIsSet,
469
- maxScrollDistancePerSwipe,
470
- minScrollDistancePerSwipeIsSet,
471
- minScrollDistancePerSwipe,
472
385
  endWithSpring,
473
- withSpring,
474
386
  onScrollEnd,
387
+ hasStartedMovement,
475
388
  sizeReady,
476
389
  resolvedSize,
390
+ directionSign,
477
391
  ]
478
392
  );
479
393
 
@@ -482,7 +396,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
482
396
  onGestureStart,
483
397
  onGestureUpdate,
484
398
  onGestureEnd,
485
- options: { enabled },
399
+ options: { enabled: scrollEnabled },
486
400
  });
487
401
 
488
402
  const onLayout = React.useCallback(
@@ -491,7 +405,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
491
405
 
492
406
  const measuredWidth = e.nativeEvent.layout.width;
493
407
  const measuredHeight = e.nativeEvent.layout.height;
494
- const measuredSize = Math.round((vertical ? measuredHeight : measuredWidth) || 0);
408
+ const measuredSize = Math.round((isVertical ? measuredHeight : measuredWidth) || 0);
495
409
 
496
410
  if (!sizeExplicit && measuredSize > 0) {
497
411
  const current = resolvedSize.value ?? 0;
@@ -507,7 +421,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
507
421
  height: measuredHeight,
508
422
  });
509
423
  },
510
- [updateContainerSize, resolvedSize, sizePhase, vertical, sizeExplicit]
424
+ [updateContainerSize, resolvedSize, sizePhase, isVertical, sizeExplicit]
511
425
  );
512
426
 
513
427
  return (
@@ -517,6 +431,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
517
431
  style={style}
518
432
  onTouchStart={onTouchBegin}
519
433
  onTouchEnd={onTouchEnd}
434
+ onTouchCancel={onTouchEnd}
520
435
  onLayout={onLayout}
521
436
  >
522
437
  {props.children}
@@ -1,18 +1,22 @@
1
1
  import * as React from "react";
2
2
 
3
- import type { ICarouselController } from "./useCarouselController";
3
+ import type { CarouselController } from "./useCarouselController";
4
4
 
5
- export function useAutoPlay(opts: {
6
- autoPlay?: boolean;
7
- autoPlayInterval?: number;
8
- autoPlayReverse?: boolean;
9
- carouselController: ICarouselController;
5
+ export function useAutoPlay(options: {
6
+ autoplay?: boolean;
7
+ autoplayInterval?: number;
8
+ autoplayDirection?: "forward" | "backward";
9
+ carouselController: CarouselController;
10
10
  }) {
11
- const { autoPlay = false, autoPlayReverse = false, autoPlayInterval, carouselController } = opts;
12
-
11
+ const {
12
+ autoplay = false,
13
+ autoplayDirection = "forward",
14
+ autoplayInterval,
15
+ carouselController,
16
+ } = options;
13
17
  const { prev, next } = carouselController;
14
18
  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);
15
- const stopped = React.useRef<boolean>(!autoPlay);
19
+ const stopped = React.useRef(!autoplay);
16
20
 
17
21
  const play = React.useCallback(() => {
18
22
  if (stopped.current) return;
@@ -22,33 +26,34 @@ export function useAutoPlay(opts: {
22
26
  timer.current = null;
23
27
  }
24
28
  timer.current = setTimeout(() => {
25
- autoPlayReverse ? prev({ onFinished: play }) : next({ onFinished: play });
26
- }, autoPlayInterval);
27
- }, [autoPlayReverse, autoPlayInterval, prev, next]);
29
+ if (autoplayDirection === "backward") prev({ onFinished: play });
30
+ else next({ onFinished: play });
31
+ }, autoplayInterval);
32
+ }, [autoplayDirection, autoplayInterval, next, prev]);
28
33
 
29
34
  const pause = React.useCallback(() => {
30
- if (!autoPlay) return;
35
+ if (!autoplay) return;
31
36
 
32
37
  if (timer.current) {
33
38
  clearTimeout(timer.current);
34
39
  timer.current = null;
35
40
  }
36
41
  stopped.current = true;
37
- }, [autoPlay]);
42
+ }, [autoplay]);
38
43
 
39
44
  const start = React.useCallback(() => {
40
- if (!autoPlay) return;
45
+ if (!autoplay) return;
41
46
 
42
47
  stopped.current = false;
43
48
  play();
44
- }, [play, autoPlay]);
49
+ }, [autoplay, play]);
45
50
 
46
51
  React.useEffect(() => {
47
- if (autoPlay) start();
52
+ if (autoplay) start();
48
53
  else pause();
49
54
 
50
55
  return pause;
51
- }, [pause, start, autoPlay]);
56
+ }, [autoplay, pause, start]);
52
57
 
53
58
  return {
54
59
  pause,