@leonsilicon/react-native-reanimated-carousel 0.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 (328) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +652 -0
  3. package/lib/commonjs/components/Carousel.js +2 -0
  4. package/lib/commonjs/components/Carousel.js.map +1 -0
  5. package/lib/commonjs/components/CarouselLayout.js +2 -0
  6. package/lib/commonjs/components/CarouselLayout.js.map +1 -0
  7. package/lib/commonjs/components/ItemLayout.js +2 -0
  8. package/lib/commonjs/components/ItemLayout.js.map +1 -0
  9. package/lib/commonjs/components/ItemRenderer.js +2 -0
  10. package/lib/commonjs/components/ItemRenderer.js.map +1 -0
  11. package/lib/commonjs/components/LazyView.js +2 -0
  12. package/lib/commonjs/components/LazyView.js.map +1 -0
  13. package/lib/commonjs/components/Pagination/Basic/PaginationItem.js +2 -0
  14. package/lib/commonjs/components/Pagination/Basic/PaginationItem.js.map +1 -0
  15. package/lib/commonjs/components/Pagination/Basic/index.js +2 -0
  16. package/lib/commonjs/components/Pagination/Basic/index.js.map +1 -0
  17. package/lib/commonjs/components/Pagination/Custom/PaginationItem.js +2 -0
  18. package/lib/commonjs/components/Pagination/Custom/PaginationItem.js.map +1 -0
  19. package/lib/commonjs/components/Pagination/Custom/index.js +2 -0
  20. package/lib/commonjs/components/Pagination/Custom/index.js.map +1 -0
  21. package/lib/commonjs/components/Pagination/index.js +2 -0
  22. package/lib/commonjs/components/Pagination/index.js.map +1 -0
  23. package/lib/commonjs/components/ScrollViewGesture.js +2 -0
  24. package/lib/commonjs/components/ScrollViewGesture.js.map +1 -0
  25. package/lib/commonjs/constants/index.js +2 -0
  26. package/lib/commonjs/constants/index.js.map +1 -0
  27. package/lib/commonjs/hooks/useAutoPlay.js +2 -0
  28. package/lib/commonjs/hooks/useAutoPlay.js.map +1 -0
  29. package/lib/commonjs/hooks/useCarouselController.js +2 -0
  30. package/lib/commonjs/hooks/useCarouselController.js.map +1 -0
  31. package/lib/commonjs/hooks/useCheckMounted.js +2 -0
  32. package/lib/commonjs/hooks/useCheckMounted.js.map +1 -0
  33. package/lib/commonjs/hooks/useCommonVariables.js +2 -0
  34. package/lib/commonjs/hooks/useCommonVariables.js.map +1 -0
  35. package/lib/commonjs/hooks/useInitProps.js +2 -0
  36. package/lib/commonjs/hooks/useInitProps.js.map +1 -0
  37. package/lib/commonjs/hooks/useLayoutConfig.js +2 -0
  38. package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -0
  39. package/lib/commonjs/hooks/useOffsetX.js +2 -0
  40. package/lib/commonjs/hooks/useOffsetX.js.map +1 -0
  41. package/lib/commonjs/hooks/useOnProgressChange.js +2 -0
  42. package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -0
  43. package/lib/commonjs/hooks/usePanGestureProxy.js +2 -0
  44. package/lib/commonjs/hooks/usePanGestureProxy.js.map +1 -0
  45. package/lib/commonjs/hooks/usePropsErrorBoundary.js +2 -0
  46. package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -0
  47. package/lib/commonjs/hooks/useSizeResolver.js +2 -0
  48. package/lib/commonjs/hooks/useSizeResolver.js.map +1 -0
  49. package/lib/commonjs/hooks/useUpdateGestureConfig.js +2 -0
  50. package/lib/commonjs/hooks/useUpdateGestureConfig.js.map +1 -0
  51. package/lib/commonjs/hooks/useVisibleRanges.js +2 -0
  52. package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -0
  53. package/lib/commonjs/index.js +2 -0
  54. package/lib/commonjs/index.js.map +1 -0
  55. package/lib/commonjs/layouts/index.js +2 -0
  56. package/lib/commonjs/layouts/index.js.map +1 -0
  57. package/lib/commonjs/layouts/normal.js +2 -0
  58. package/lib/commonjs/layouts/normal.js.map +1 -0
  59. package/lib/commonjs/layouts/parallax.js +2 -0
  60. package/lib/commonjs/layouts/parallax.js.map +1 -0
  61. package/lib/commonjs/layouts/stack.js +2 -0
  62. package/lib/commonjs/layouts/stack.js.map +1 -0
  63. package/lib/commonjs/package.json +1 -0
  64. package/lib/commonjs/store/index.js +2 -0
  65. package/lib/commonjs/store/index.js.map +1 -0
  66. package/lib/commonjs/types.js +2 -0
  67. package/lib/commonjs/types.js.map +1 -0
  68. package/lib/commonjs/utils/compute-gesture-translation.js +2 -0
  69. package/lib/commonjs/utils/compute-gesture-translation.js.map +1 -0
  70. package/lib/commonjs/utils/compute-offset-if-data-changed.js +2 -0
  71. package/lib/commonjs/utils/compute-offset-if-data-changed.js.map +1 -0
  72. package/lib/commonjs/utils/compute-offset-if-size-changed.js +2 -0
  73. package/lib/commonjs/utils/compute-offset-if-size-changed.js.map +1 -0
  74. package/lib/commonjs/utils/compute-offset-if-sizes-changed.js +2 -0
  75. package/lib/commonjs/utils/compute-offset-if-sizes-changed.js.map +1 -0
  76. package/lib/commonjs/utils/computed-with-auto-fill-data.js +2 -0
  77. package/lib/commonjs/utils/computed-with-auto-fill-data.js.map +1 -0
  78. package/lib/commonjs/utils/deal-with-animation.js +2 -0
  79. package/lib/commonjs/utils/deal-with-animation.js.map +1 -0
  80. package/lib/commonjs/utils/handleroffset-direction.js +2 -0
  81. package/lib/commonjs/utils/handleroffset-direction.js.map +1 -0
  82. package/lib/commonjs/utils/log.js +2 -0
  83. package/lib/commonjs/utils/log.js.map +1 -0
  84. package/lib/commonjs/utils/sanitize-animation-style.js +2 -0
  85. package/lib/commonjs/utils/sanitize-animation-style.js.map +1 -0
  86. package/lib/commonjs/utils/size-resolver.js +2 -0
  87. package/lib/commonjs/utils/size-resolver.js.map +1 -0
  88. package/lib/module/components/Carousel.js +2 -0
  89. package/lib/module/components/Carousel.js.map +1 -0
  90. package/lib/module/components/CarouselLayout.js +2 -0
  91. package/lib/module/components/CarouselLayout.js.map +1 -0
  92. package/lib/module/components/ItemLayout.js +2 -0
  93. package/lib/module/components/ItemLayout.js.map +1 -0
  94. package/lib/module/components/ItemRenderer.js +2 -0
  95. package/lib/module/components/ItemRenderer.js.map +1 -0
  96. package/lib/module/components/LazyView.js +2 -0
  97. package/lib/module/components/LazyView.js.map +1 -0
  98. package/lib/module/components/Pagination/Basic/PaginationItem.js +2 -0
  99. package/lib/module/components/Pagination/Basic/PaginationItem.js.map +1 -0
  100. package/lib/module/components/Pagination/Basic/index.js +2 -0
  101. package/lib/module/components/Pagination/Basic/index.js.map +1 -0
  102. package/lib/module/components/Pagination/Custom/PaginationItem.js +2 -0
  103. package/lib/module/components/Pagination/Custom/PaginationItem.js.map +1 -0
  104. package/lib/module/components/Pagination/Custom/index.js +2 -0
  105. package/lib/module/components/Pagination/Custom/index.js.map +1 -0
  106. package/lib/module/components/Pagination/index.js +2 -0
  107. package/lib/module/components/Pagination/index.js.map +1 -0
  108. package/lib/module/components/ScrollViewGesture.js +2 -0
  109. package/lib/module/components/ScrollViewGesture.js.map +1 -0
  110. package/lib/module/constants/index.js +2 -0
  111. package/lib/module/constants/index.js.map +1 -0
  112. package/lib/module/hooks/useAutoPlay.js +2 -0
  113. package/lib/module/hooks/useAutoPlay.js.map +1 -0
  114. package/lib/module/hooks/useCarouselController.js +2 -0
  115. package/lib/module/hooks/useCarouselController.js.map +1 -0
  116. package/lib/module/hooks/useCheckMounted.js +2 -0
  117. package/lib/module/hooks/useCheckMounted.js.map +1 -0
  118. package/lib/module/hooks/useCommonVariables.js +2 -0
  119. package/lib/module/hooks/useCommonVariables.js.map +1 -0
  120. package/lib/module/hooks/useInitProps.js +2 -0
  121. package/lib/module/hooks/useInitProps.js.map +1 -0
  122. package/lib/module/hooks/useLayoutConfig.js +2 -0
  123. package/lib/module/hooks/useLayoutConfig.js.map +1 -0
  124. package/lib/module/hooks/useOffsetX.js +2 -0
  125. package/lib/module/hooks/useOffsetX.js.map +1 -0
  126. package/lib/module/hooks/useOnProgressChange.js +2 -0
  127. package/lib/module/hooks/useOnProgressChange.js.map +1 -0
  128. package/lib/module/hooks/usePanGestureProxy.js +2 -0
  129. package/lib/module/hooks/usePanGestureProxy.js.map +1 -0
  130. package/lib/module/hooks/usePropsErrorBoundary.js +2 -0
  131. package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -0
  132. package/lib/module/hooks/useSizeResolver.js +2 -0
  133. package/lib/module/hooks/useSizeResolver.js.map +1 -0
  134. package/lib/module/hooks/useUpdateGestureConfig.js +2 -0
  135. package/lib/module/hooks/useUpdateGestureConfig.js.map +1 -0
  136. package/lib/module/hooks/useVisibleRanges.js +2 -0
  137. package/lib/module/hooks/useVisibleRanges.js.map +1 -0
  138. package/lib/module/index.js +2 -0
  139. package/lib/module/index.js.map +1 -0
  140. package/lib/module/layouts/index.js +2 -0
  141. package/lib/module/layouts/index.js.map +1 -0
  142. package/lib/module/layouts/normal.js +2 -0
  143. package/lib/module/layouts/normal.js.map +1 -0
  144. package/lib/module/layouts/parallax.js +2 -0
  145. package/lib/module/layouts/parallax.js.map +1 -0
  146. package/lib/module/layouts/stack.js +2 -0
  147. package/lib/module/layouts/stack.js.map +1 -0
  148. package/lib/module/store/index.js +2 -0
  149. package/lib/module/store/index.js.map +1 -0
  150. package/lib/module/types.js +2 -0
  151. package/lib/module/types.js.map +1 -0
  152. package/lib/module/utils/compute-gesture-translation.js +2 -0
  153. package/lib/module/utils/compute-gesture-translation.js.map +1 -0
  154. package/lib/module/utils/compute-offset-if-data-changed.js +2 -0
  155. package/lib/module/utils/compute-offset-if-data-changed.js.map +1 -0
  156. package/lib/module/utils/compute-offset-if-size-changed.js +2 -0
  157. package/lib/module/utils/compute-offset-if-size-changed.js.map +1 -0
  158. package/lib/module/utils/compute-offset-if-sizes-changed.js +2 -0
  159. package/lib/module/utils/compute-offset-if-sizes-changed.js.map +1 -0
  160. package/lib/module/utils/computed-with-auto-fill-data.js +2 -0
  161. package/lib/module/utils/computed-with-auto-fill-data.js.map +1 -0
  162. package/lib/module/utils/deal-with-animation.js +2 -0
  163. package/lib/module/utils/deal-with-animation.js.map +1 -0
  164. package/lib/module/utils/handleroffset-direction.js +2 -0
  165. package/lib/module/utils/handleroffset-direction.js.map +1 -0
  166. package/lib/module/utils/log.js +2 -0
  167. package/lib/module/utils/log.js.map +1 -0
  168. package/lib/module/utils/sanitize-animation-style.js +2 -0
  169. package/lib/module/utils/sanitize-animation-style.js.map +1 -0
  170. package/lib/module/utils/size-resolver.js +2 -0
  171. package/lib/module/utils/size-resolver.js.map +1 -0
  172. package/lib/typescript/components/Carousel.d.ts +8 -0
  173. package/lib/typescript/components/Carousel.d.ts.map +1 -0
  174. package/lib/typescript/components/CarouselLayout.d.ts +6 -0
  175. package/lib/typescript/components/CarouselLayout.d.ts.map +1 -0
  176. package/lib/typescript/components/ItemLayout.d.ts +15 -0
  177. package/lib/typescript/components/ItemLayout.d.ts.map +1 -0
  178. package/lib/typescript/components/ItemRenderer.d.ts +24 -0
  179. package/lib/typescript/components/ItemRenderer.d.ts.map +1 -0
  180. package/lib/typescript/components/LazyView.d.ts +8 -0
  181. package/lib/typescript/components/LazyView.d.ts.map +1 -0
  182. package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts +29 -0
  183. package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts.map +1 -0
  184. package/lib/typescript/components/Pagination/Basic/index.d.ts +23 -0
  185. package/lib/typescript/components/Pagination/Basic/index.d.ts.map +1 -0
  186. package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts +35 -0
  187. package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts.map +1 -0
  188. package/lib/typescript/components/Pagination/Custom/index.d.ts +26 -0
  189. package/lib/typescript/components/Pagination/Custom/index.d.ts.map +1 -0
  190. package/lib/typescript/components/Pagination/index.d.ts +5 -0
  191. package/lib/typescript/components/Pagination/index.d.ts.map +1 -0
  192. package/lib/typescript/components/ScrollViewGesture.d.ts +19 -0
  193. package/lib/typescript/components/ScrollViewGesture.d.ts.map +1 -0
  194. package/lib/typescript/constants/index.d.ts +9 -0
  195. package/lib/typescript/constants/index.d.ts.map +1 -0
  196. package/lib/typescript/hooks/useAutoPlay.d.ts +12 -0
  197. package/lib/typescript/hooks/useAutoPlay.d.ts.map +1 -0
  198. package/lib/typescript/hooks/useCarouselController.d.ts +28 -0
  199. package/lib/typescript/hooks/useCarouselController.d.ts.map +1 -0
  200. package/lib/typescript/hooks/useCheckMounted.d.ts +3 -0
  201. package/lib/typescript/hooks/useCheckMounted.d.ts.map +1 -0
  202. package/lib/typescript/hooks/useCommonVariables.d.ts +13 -0
  203. package/lib/typescript/hooks/useCommonVariables.d.ts.map +1 -0
  204. package/lib/typescript/hooks/useInitProps.d.ts +17 -0
  205. package/lib/typescript/hooks/useInitProps.d.ts.map +1 -0
  206. package/lib/typescript/hooks/useLayoutConfig.d.ts +10 -0
  207. package/lib/typescript/hooks/useLayoutConfig.d.ts.map +1 -0
  208. package/lib/typescript/hooks/useOffsetX.d.ts +24 -0
  209. package/lib/typescript/hooks/useOffsetX.d.ts.map +1 -0
  210. package/lib/typescript/hooks/useOnProgressChange.d.ts +14 -0
  211. package/lib/typescript/hooks/useOnProgressChange.d.ts.map +1 -0
  212. package/lib/typescript/hooks/usePanGestureProxy.d.ts +10 -0
  213. package/lib/typescript/hooks/usePanGestureProxy.d.ts.map +1 -0
  214. package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +5 -0
  215. package/lib/typescript/hooks/usePropsErrorBoundary.d.ts.map +1 -0
  216. package/lib/typescript/hooks/useSizeResolver.d.ts +27 -0
  217. package/lib/typescript/hooks/useSizeResolver.d.ts.map +1 -0
  218. package/lib/typescript/hooks/useUpdateGestureConfig.d.ts +6 -0
  219. package/lib/typescript/hooks/useUpdateGestureConfig.d.ts.map +1 -0
  220. package/lib/typescript/hooks/useVisibleRanges.d.ts +23 -0
  221. package/lib/typescript/hooks/useVisibleRanges.d.ts.map +1 -0
  222. package/lib/typescript/index.d.ts +7 -0
  223. package/lib/typescript/index.d.ts.map +1 -0
  224. package/lib/typescript/layouts/index.d.ts +11 -0
  225. package/lib/typescript/layouts/index.d.ts.map +1 -0
  226. package/lib/typescript/layouts/normal.d.ts +16 -0
  227. package/lib/typescript/layouts/normal.d.ts.map +1 -0
  228. package/lib/typescript/layouts/parallax.d.ts +50 -0
  229. package/lib/typescript/layouts/parallax.d.ts.map +1 -0
  230. package/lib/typescript/layouts/stack.d.ts +38 -0
  231. package/lib/typescript/layouts/stack.d.ts.map +1 -0
  232. package/lib/typescript/store/index.d.ts +38 -0
  233. package/lib/typescript/store/index.d.ts.map +1 -0
  234. package/lib/typescript/types.d.ts +326 -0
  235. package/lib/typescript/types.d.ts.map +1 -0
  236. package/lib/typescript/utils/compute-gesture-translation.d.ts +9 -0
  237. package/lib/typescript/utils/compute-gesture-translation.d.ts.map +1 -0
  238. package/lib/typescript/utils/compute-offset-if-data-changed.d.ts +9 -0
  239. package/lib/typescript/utils/compute-offset-if-data-changed.d.ts.map +1 -0
  240. package/lib/typescript/utils/compute-offset-if-size-changed.d.ts +6 -0
  241. package/lib/typescript/utils/compute-offset-if-size-changed.d.ts.map +1 -0
  242. package/lib/typescript/utils/compute-offset-if-sizes-changed.d.ts +14 -0
  243. package/lib/typescript/utils/compute-offset-if-sizes-changed.d.ts.map +1 -0
  244. package/lib/typescript/utils/computed-with-auto-fill-data.d.ts +23 -0
  245. package/lib/typescript/utils/computed-with-auto-fill-data.d.ts.map +1 -0
  246. package/lib/typescript/utils/deal-with-animation.d.ts +3 -0
  247. package/lib/typescript/utils/deal-with-animation.d.ts.map +1 -0
  248. package/lib/typescript/utils/handleroffset-direction.d.ts +4 -0
  249. package/lib/typescript/utils/handleroffset-direction.d.ts.map +1 -0
  250. package/lib/typescript/utils/log.d.ts +7 -0
  251. package/lib/typescript/utils/log.d.ts.map +1 -0
  252. package/lib/typescript/utils/sanitize-animation-style.d.ts +3 -0
  253. package/lib/typescript/utils/sanitize-animation-style.d.ts.map +1 -0
  254. package/lib/typescript/utils/size-resolver.d.ts +87 -0
  255. package/lib/typescript/utils/size-resolver.d.ts.map +1 -0
  256. package/package.json +151 -0
  257. package/src/components/Carousel.test.tsx +1153 -0
  258. package/src/components/Carousel.tsx +35 -0
  259. package/src/components/CarouselLayout.tsx +231 -0
  260. package/src/components/ItemLayout.tsx +217 -0
  261. package/src/components/ItemRenderer.tsx +114 -0
  262. package/src/components/LazyView.test.tsx +61 -0
  263. package/src/components/LazyView.tsx +14 -0
  264. package/src/components/Pagination/Basic/PaginationItem.tsx +149 -0
  265. package/src/components/Pagination/Basic/index.tsx +98 -0
  266. package/src/components/Pagination/Custom/PaginationItem.tsx +166 -0
  267. package/src/components/Pagination/Custom/index.tsx +111 -0
  268. package/src/components/Pagination/Pagination.test.tsx +178 -0
  269. package/src/components/Pagination/index.tsx +7 -0
  270. package/src/components/ScrollViewGesture.tsx +577 -0
  271. package/src/components/rnr-demo.test.tsx +53 -0
  272. package/src/constants/index.ts +11 -0
  273. package/src/hooks/useAutoPlay.test.ts +194 -0
  274. package/src/hooks/useAutoPlay.ts +58 -0
  275. package/src/hooks/useCarouselController.test.tsx +1158 -0
  276. package/src/hooks/useCarouselController.tsx +525 -0
  277. package/src/hooks/useCheckMounted.test.ts +47 -0
  278. package/src/hooks/useCheckMounted.ts +14 -0
  279. package/src/hooks/useCommonVariables.test.tsx +384 -0
  280. package/src/hooks/useCommonVariables.ts +202 -0
  281. package/src/hooks/useInitProps.test.tsx +134 -0
  282. package/src/hooks/useInitProps.ts +111 -0
  283. package/src/hooks/useLayoutConfig.test.tsx +247 -0
  284. package/src/hooks/useLayoutConfig.ts +30 -0
  285. package/src/hooks/useOffsetX.test.ts +110 -0
  286. package/src/hooks/useOffsetX.ts +109 -0
  287. package/src/hooks/useOnProgressChange.test.tsx +207 -0
  288. package/src/hooks/useOnProgressChange.ts +105 -0
  289. package/src/hooks/usePanGestureProxy.test.tsx +368 -0
  290. package/src/hooks/usePanGestureProxy.ts +144 -0
  291. package/src/hooks/usePropsErrorBoundary.ts +138 -0
  292. package/src/hooks/useSizeResolver.test.tsx +112 -0
  293. package/src/hooks/useSizeResolver.ts +106 -0
  294. package/src/hooks/useUpdateGestureConfig.test.ts +89 -0
  295. package/src/hooks/useUpdateGestureConfig.ts +14 -0
  296. package/src/hooks/useVisibleRanges.test.tsx +366 -0
  297. package/src/hooks/useVisibleRanges.tsx +123 -0
  298. package/src/index.tsx +13 -0
  299. package/src/layouts/index.tsx +12 -0
  300. package/src/layouts/normal.ts +32 -0
  301. package/src/layouts/parallax.test.ts +239 -0
  302. package/src/layouts/parallax.ts +83 -0
  303. package/src/layouts/stack.test.ts +252 -0
  304. package/src/layouts/stack.ts +306 -0
  305. package/src/store/index.test.tsx +314 -0
  306. package/src/store/index.tsx +66 -0
  307. package/src/types.ts +348 -0
  308. package/src/utils/compute-gesture-translation.test.ts +70 -0
  309. package/src/utils/compute-gesture-translation.ts +29 -0
  310. package/src/utils/compute-offset-if-data-changed.test.ts +133 -0
  311. package/src/utils/compute-offset-if-data-changed.ts +44 -0
  312. package/src/utils/compute-offset-if-size-changed.test.ts +78 -0
  313. package/src/utils/compute-offset-if-size-changed.ts +14 -0
  314. package/src/utils/compute-offset-if-sizes-changed.test.ts +74 -0
  315. package/src/utils/compute-offset-if-sizes-changed.ts +44 -0
  316. package/src/utils/computed-with-auto-fill-data.test.ts +298 -0
  317. package/src/utils/computed-with-auto-fill-data.ts +92 -0
  318. package/src/utils/deal-with-animation.test.ts +181 -0
  319. package/src/utils/deal-with-animation.ts +17 -0
  320. package/src/utils/handleroffset-direction.test.ts +124 -0
  321. package/src/utils/handleroffset-direction.ts +18 -0
  322. package/src/utils/index.test.ts +90 -0
  323. package/src/utils/log.test.ts +134 -0
  324. package/src/utils/log.ts +12 -0
  325. package/src/utils/sanitize-animation-style.test.ts +40 -0
  326. package/src/utils/sanitize-animation-style.ts +20 -0
  327. package/src/utils/size-resolver.test.ts +193 -0
  328. package/src/utils/size-resolver.ts +216 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Doho
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 ADDED
@@ -0,0 +1,652 @@
1
+ # react-native-reanimated-carousel
2
+
3
+ <img src="assets/home-banner.png" width="100%"/>
4
+
5
+ ![Hacktober Badge](https://img.shields.io/badge/hacktoberfest-2022-blueviolet)
6
+ ![platforms](https://img.shields.io/badge/platforms-Android%20%7C%20iOS%20%7C%20Web-brightgreen.svg?style=flat-square&colorB=191A17)
7
+ [![npm](https://img.shields.io/npm/v/react-native-reanimated-carousel.svg?style=flat-square)](https://www.npmjs.com/package/react-native-reanimated-carousel)
8
+ [![npm](https://img.shields.io/npm/dm/react-native-reanimated-carousel.svg?style=flat-square&colorB=007ec6)](https://www.npmjs.com/package/react-native-reanimated-carousel)
9
+ [![npm](https://img.shields.io/npm/dw/react-native-reanimated-carousel.svg?style=flat-square&colorB=007ec6)](https://www.npmjs.com/package/react-native-reanimated-carousel)
10
+ [![github issues](https://img.shields.io/github/issues/dohooo/react-native-reanimated-carousel.svg?style=flat-square)](https://github.com/dohooo/react-native-reanimated-carousel/issues)
11
+ [![github closed issues](https://img.shields.io/github/issues-closed/dohooo/react-native-reanimated-carousel.svg?style=flat-square&colorB=44cc11)](https://github.com/dohooo/react-native-reanimated-carousel/issues?q=is%3Aissue+is%3Aclosed)
12
+ [![discord chat](https://img.shields.io/badge/chat-discord-blue?style=flat&logo=discord)](https://discord.gg/KsXRuDs43y)
13
+
14
+ ## The best carousel component in React Native community. ⚡️
15
+
16
+ - [Getting Started](https://rn-carousel.dev)
17
+ - [Examples](https://rn-carousel.dev/Examples/summary)
18
+
19
+ ## v5 beta notes
20
+
21
+ - **Sizing**: `style` controls the **container size**; `itemWidth`/`itemHeight` control the **page size** (snap distance & animation progress).
22
+ - **Scroll offset shared value**: use `scrollOffsetValue` (recommended). `defaultScrollOffsetValue` is deprecated but still supported.
23
+ - **Progress**: `onProgressChange` supports both a callback and `SharedValue<number>`.
24
+ - **Pagination accessibility**: `Pagination.Basic` and `Pagination.Custom` support `paginationItemAccessibility` for per-item a11y overrides.
25
+ - **Custom animation safety**: `customAnimation` styles are sanitized and `zIndex` is normalized to finite integers.
26
+
27
+ ## 📊 Version Compatibility
28
+
29
+ | Carousel Version | Expo SDK | React Native | Reanimated | Gesture Handler | Worklets |
30
+ |------------------|----------|--------------|------------|-----------------|------------|
31
+ | **v5.0.0-beta** | **54+** | **0.80+** | **4.0.0+** | **2.9.0+** | **0.5.0+** |
32
+ | v4.x | 50-53 | 0.70.3+ | 3.0.0+ | 2.9.0+ | ❌ |
33
+ | v3.x | 47-49 | 0.66.0+ | 2.0.0+ | 2.0.0+ | ❌ |
34
+
35
+
36
+ ## Sponsors
37
+
38
+ <p align="center">
39
+ <img src='https://github.com/dohooo/sponsors/blob/master/sponsors.png?raw=true'/>
40
+ </p>
41
+
42
+ ## License
43
+
44
+ MIT
45
+
46
+ ---
47
+
48
+ # Documentation
49
+
50
+ A complete, in-tree reference for the `<Carousel>` component, the `<Pagination>` helpers, and every prop, mode, callback, imperative method, and behavioral nuance.
51
+
52
+ ## Table of Contents
53
+
54
+ - [Installation](#installation)
55
+ - [Quick Start](#quick-start)
56
+ - [Sizing model: container vs. page](#sizing-model-container-vs-page)
57
+ - [Variable-size mode (`getItemWidth` / `getItemHeight`)](#variable-size-mode-getitemwidth--getitemheight)
58
+ - [Animation modes](#animation-modes)
59
+ - [`normal` (default)](#normal-default)
60
+ - [`parallax`](#parallax)
61
+ - [`horizontal-stack` / `vertical-stack`](#horizontal-stack--vertical-stack)
62
+ - [`customAnimation`](#customanimation)
63
+ - [Loop, paging, and snapping](#loop-paging-and-snapping)
64
+ - [Auto-play](#auto-play)
65
+ - [Gestures and overscroll](#gestures-and-overscroll)
66
+ - [Programmatic control (`ref`)](#programmatic-control-ref)
67
+ - [Tracking progress](#tracking-progress)
68
+ - [`<Pagination>` indicators](#pagination-indicators)
69
+ - [Render-item contract](#render-item-contract)
70
+ - [Complete prop reference](#complete-prop-reference)
71
+ - [TypeScript exports](#typescript-exports)
72
+ - [Migration notes (v4 → v5)](#migration-notes-v4--v5)
73
+ - [Performance notes](#performance-notes)
74
+ - [Architecture deep dive](#architecture-deep-dive)
75
+
76
+ ---
77
+
78
+ ## Installation
79
+
80
+ ```bash
81
+ yarn add react-native-reanimated-carousel
82
+ # or
83
+ npm install react-native-reanimated-carousel
84
+ ```
85
+
86
+ Peer dependencies (see the [Version Compatibility table](#-version-compatibility) above for exact ranges):
87
+
88
+ - `react-native-reanimated`
89
+ - `react-native-gesture-handler`
90
+ - `react-native-worklets` (v5 only)
91
+
92
+ Configure Reanimated's Babel plugin and wrap your app in `<GestureHandlerRootView>` per the docs of those libraries. The carousel mounts its own `GestureHandlerRootView` internally, but you still need the top-level one for gesture handler to work.
93
+
94
+ ---
95
+
96
+ ## Quick Start
97
+
98
+ ```tsx
99
+ import Carousel from "react-native-reanimated-carousel";
100
+ import { View, Text, useWindowDimensions } from "react-native";
101
+
102
+ export function Example() {
103
+ const { width } = useWindowDimensions();
104
+
105
+ return (
106
+ <Carousel
107
+ data={["Slide 1", "Slide 2", "Slide 3", "Slide 4"]}
108
+ style={{ width, height: 220 }}
109
+ loop
110
+ pagingEnabled
111
+ renderItem={({ item, index }) => (
112
+ <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
113
+ <Text>{item} (#{index})</Text>
114
+ </View>
115
+ )}
116
+ />
117
+ );
118
+ }
119
+ ```
120
+
121
+ Every prop is optional except `data` and `renderItem`. The container fills its parent if you omit `style` (with a dev warning), so for production usage always declare a `width` and `height` via `style`.
122
+
123
+ ---
124
+
125
+ ## Sizing model: container vs. page
126
+
127
+ The carousel distinguishes **container size** from **page size**:
128
+
129
+ - **Container size** is the outer viewport. It comes from `style`, falling back to deprecated `width` / `height` props, and finally to `onLayout` measurement.
130
+ - **Page size** is the snap distance and the unit of animation progress (one full page = animation `value` moving by 1.0). It defaults to the container size — meaning one item fills the viewport — but you can override it with `itemWidth` / `itemHeight` to show multiple items at once, or with `getItemWidth` / `getItemHeight` for per-item sizes.
131
+
132
+ ```tsx
133
+ // Container 360 px wide, three items visible per page (120 px each)
134
+ <Carousel
135
+ style={{ width: 360, height: 200 }}
136
+ itemWidth={120}
137
+ data={data}
138
+ renderItem={renderItem}
139
+ />
140
+ ```
141
+
142
+ Vertical carousels use the same model, swapping `width` ↔ `height` and `itemWidth` ↔ `itemHeight`:
143
+
144
+ ```tsx
145
+ <Carousel
146
+ vertical
147
+ style={{ width: 240, height: 600 }}
148
+ itemHeight={150}
149
+ data={data}
150
+ renderItem={renderItem}
151
+ />
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Variable-size mode (`getItemWidth` / `getItemHeight`)
157
+
158
+ For long lists where every item has a *different* size — chat feeds, image grids with mixed aspect ratios, masonry-style content — supply `getItemWidth(index)` (horizontal) or `getItemHeight(index)` (vertical). The carousel precomputes a prefix-sum offset table before mount, so every visible item is positioned correctly on the first frame with **no measurement race, no blank frames, no jump-on-measure**.
159
+
160
+ ```tsx
161
+ const WIDTHS = [80, 150, 220, 100, 300, 100, 120, 200, 90, 180];
162
+
163
+ <Carousel
164
+ data={items}
165
+ style={{ width: screenWidth, height: 200 }}
166
+ getItemWidth={(index) => WIDTHS[index % WIDTHS.length]}
167
+ windowSize={10}
168
+ renderItem={renderItem}
169
+ />
170
+ ```
171
+
172
+ ### Requirements & caveats
173
+
174
+ - The function must return a **positive, finite number** for every index in `[0, data.length)`. Non-finite or non-positive values are clamped to 0 (and warned about in `__DEV__`).
175
+ - Treat the function identity as part of the data identity. Memoize with `useCallback` or hoist to module scope — re-creating it on every render triggers a full prefix-sum rebuild. (O(n) on the JS thread; fast for thousands of items but worth avoiding.)
176
+ - **`onLayout` measurements never override `getItem*` values.** Your declarations are authoritative. If your real content is bigger than declared, it overflows; if smaller, you get trailing whitespace inside the item slot.
177
+ - **`pagingEnabled` snaps by item index** — one swipe advances one item, regardless of width. Per-snap pixel distance therefore varies.
178
+ - **`autoFillData` is disabled** in variable-size mode. autoFillData duplicates short data arrays assuming uniform size; with variable sizes the heuristic doesn't apply. Pre-duplicate your data array manually if you need a short loopable list.
179
+ - **`loop` is fully supported.** Items wrap around using the total span of all declared sizes.
180
+ - **Lookup cost.** Each visible item performs a binary search through the prefix table on every gesture frame (≈ log₂(N) comparisons per item). For lists with hundreds of items this is negligible; for tens of thousands the cached-hint optimization keeps amortized cost at O(1) during continuous scrolling.
181
+
182
+ ### When to use each sizing prop
183
+
184
+ | Prop | Use when |
185
+ | --- | --- |
186
+ | `style={{ width, height }}` only | One item per page, uniform size |
187
+ | `itemWidth` / `itemHeight` | Multiple items per page, all the same size |
188
+ | `getItemWidth` / `getItemHeight` | Per-item sizes are known up-front |
189
+
190
+ ---
191
+
192
+ ## Animation modes
193
+
194
+ The `mode` prop selects a built-in animation strategy. All modes preserve the "no blanks" rendering guarantee — items render synchronously on the UI thread.
195
+
196
+ ### `normal` (default)
197
+
198
+ Pure horizontal/vertical scroll. Each item translates by the page size as it moves through the viewport.
199
+
200
+ ```tsx
201
+ <Carousel data={data} style={{ width: 300, height: 200 }} renderItem={renderItem} />
202
+ ```
203
+
204
+ ### `parallax`
205
+
206
+ Items scale down and translate inward as they leave the center, creating a depth effect.
207
+
208
+ ```tsx
209
+ <Carousel
210
+ mode="parallax"
211
+ modeConfig={{
212
+ parallaxScrollingOffset: 50,
213
+ parallaxScrollingScale: 0.9,
214
+ parallaxAdjacentItemScale: 0.75,
215
+ }}
216
+ data={data}
217
+ style={{ width: 300, height: 200 }}
218
+ renderItem={renderItem}
219
+ />
220
+ ```
221
+
222
+ `modeConfig` options (all optional):
223
+
224
+ - `parallaxScrollingOffset` (default `100`): pixels each adjacent item is inset by.
225
+ - `parallaxScrollingScale` (default `0.8`): scale of the centered item.
226
+ - `parallaxAdjacentItemScale` (default `parallaxScrollingScale ** 2`): scale of the off-center items.
227
+
228
+ ### `horizontal-stack` / `vertical-stack`
229
+
230
+ Tinder-style card stack. Items pile up on top of each other and animate off the stack as the user swipes.
231
+
232
+ ```tsx
233
+ <Carousel
234
+ mode="horizontal-stack"
235
+ modeConfig={{
236
+ snapDirection: "left", // or "right"
237
+ showLength: 3, // number of cards visible in the stack
238
+ stackInterval: 18,
239
+ scaleInterval: 0.04,
240
+ opacityInterval: 0.1,
241
+ rotateZDeg: 30,
242
+ moveSize: screenWidth,
243
+ }}
244
+ data={data}
245
+ style={{ width: 300, height: 400 }}
246
+ renderItem={renderItem}
247
+ />
248
+ ```
249
+
250
+ Use `vertical-stack` with `vertical` flag for vertical card stacks.
251
+
252
+ ### `customAnimation`
253
+
254
+ Skip the built-in modes and define your own animation as a worklet. Receives the animation `value` (–1 = one item to the left of center, 0 = centered, 1 = one to the right) and the item index, returns a React Native `ViewStyle`.
255
+
256
+ ```tsx
257
+ import type { ViewStyle } from "react-native";
258
+ import { interpolate } from "react-native-reanimated";
259
+
260
+ const customAnimation = (value: number, index: number): ViewStyle => {
261
+ "worklet";
262
+ const translateX = interpolate(value, [-1, 0, 1], [-300, 0, 300]);
263
+ const opacity = interpolate(value, [-1, 0, 1], [0.5, 1, 0.5]);
264
+ return {
265
+ transform: [{ translateX }],
266
+ opacity,
267
+ };
268
+ };
269
+
270
+ <Carousel customAnimation={customAnimation} data={data} renderItem={renderItem} />
271
+ ```
272
+
273
+ The carousel sanitizes the returned style on every frame: non-finite `zIndex` values are clamped to integers, and unsupported keys are dropped.
274
+
275
+ ---
276
+
277
+ ## Loop, paging, and snapping
278
+
279
+ These three props together describe the carousel's scroll behavior. They're independent:
280
+
281
+ | Prop | Default | Effect |
282
+ | --- | --- | --- |
283
+ | `loop` | `true` | When `true`, scrolling past the last item wraps to the first. When `false`, the carousel stops at the boundaries. |
284
+ | `pagingEnabled` | `true` | When `true`, releasing a swipe always snaps to the next or previous item boundary (one swipe = one item). When `false`, the carousel scrolls freely. |
285
+ | `snapEnabled` | `true` | When `true` *and* `pagingEnabled` is `false`, releasing a swipe snaps to the nearest item boundary. When both are `false`, the carousel comes to rest wherever the gesture decay ends. |
286
+
287
+ ### Tweaking snap behavior
288
+
289
+ - **`maxScrollDistancePerSwipe`** — maximum pixel distance a single swipe can travel. Useful for preventing flicks from scrolling past several items at once.
290
+ - **`minScrollDistancePerSwipe`** — minimum pixel distance for a swipe to register. Below this threshold, the carousel resets to the current item.
291
+ - **`scrollAnimationDuration`** (default `500ms`) — how long the spring/timing animation takes when snapping.
292
+ - **`withAnimation`** — replace the default ease-out-quart timing with a custom timing or spring config. Takes precedence over `scrollAnimationDuration`.
293
+
294
+ ```tsx
295
+ <Carousel
296
+ withAnimation={{
297
+ type: "spring",
298
+ config: { damping: 13, mass: 1.2, stiffness: 100 },
299
+ }}
300
+ data={data}
301
+ renderItem={renderItem}
302
+ />
303
+ ```
304
+
305
+ ### `fixedDirection`
306
+
307
+ Forces every swipe to move in a single direction regardless of which way the user drags. Useful for "always scroll forward" patterns.
308
+
309
+ ```tsx
310
+ <Carousel fixedDirection="positive" data={data} renderItem={renderItem} />
311
+ ```
312
+
313
+ ---
314
+
315
+ ## Auto-play
316
+
317
+ ```tsx
318
+ <Carousel
319
+ autoPlay
320
+ autoPlayInterval={2500} // ms between slides (default 1000)
321
+ autoPlayReverse={false} // when true, plays backwards
322
+ data={data}
323
+ renderItem={renderItem}
324
+ />
325
+ ```
326
+
327
+ Auto-play pauses on touch and resumes on release. It also pauses if `enabled={false}` is set.
328
+
329
+ ---
330
+
331
+ ## Gestures and overscroll
332
+
333
+ - **`enabled`** (default `true`) — when `false`, the carousel ignores all gestures. Programmatic control (`ref.scrollTo`, `next`, `prev`) still works.
334
+ - **`overscrollEnabled`** (default `true`) — when `false`, scrolling stops exactly at the edges in non-loop mode. When `true`, you can drag past the edge with rubber-band feel.
335
+ - **`onConfigurePanGesture`** — receives the underlying `PanGesture` so you can compose with other gesture handlers, set `activeOffsetX`/`activeOffsetY`, or chain `.simultaneousWithExternalGesture(...)`.
336
+
337
+ ```tsx
338
+ import { Gesture } from "react-native-gesture-handler";
339
+
340
+ <Carousel
341
+ onConfigurePanGesture={(pan) => {
342
+ pan.activeOffsetX([-10, 10]);
343
+ }}
344
+ data={data}
345
+ renderItem={renderItem}
346
+ />
347
+ ```
348
+
349
+ ---
350
+
351
+ ## Programmatic control (`ref`)
352
+
353
+ Attach a `ref<ICarouselInstance>` to drive the carousel from code.
354
+
355
+ ```tsx
356
+ import { useRef } from "react";
357
+ import Carousel, { type ICarouselInstance } from "react-native-reanimated-carousel";
358
+
359
+ const ref = useRef<ICarouselInstance>(null);
360
+
361
+ <Carousel ref={ref} data={data} renderItem={renderItem} />;
362
+
363
+ // Imperative methods:
364
+ ref.current?.next(); // advance by 1
365
+ ref.current?.next({ count: 3, animated: true }); // advance by 3
366
+ ref.current?.prev({ count: 2 }); // go back 2
367
+ ref.current?.scrollTo({ index: 0, animated: true }); // jump to index 0
368
+ ref.current?.scrollTo({ count: -5 }); // equivalent to prev(5)
369
+ ref.current?.getCurrentIndex(); // returns the current item index
370
+ ```
371
+
372
+ ### `TCarouselActionOptions`
373
+
374
+ | Field | Type | Description |
375
+ | --- | --- | --- |
376
+ | `index` | `number` | Absolute target index. Takes precedence over `count`. |
377
+ | `count` | `number` | Relative offset (positive = forward, negative = backward). |
378
+ | `animated` | `boolean` | Whether to animate the scroll. Defaults to `true` for `next`/`prev`, `false` for `scrollTo`. |
379
+ | `onFinished` | `() => void` | Called when the animation settles (or immediately if `animated: false`). |
380
+
381
+ ---
382
+
383
+ ## Tracking progress
384
+
385
+ Three callbacks fire during scrolling:
386
+
387
+ ```tsx
388
+ <Carousel
389
+ onScrollStart={() => console.log("scroll began")}
390
+ onScrollEnd={(index) => console.log("settled at", index)}
391
+ onSnapToItem={(index) => console.log("snapped to", index)}
392
+ onProgressChange={(offsetProgress, absoluteProgress) => {
393
+ // offsetProgress: total pixel offset from start (negative when scrolling forward)
394
+ // absoluteProgress: fractional item index (e.g. 1.5 = halfway between items 1 and 2)
395
+ }}
396
+ data={data}
397
+ renderItem={renderItem}
398
+ />
399
+ ```
400
+
401
+ ### `onProgressChange` with a `SharedValue`
402
+
403
+ For tight integration with Reanimated worklets, pass a `SharedValue<number>` directly. The carousel writes `absoluteProgress` into it on every frame without ever crossing the JS thread:
404
+
405
+ ```tsx
406
+ import { useSharedValue } from "react-native-reanimated";
407
+
408
+ const progress = useSharedValue(0);
409
+
410
+ <Carousel onProgressChange={progress} data={data} renderItem={renderItem} />;
411
+ ```
412
+
413
+ This is the recommended pattern for driving a `<Pagination>` indicator (see below).
414
+
415
+ ### `scrollOffsetValue` (advanced)
416
+
417
+ Pass your own `SharedValue<number>` as the carousel's internal translation state. The carousel mutates it during gestures and animations, letting you observe or write to the scroll offset from outside the component. Use this when you need to synchronize the carousel with another animated component (custom indicator, parallax background, etc.).
418
+
419
+ The legacy `defaultScrollOffsetValue` prop is still accepted but deprecated; prefer `scrollOffsetValue`.
420
+
421
+ ---
422
+
423
+ ## `<Pagination>` indicators
424
+
425
+ Two flavors, both driven by a `SharedValue<number>` (typically wired up via `onProgressChange`).
426
+
427
+ ### `Pagination.Basic`
428
+
429
+ Simple dots that interpolate width / color between active and inactive states.
430
+
431
+ ```tsx
432
+ import { Pagination } from "react-native-reanimated-carousel";
433
+ import { useSharedValue } from "react-native-reanimated";
434
+
435
+ const progress = useSharedValue(0);
436
+
437
+ <Carousel onProgressChange={progress} data={data} renderItem={renderItem} />
438
+ <Pagination.Basic
439
+ progress={progress}
440
+ data={data}
441
+ horizontal
442
+ size={12}
443
+ dotStyle={{ backgroundColor: "#999", borderRadius: 6 }}
444
+ activeDotStyle={{ backgroundColor: "#000" }}
445
+ containerStyle={{ gap: 8 }}
446
+ onPress={(i) => ref.current?.scrollTo({ index: i, animated: true })}
447
+ />
448
+ ```
449
+
450
+ ### `Pagination.Custom`
451
+
452
+ Same API plus a `customReanimatedStyle(progress, index, length) => style` worklet so you can implement any indicator shape (bars, segments, fading rings, etc.).
453
+
454
+ ```tsx
455
+ <Pagination.Custom
456
+ progress={progress}
457
+ data={data}
458
+ size={20}
459
+ customReanimatedStyle={(progress, index, length) => {
460
+ "worklet";
461
+ const distance = Math.abs(progress - index);
462
+ return {
463
+ opacity: 1 - Math.min(distance, 1),
464
+ transform: [{ scale: 1 - 0.4 * Math.min(distance, 1) }],
465
+ };
466
+ }}
467
+ />
468
+ ```
469
+
470
+ ### Accessibility overrides
471
+
472
+ Both variants accept `paginationItemAccessibility(index, length)` returning overrides:
473
+
474
+ ```tsx
475
+ <Pagination.Basic
476
+ progress={progress}
477
+ data={data}
478
+ carouselName="Featured photos"
479
+ paginationItemAccessibility={(index, length) => ({
480
+ accessibilityLabel: `Photo ${index + 1} of ${length}`,
481
+ accessibilityRole: "button",
482
+ })}
483
+ />
484
+ ```
485
+
486
+ Without overrides, items announce as `"Slide N of M"` (or `"Slide N of M - <carouselName>"` if `carouselName` is set).
487
+
488
+ ---
489
+
490
+ ## Render-item contract
491
+
492
+ ```ts
493
+ type CarouselRenderItem<T> = (info: {
494
+ item: T;
495
+ index: number;
496
+ animationValue: SharedValue<number>;
497
+ }) => React.ReactElement;
498
+ ```
499
+
500
+ - `item` — the data entry.
501
+ - `index` — the real item index (already corrected for `autoFillData` duplication).
502
+ - `animationValue` — a `SharedValue<number>` representing the item's position relative to the viewport: `0` when centered, `-1` when one page to the left, `1` when one page to the right, and so on. Useful for driving per-item animations from inside the rendered subtree.
503
+
504
+ ```tsx
505
+ import Animated, { useAnimatedStyle, interpolate } from "react-native-reanimated";
506
+
507
+ const renderItem = ({ item, animationValue }) => {
508
+ const style = useAnimatedStyle(() => ({
509
+ opacity: interpolate(animationValue.value, [-1, 0, 1], [0.4, 1, 0.4]),
510
+ }));
511
+ return <Animated.View style={[styles.card, style]}>{/* ... */}</Animated.View>;
512
+ };
513
+ ```
514
+
515
+ ---
516
+
517
+ ## Complete prop reference
518
+
519
+ All props on `<Carousel>` (everything except `data` and `renderItem` is optional).
520
+
521
+ ### Data & rendering
522
+
523
+ | Prop | Type | Default | Description |
524
+ | --- | --- | --- | --- |
525
+ | `data` | `T[]` | **required** | Items to render. |
526
+ | `renderItem` | `CarouselRenderItem<T>` | **required** | Function that returns a React element for each item. |
527
+ | `autoFillData` | `boolean` | `true` | When `loop=true` and `data.length` is 1 or 2, duplicates entries internally so the loop animation has enough items. Disabled in variable-size mode. |
528
+ | `defaultIndex` | `number` | `0` | Initial item index. |
529
+ | `keyExtractor` | implicit | uses `index` | Items are keyed by their array index. |
530
+
531
+ ### Sizing
532
+
533
+ | Prop | Type | Default | Description |
534
+ | --- | --- | --- | --- |
535
+ | `style` | `StyleProp<ViewStyle>` | — | Container style. Provide `width`/`height` here. |
536
+ | `contentContainerStyle` | `StyleProp<ViewStyle>` | — | Style for the inner content container. Avoid `opacity` and `transform` here — they conflict with internal animations. |
537
+ | `itemWidth` | `number` | container width | Horizontal page size (snap distance). Use to show multiple items at once. |
538
+ | `itemHeight` | `number` | container height | Vertical page size when `vertical=true`. |
539
+ | `getItemWidth` | `(i: number) => number` | — | Per-item width. Enables [variable-size mode](#variable-size-mode-getitemwidth--getitemheight). |
540
+ | `getItemHeight` | `(i: number) => number` | — | Per-item height for vertical carousels. |
541
+ | `vertical` | `boolean` | `false` | When `true`, items scroll top-to-bottom. |
542
+ | `width` | `number` | — | **Deprecated.** Use `style={{ width }}`. |
543
+ | `height` | `number` | — | **Deprecated.** Use `style={{ height }}`. |
544
+
545
+ ### Scroll behavior
546
+
547
+ | Prop | Type | Default | Description |
548
+ | --- | --- | --- | --- |
549
+ | `loop` | `boolean` | `true` | Wrap-around scrolling. |
550
+ | `pagingEnabled` | `boolean` | `true` | Snap to one-item-at-a-time on release. |
551
+ | `snapEnabled` | `boolean` | `true` | When paging is off, still snap to the nearest item. |
552
+ | `overscrollEnabled` | `boolean` | `true` | Allow dragging past the edges (non-loop mode). |
553
+ | `enabled` | `boolean` | `true` | Disable all gesture input. |
554
+ | `fixedDirection` | `"positive" \| "negative"` | — | Force every swipe to move in the given direction. |
555
+ | `maxScrollDistancePerSwipe` | `number` | — | Cap on a single swipe's pixel distance. |
556
+ | `minScrollDistancePerSwipe` | `number` | — | Threshold below which a swipe is ignored. |
557
+ | `scrollAnimationDuration` | `number` | `500` | Animation duration for snap, in milliseconds. |
558
+ | `withAnimation` | `WithSpringAnimation \| WithTimingAnimation` | — | Custom animation config; takes precedence over `scrollAnimationDuration`. |
559
+ | `windowSize` | `number` | `data.length` | Number of items rendered around the visible window. Lower = better perf with very long lists. |
560
+
561
+ ### Auto-play
562
+
563
+ | Prop | Type | Default | Description |
564
+ | --- | --- | --- | --- |
565
+ | `autoPlay` | `boolean` | `false` | Automatically advance. |
566
+ | `autoPlayInterval` | `number` | `1000` | Milliseconds between auto-advances. |
567
+ | `autoPlayReverse` | `boolean` | `false` | Play backwards. |
568
+
569
+ ### Animation modes
570
+
571
+ | Prop | Type | Description |
572
+ | --- | --- | --- |
573
+ | `mode` | `"parallax" \| "horizontal-stack" \| "vertical-stack"` | Built-in animation strategy. Omit for the default linear translation. |
574
+ | `modeConfig` | `ILayoutConfig` (parallax) or stack `ILayoutConfig` | Mode-specific tuning. |
575
+ | `customAnimation` | `(value: number, index: number) => ViewStyle` | Worklet that returns the per-item style. Bypasses built-in modes. |
576
+ | `customConfig` | `CustomConfig \| (() => CustomConfig)` | Override the internal `type`/`viewCount` used by `useOffsetX`. Advanced. |
577
+
578
+ ### Callbacks
579
+
580
+ | Prop | Type | Description |
581
+ | --- | --- | --- |
582
+ | `onScrollStart` | `() => void` | Fires when a gesture begins or `next`/`prev`/`scrollTo` is called. |
583
+ | `onScrollEnd` | `(index: number) => void` | Fires when the scroll settles. |
584
+ | `onSnapToItem` | `(index: number) => void` | Fires when the carousel snaps to a new item. |
585
+ | `onProgressChange` | `((offset: number, abs: number) => void) \| SharedValue<number>` | Continuous scroll progress. Pass a SharedValue for zero-overhead worklet integration. |
586
+ | `onConfigurePanGesture` | `(pan: PanGesture) => void` | Customize the underlying Gesture Handler `PanGesture`. |
587
+ | `onLayout` | `(e: LayoutChangeEvent) => void` | Standard React Native `onLayout` for the container. |
588
+
589
+ ### Shared values
590
+
591
+ | Prop | Type | Description |
592
+ | --- | --- | --- |
593
+ | `scrollOffsetValue` | `SharedValue<number>` | External translation state; the carousel mutates this during gestures. |
594
+ | `defaultScrollOffsetValue` | `SharedValue<number>` | **Deprecated** alias for `scrollOffsetValue`. |
595
+
596
+ ### Misc
597
+
598
+ | Prop | Type | Description |
599
+ | --- | --- | --- |
600
+ | `testID` | `string` | E2E test identifier. |
601
+ | `ref` | `Ref<ICarouselInstance>` | Imperative handle. See [Programmatic control](#programmatic-control-ref). |
602
+
603
+ ---
604
+
605
+ ## TypeScript exports
606
+
607
+ ```ts
608
+ import Carousel, {
609
+ Pagination,
610
+ type TCarouselProps,
611
+ type ICarouselInstance,
612
+ type CarouselRenderItem,
613
+ type IComputedDirectionTypes,
614
+ type TAnimationStyle,
615
+ type ILayoutConfig,
616
+ } from "react-native-reanimated-carousel";
617
+ ```
618
+
619
+ - `TCarouselProps<T>` — full props shape, generic over `data[number]`.
620
+ - `ICarouselInstance` — the imperative handle (`next`, `prev`, `scrollTo`, `getCurrentIndex`).
621
+ - `CarouselRenderItem<T>` — the `renderItem` signature.
622
+ - `IComputedDirectionTypes` — internal helper for the vertical/horizontal prop variants; rarely needed at the call site.
623
+ - `TAnimationStyle` — the `customAnimation` worklet signature.
624
+ - `ILayoutConfig` — the stack mode's `modeConfig` shape.
625
+
626
+ ---
627
+
628
+ ## Migration notes (v4 → v5)
629
+
630
+ - **Sizing**: move `width`/`height` into `style`. The props still work but emit deprecation warnings.
631
+ - **Page size**: `itemWidth`/`itemHeight` now control snap distance, not container size. To show multiple items at once: keep the container at full width via `style={{ width }}`, and set `itemWidth` to the per-page distance.
632
+ - **Scroll offset**: prefer `scrollOffsetValue` over the deprecated `defaultScrollOffsetValue`.
633
+ - **Progress**: `onProgressChange` accepts a `SharedValue<number>` directly. The two-arg callback form still works.
634
+ - **Custom animations**: styles are now sanitized; non-finite `zIndex` is normalized. If you were relying on unsupported style keys, they'll be silently dropped.
635
+ - **Pagination accessibility**: both `Pagination.Basic` and `Pagination.Custom` now accept `paginationItemAccessibility` and `carouselName` props for screen-reader customization.
636
+ - **Variable-size mode** (new in this release): if you previously emulated variable widths via `customAnimation`, you can now use `getItemWidth` / `getItemHeight` for a fully integrated solution that preserves snap behavior, looping, and progress tracking.
637
+
638
+ ---
639
+
640
+ ## Performance notes
641
+
642
+ - **Synchronous rendering**: every visible item's position is a pure function of `handlerOffset` evaluated on the UI thread. The carousel doesn't await measurement before placing items, which is what makes scrolling jank-free even on slow devices.
643
+ - **`windowSize`**: for lists longer than ~20 items, set `windowSize` to a small number (e.g., 5–10) so off-screen items are not even constructed.
644
+ - **`autoFillData`**: only kicks in for `data.length` 1 or 2 when `loop=true`. For longer arrays it's a no-op; you don't need to disable it.
645
+ - **Variable-size lookups**: `O(log n)` per visible item per frame, with a cached-hint fast path for continuous scrolling that amortizes to `O(1)`. For lists in the tens of thousands, this is still well below 1 ms per frame.
646
+ - **`customAnimation`**: every worklet runs on every frame for every visible item. Keep them simple — prefer `interpolate` over hand-rolled math, and avoid allocating arrays/objects inside the worklet.
647
+
648
+ ---
649
+
650
+ ## Architecture deep dive
651
+
652
+ For contributors and curious users who want to understand the internals — the hooks ecosystem, the math behind position interpolation, the gesture state machine, and how the `SizeResolver` abstraction makes variable-size mode work — see [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md).
@@ -0,0 +1,2 @@
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=_interopRequireDefault(require("react"));var _useCommonVariables=require("../hooks/useCommonVariables");var _useInitProps=require("../hooks/useInitProps");var _usePropsErrorBoundary=require("../hooks/usePropsErrorBoundary");var _useSizeResolver=require("../hooks/useSizeResolver");var _store=require("../store");var _CarouselLayout=require("./CarouselLayout");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/leonsilicon/Developer/github/dohooo/react-native-reanimated-carousel/src/components/Carousel.tsx";var Carousel=_react.default.forwardRef(function(_props,ref){var props=(0,_useInitProps.useInitProps)(_props);var dataLength=props.dataLength,getItemSize=props.getItemSize;var commonVariables=(0,_useCommonVariables.useCommonVariables)(props);(0,_usePropsErrorBoundary.usePropsErrorBoundary)(Object.assign({},props,{dataLength:dataLength}));var sizeResolver=(0,_useSizeResolver.useSizeResolver)({dataLength:dataLength,getItemSize:getItemSize,uniformSize:commonVariables.resolvedSize});return(0,_jsxRuntime.jsx)(_store.GlobalStateProvider,{value:{props:props,common:commonVariables,sizeResolver:sizeResolver},children:(0,_jsxRuntime.jsx)(_CarouselLayout.CarouselLayout,{ref:ref})});});var _default=exports.default=Carousel;
2
+ //# sourceMappingURL=Carousel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_useCommonVariables","_useInitProps","_usePropsErrorBoundary","_useSizeResolver","_store","_CarouselLayout","_jsxRuntime","_this","_jsxFileName","Carousel","React","forwardRef","_props","ref","props","useInitProps","dataLength","getItemSize","commonVariables","useCommonVariables","usePropsErrorBoundary","Object","assign","sizeResolver","useSizeResolver","uniformSize","resolvedSize","jsx","GlobalStateProvider","value","common","children","CarouselLayout","_default","exports","default"],"sourceRoot":"../../../src","sources":["components/Carousel.tsx"],"mappings":"mKAAA,IAAAA,MAAA,CAAAC,sBAAA,CAAAC,OAAA,WACA,IAAAC,mBAAA,CAAAD,OAAA,gCACA,IAAAE,aAAA,CAAAF,OAAA,0BACA,IAAAG,sBAAA,CAAAH,OAAA,mCACA,IAAAI,gBAAA,CAAAJ,OAAA,6BACA,IAAAK,MAAA,CAAAL,OAAA,aAEA,IAAAM,eAAA,CAAAN,OAAA,qBAAkD,IAAAO,WAAA,CAAAP,OAAA,0BAAAQ,KAAA,MAAAC,YAAA,2GAElD,GAAM,CAAAC,QAAQ,CAAGC,cAAK,CAACC,UAAU,CAAyC,SAACC,MAAM,CAAEC,GAAG,CAAK,CACzF,GAAM,CAAAC,KAAK,CAAG,GAAAC,0BAAY,EAACH,MAAM,CAAC,CAClC,GAAQ,CAAAI,UAAU,CAAkBF,KAAK,CAAjCE,UAAU,CAAEC,WAAW,CAAKH,KAAK,CAArBG,WAAW,CAC/B,GAAM,CAAAC,eAAe,CAAG,GAAAC,sCAAkB,EAACL,KAAK,CAAC,CACjD,GAAAM,4CAAqB,EAAAC,MAAA,CAAAC,MAAA,IAAMR,KAAK,EAAEE,UAAU,CAAVA,UAAU,EAAE,CAAC,CAE/C,GAAM,CAAAO,YAAY,CAAG,GAAAC,gCAAe,EAAC,CACnCR,UAAU,CAAVA,UAAU,CACVC,WAAW,CAAXA,WAAW,CACXQ,WAAW,CAAEP,eAAe,CAACQ,YAC/B,CAAC,CAAC,CAEF,MACE,GAAApB,WAAA,CAAAqB,GAAA,EAACvB,MAAA,CAAAwB,mBAAmB,EAACC,KAAK,CAAE,CAAEf,KAAK,CAALA,KAAK,CAAEgB,MAAM,CAAEZ,eAAe,CAAEK,YAAY,CAAZA,YAAa,CAAE,CAAAQ,QAAA,CAC3E,GAAAzB,WAAA,CAAAqB,GAAA,EAACtB,eAAA,CAAA2B,cAAc,EAACnB,GAAG,CAAEA,GAAI,CAAE,CAAC,CACT,CAAC,CAE1B,CAAC,CAAC,CAAC,IAAAoB,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAQY1B,QAAQ","ignoreList":[]}