@fountain-ui/lab 2.0.0-beta.9 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (474) hide show
  1. package/build/commonjs/BottomSheet/BottomSheetNative.js +78 -27
  2. package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
  3. package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
  4. package/build/commonjs/BottomSheet/BottomSheetWeb.js +63 -17
  5. package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
  6. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js +79 -0
  7. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js.map +1 -0
  8. package/build/commonjs/Carousel/Carousel.js +130 -0
  9. package/build/commonjs/Carousel/Carousel.js.map +1 -0
  10. package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
  11. package/build/commonjs/Carousel/animation/animationUtils.js +9 -0
  12. package/build/commonjs/Carousel/animation/animationUtils.js.map +1 -0
  13. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js +15 -0
  14. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  15. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +26 -0
  16. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  17. package/build/commonjs/Carousel/animation/index.js +40 -0
  18. package/build/commonjs/Carousel/animation/index.js.map +1 -0
  19. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js +27 -0
  20. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  21. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +65 -0
  22. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  23. package/build/commonjs/Carousel/components/InternalContext.js +29 -0
  24. package/build/commonjs/Carousel/components/InternalContext.js.map +1 -0
  25. package/build/commonjs/Carousel/components/ItemView.js +66 -0
  26. package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
  27. package/build/commonjs/Carousel/components/RootView.js +86 -0
  28. package/build/commonjs/Carousel/components/RootView.js.map +1 -0
  29. package/build/commonjs/Carousel/components/ScrollViewGesture.js +84 -0
  30. package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -0
  31. package/build/commonjs/Carousel/components/index.js +40 -0
  32. package/build/commonjs/Carousel/components/index.js.map +1 -0
  33. package/build/commonjs/Carousel/components/useItemInterpolation.js +65 -0
  34. package/build/commonjs/Carousel/components/useItemInterpolation.js.map +1 -0
  35. package/build/commonjs/Carousel/hooks/index.js +48 -0
  36. package/build/commonjs/Carousel/hooks/index.js.map +1 -0
  37. package/build/commonjs/Carousel/hooks/useAutoplayController.js +58 -0
  38. package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
  39. package/build/commonjs/Carousel/hooks/useIndexController.js +55 -0
  40. package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
  41. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +95 -0
  42. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  43. package/build/commonjs/Carousel/hooks/useLoopedData.js +33 -0
  44. package/build/commonjs/Carousel/hooks/useLoopedData.js.map +1 -0
  45. package/build/commonjs/Carousel/hooks/usePagingAnimator.js +202 -0
  46. package/build/commonjs/Carousel/hooks/usePagingAnimator.js.map +1 -0
  47. package/build/commonjs/Carousel/index.js +16 -2
  48. package/build/commonjs/Carousel/index.js.map +1 -1
  49. package/build/commonjs/Carousel/tick.js +16 -0
  50. package/build/commonjs/Carousel/tick.js.map +1 -0
  51. package/build/commonjs/Carousel/types.js +8 -0
  52. package/build/commonjs/Carousel/types.js.map +1 -0
  53. package/build/commonjs/ComicViewer/ComicViewer.js +230 -92
  54. package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
  55. package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
  56. package/build/commonjs/ComicViewer/EncodedTile.js +10 -0
  57. package/build/commonjs/ComicViewer/EncodedTile.js.map +1 -0
  58. package/build/commonjs/ComicViewer/FastScroll.js +175 -0
  59. package/build/commonjs/ComicViewer/FastScroll.js.map +1 -0
  60. package/build/commonjs/ComicViewer/{ComicViewerItemProps.js → FastScrollProps.js} +1 -1
  61. package/build/commonjs/ComicViewer/FastScrollProps.js.map +1 -0
  62. package/build/commonjs/ComicViewer/ReloadButton.js +48 -0
  63. package/build/commonjs/ComicViewer/ReloadButton.js.map +1 -0
  64. package/build/commonjs/ComicViewer/ViewerItem.js +53 -59
  65. package/build/commonjs/ComicViewer/ViewerItem.js.map +1 -1
  66. package/build/commonjs/ComicViewer/index.js.map +1 -1
  67. package/build/commonjs/ComicViewer/util.js +27 -0
  68. package/build/commonjs/ComicViewer/util.js.map +1 -0
  69. package/build/commonjs/DateTimePicker/DateTimePicker.js +12 -3
  70. package/build/commonjs/DateTimePicker/DateTimePicker.js.map +1 -1
  71. package/build/commonjs/DateTimePicker/YearPicker.js +2 -2
  72. package/build/commonjs/DateTimePicker/YearPicker.js.map +1 -1
  73. package/build/commonjs/StatusBarProvider/Provider.js.map +1 -1
  74. package/build/commonjs/StatusBarProvider/StatusBarProvider.js +111 -2
  75. package/build/commonjs/StatusBarProvider/StatusBarProvider.js.map +1 -1
  76. package/build/commonjs/ViewPager/FluxContext.js +13 -0
  77. package/build/commonjs/ViewPager/FluxContext.js.map +1 -0
  78. package/build/commonjs/ViewPager/InternalContext.js +17 -0
  79. package/build/commonjs/ViewPager/InternalContext.js.map +1 -0
  80. package/build/commonjs/ViewPager/PageStateContext.js +14 -0
  81. package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
  82. package/build/commonjs/ViewPager/ViewPager.js +81 -0
  83. package/build/commonjs/ViewPager/ViewPager.js.map +1 -0
  84. package/build/commonjs/ViewPager/ViewPager.native.js +152 -0
  85. package/build/commonjs/ViewPager/ViewPager.native.js.map +1 -0
  86. package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
  87. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js +122 -0
  88. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  89. package/build/commonjs/ViewPager/components/FluxStoreProvider.js +37 -0
  90. package/build/commonjs/ViewPager/components/FluxStoreProvider.js.map +1 -0
  91. package/build/commonjs/ViewPager/components/index.js +24 -0
  92. package/build/commonjs/ViewPager/components/index.js.map +1 -0
  93. package/build/commonjs/ViewPager/hooks/index.js +64 -0
  94. package/build/commonjs/ViewPager/hooks/index.js.map +1 -0
  95. package/build/commonjs/ViewPager/hooks/useDispatch.js +22 -0
  96. package/build/commonjs/ViewPager/hooks/useDispatch.js.map +1 -0
  97. package/build/commonjs/ViewPager/hooks/useEagerState.js +24 -0
  98. package/build/commonjs/ViewPager/hooks/useEagerState.js.map +1 -0
  99. package/build/commonjs/ViewPager/hooks/useForceRender.js +16 -0
  100. package/build/commonjs/ViewPager/hooks/useForceRender.js.map +1 -0
  101. package/build/commonjs/ViewPager/hooks/useLazyState.js +43 -0
  102. package/build/commonjs/ViewPager/hooks/useLazyState.js.map +1 -0
  103. package/build/commonjs/ViewPager/hooks/usePageStore.js +35 -0
  104. package/build/commonjs/ViewPager/hooks/usePageStore.js.map +1 -0
  105. package/build/commonjs/ViewPager/hooks/useStore.js +26 -0
  106. package/build/commonjs/ViewPager/hooks/useStore.js.map +1 -0
  107. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js +19 -0
  108. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  109. package/build/commonjs/ViewPager/index.js +42 -2
  110. package/build/commonjs/ViewPager/index.js.map +1 -1
  111. package/build/commonjs/ViewPager/types.js +2 -0
  112. package/build/commonjs/ViewPager/types.js.map +1 -0
  113. package/build/commonjs/ViewPager/utils.js +12 -45
  114. package/build/commonjs/ViewPager/utils.js.map +1 -1
  115. package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
  116. package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
  117. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
  118. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  119. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  120. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  121. package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
  122. package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
  123. package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
  124. package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
  125. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
  126. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  127. package/build/commonjs/hooks/index.js +16 -0
  128. package/build/commonjs/hooks/index.js.map +1 -1
  129. package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
  130. package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
  131. package/build/commonjs/hooks/useHeight.js +4 -4
  132. package/build/commonjs/hooks/useHeight.js.map +1 -1
  133. package/build/commonjs/hooks/useIsMounted.js +22 -0
  134. package/build/commonjs/hooks/useIsMounted.js.map +1 -0
  135. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +3 -5
  136. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  137. package/build/commonjs/index.js +22 -1
  138. package/build/commonjs/index.js.map +1 -1
  139. package/build/module/BottomSheet/BottomSheetNative.js +73 -22
  140. package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
  141. package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
  142. package/build/module/BottomSheet/BottomSheetWeb.js +58 -18
  143. package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
  144. package/build/module/BottomSheet/useDynamicSnapPoints.js +65 -0
  145. package/build/module/BottomSheet/useDynamicSnapPoints.js.map +1 -0
  146. package/build/module/Carousel/Carousel.js +109 -0
  147. package/build/module/Carousel/Carousel.js.map +1 -0
  148. package/build/module/Carousel/CarouselProps.js.map +1 -1
  149. package/build/module/Carousel/animation/animationUtils.js +2 -0
  150. package/build/module/Carousel/animation/animationUtils.js.map +1 -0
  151. package/build/module/Carousel/animation/createDefaultItemStyle.js +3 -0
  152. package/build/module/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  153. package/build/module/Carousel/animation/createDefaultScrollAnimation.js +12 -0
  154. package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  155. package/build/module/Carousel/animation/index.js +5 -0
  156. package/build/module/Carousel/animation/index.js.map +1 -0
  157. package/build/module/Carousel/animation/normalItemStyleFactory.js +18 -0
  158. package/build/module/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  159. package/build/module/Carousel/animation/parallaxItemStyleFactory.js +55 -0
  160. package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  161. package/build/module/Carousel/components/InternalContext.js +19 -0
  162. package/build/module/Carousel/components/InternalContext.js.map +1 -0
  163. package/build/module/Carousel/components/ItemView.js +46 -0
  164. package/build/module/Carousel/components/ItemView.js.map +1 -0
  165. package/build/module/Carousel/components/RootView.js +65 -0
  166. package/build/module/Carousel/components/RootView.js.map +1 -0
  167. package/build/module/Carousel/components/ScrollViewGesture.js +69 -0
  168. package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -0
  169. package/build/module/Carousel/components/index.js +5 -0
  170. package/build/module/Carousel/components/index.js.map +1 -0
  171. package/build/module/Carousel/components/useItemInterpolation.js +51 -0
  172. package/build/module/Carousel/components/useItemInterpolation.js.map +1 -0
  173. package/build/module/Carousel/hooks/index.js +6 -0
  174. package/build/module/Carousel/hooks/index.js.map +1 -0
  175. package/build/module/Carousel/hooks/useAutoplayController.js +48 -0
  176. package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
  177. package/build/module/Carousel/hooks/useIndexController.js +44 -0
  178. package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
  179. package/build/module/Carousel/hooks/useItemVisibilityStore.js +86 -0
  180. package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  181. package/build/module/Carousel/hooks/useLoopedData.js +24 -0
  182. package/build/module/Carousel/hooks/useLoopedData.js.map +1 -0
  183. package/build/module/Carousel/hooks/usePagingAnimator.js +192 -0
  184. package/build/module/Carousel/hooks/usePagingAnimator.js.map +1 -0
  185. package/build/module/Carousel/index.js +2 -1
  186. package/build/module/Carousel/index.js.map +1 -1
  187. package/build/module/Carousel/tick.js +6 -0
  188. package/build/module/Carousel/tick.js.map +1 -0
  189. package/build/module/Carousel/types.js +4 -0
  190. package/build/module/Carousel/types.js.map +1 -0
  191. package/build/module/ComicViewer/ComicViewer.js +229 -93
  192. package/build/module/ComicViewer/ComicViewer.js.map +1 -1
  193. package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
  194. package/build/module/ComicViewer/EncodedTile.js +3 -0
  195. package/build/module/ComicViewer/EncodedTile.js.map +1 -0
  196. package/build/module/ComicViewer/FastScroll.js +152 -0
  197. package/build/module/ComicViewer/FastScroll.js.map +1 -0
  198. package/build/module/ComicViewer/FastScrollProps.js +2 -0
  199. package/build/module/ComicViewer/FastScrollProps.js.map +1 -0
  200. package/build/module/ComicViewer/ReloadButton.js +33 -0
  201. package/build/module/ComicViewer/ReloadButton.js.map +1 -0
  202. package/build/module/ComicViewer/ViewerItem.js +53 -60
  203. package/build/module/ComicViewer/ViewerItem.js.map +1 -1
  204. package/build/module/ComicViewer/index.js.map +1 -1
  205. package/build/module/ComicViewer/util.js +15 -0
  206. package/build/module/ComicViewer/util.js.map +1 -0
  207. package/build/module/DateTimePicker/DateTimePicker.js +13 -4
  208. package/build/module/DateTimePicker/DateTimePicker.js.map +1 -1
  209. package/build/module/DateTimePicker/YearPicker.js +2 -2
  210. package/build/module/DateTimePicker/YearPicker.js.map +1 -1
  211. package/build/module/StatusBarProvider/Provider.js.map +1 -1
  212. package/build/module/StatusBarProvider/StatusBarProvider.js +105 -2
  213. package/build/module/StatusBarProvider/StatusBarProvider.js.map +1 -1
  214. package/build/module/ViewPager/FluxContext.js +4 -0
  215. package/build/module/ViewPager/FluxContext.js.map +1 -0
  216. package/build/module/ViewPager/InternalContext.js +7 -0
  217. package/build/module/ViewPager/InternalContext.js.map +1 -0
  218. package/build/module/ViewPager/PageStateContext.js +5 -0
  219. package/build/module/ViewPager/PageStateContext.js.map +1 -0
  220. package/build/module/ViewPager/ViewPager.js +57 -0
  221. package/build/module/ViewPager/ViewPager.js.map +1 -0
  222. package/build/module/ViewPager/ViewPager.native.js +129 -0
  223. package/build/module/ViewPager/ViewPager.native.js.map +1 -0
  224. package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
  225. package/build/module/ViewPager/components/ChildrenMemoizedPage.js +101 -0
  226. package/build/module/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  227. package/build/module/ViewPager/components/FluxStoreProvider.js +20 -0
  228. package/build/module/ViewPager/components/FluxStoreProvider.js.map +1 -0
  229. package/build/module/ViewPager/components/index.js +3 -0
  230. package/build/module/ViewPager/components/index.js.map +1 -0
  231. package/build/module/ViewPager/hooks/index.js +8 -0
  232. package/build/module/ViewPager/hooks/index.js.map +1 -0
  233. package/build/module/ViewPager/hooks/useDispatch.js +10 -0
  234. package/build/module/ViewPager/hooks/useDispatch.js.map +1 -0
  235. package/build/module/ViewPager/hooks/useEagerState.js +12 -0
  236. package/build/module/ViewPager/hooks/useEagerState.js.map +1 -0
  237. package/build/module/ViewPager/hooks/useForceRender.js +7 -0
  238. package/build/module/ViewPager/hooks/useForceRender.js.map +1 -0
  239. package/build/module/ViewPager/hooks/useLazyState.js +28 -0
  240. package/build/module/ViewPager/hooks/useLazyState.js.map +1 -0
  241. package/build/module/ViewPager/hooks/usePageStore.js +25 -0
  242. package/build/module/ViewPager/hooks/usePageStore.js.map +1 -0
  243. package/build/module/ViewPager/hooks/useStore.js +14 -0
  244. package/build/module/ViewPager/hooks/useStore.js.map +1 -0
  245. package/build/module/ViewPager/hooks/useViewPagerPageState.js +7 -0
  246. package/build/module/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  247. package/build/module/ViewPager/index.js +3 -1
  248. package/build/module/ViewPager/index.js.map +1 -1
  249. package/build/module/ViewPager/types.js +2 -0
  250. package/build/module/ViewPager/types.js.map +1 -0
  251. package/build/module/ViewPager/utils.js +6 -34
  252. package/build/module/ViewPager/utils.js.map +1 -1
  253. package/build/module/ViewabilityTrackerView/Viewability.js +2 -0
  254. package/build/module/ViewabilityTrackerView/Viewability.js.map +1 -0
  255. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js +28 -0
  256. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  257. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  258. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  259. package/build/module/ViewabilityTrackerView/index.js +2 -0
  260. package/build/module/ViewabilityTrackerView/index.js.map +1 -0
  261. package/build/module/ViewabilityTrackerView/measureViewability.js +34 -0
  262. package/build/module/ViewabilityTrackerView/measureViewability.js.map +1 -0
  263. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js +73 -0
  264. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  265. package/build/module/hooks/index.js +2 -0
  266. package/build/module/hooks/index.js.map +1 -1
  267. package/build/module/hooks/useDeferredExecutor.js +33 -0
  268. package/build/module/hooks/useDeferredExecutor.js.map +1 -0
  269. package/build/module/hooks/useHeight.js +2 -3
  270. package/build/module/hooks/useHeight.js.map +1 -1
  271. package/build/module/hooks/useIsMounted.js +13 -0
  272. package/build/module/hooks/useIsMounted.js.map +1 -0
  273. package/build/module/hooks/useUnstableCollapsibleAppBar.js +4 -6
  274. package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  275. package/build/module/index.js +2 -0
  276. package/build/module/index.js.map +1 -1
  277. package/build/typescript/AnimatedY/AnimatedY.d.ts +1 -0
  278. package/build/typescript/BottomSheet/BottomSheetNative.d.ts +1 -0
  279. package/build/typescript/BottomSheet/BottomSheetProps.d.ts +22 -1
  280. package/build/typescript/BottomSheet/BottomSheetWeb.d.ts +1 -0
  281. package/build/typescript/BottomSheet/TransparentBackdrop.d.ts +1 -0
  282. package/build/typescript/BottomSheet/useDynamicSnapPoints.d.ts +13 -0
  283. package/build/typescript/Carousel/Carousel.d.ts +5 -0
  284. package/build/typescript/Carousel/CarouselProps.d.ts +33 -48
  285. package/build/typescript/Carousel/animation/animationUtils.d.ts +1 -0
  286. package/build/typescript/Carousel/animation/createDefaultItemStyle.d.ts +2 -0
  287. package/build/typescript/Carousel/animation/createDefaultScrollAnimation.d.ts +2 -0
  288. package/build/typescript/Carousel/animation/index.d.ts +4 -0
  289. package/build/typescript/Carousel/animation/normalItemStyleFactory.d.ts +2 -0
  290. package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +9 -0
  291. package/build/typescript/Carousel/components/InternalContext.d.ts +14 -0
  292. package/build/typescript/Carousel/components/ItemView.d.ts +9 -0
  293. package/build/typescript/Carousel/components/RootView.d.ts +16 -0
  294. package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +12 -0
  295. package/build/typescript/Carousel/components/index.d.ts +4 -0
  296. package/build/typescript/Carousel/components/useItemInterpolation.d.ts +2 -0
  297. package/build/typescript/Carousel/hooks/index.d.ts +5 -0
  298. package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
  299. package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
  300. package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +7 -0
  301. package/build/typescript/Carousel/hooks/useLoopedData.d.ts +1 -0
  302. package/build/typescript/Carousel/hooks/usePagingAnimator.d.ts +17 -0
  303. package/build/typescript/Carousel/index.d.ts +3 -1
  304. package/build/typescript/Carousel/tick.d.ts +2 -0
  305. package/build/typescript/Carousel/types.d.ts +91 -0
  306. package/build/typescript/ComicViewer/ComicViewer.d.ts +2 -1
  307. package/build/typescript/ComicViewer/ComicViewerProps.d.ts +61 -43
  308. package/build/typescript/ComicViewer/EncodedTile.d.ts +2 -0
  309. package/build/typescript/ComicViewer/FastScroll.d.ts +4 -0
  310. package/build/typescript/ComicViewer/FastScrollProps.d.ts +74 -0
  311. package/build/typescript/ComicViewer/ReloadButton.d.ts +7 -0
  312. package/build/typescript/ComicViewer/ViewerItem.d.ts +46 -7
  313. package/build/typescript/ComicViewer/index.d.ts +3 -2
  314. package/build/typescript/ComicViewer/util.d.ts +2 -0
  315. package/build/typescript/DateTimePicker/DateTimePicker.d.ts +1 -0
  316. package/build/typescript/DateTimePicker/YearPicker.d.ts +1 -0
  317. package/build/typescript/FlipCard/FlipCard.d.ts +1 -0
  318. package/build/typescript/StatusBarProvider/Provider.d.ts +13 -0
  319. package/build/typescript/StatusBarProvider/StatusBarProvider.d.ts +1 -0
  320. package/build/typescript/ViewPager/FluxContext.d.ts +5 -0
  321. package/build/typescript/ViewPager/InternalContext.d.ts +7 -0
  322. package/build/typescript/ViewPager/PageStateContext.d.ts +6 -0
  323. package/build/typescript/ViewPager/ViewPager.d.ts +5 -0
  324. package/build/typescript/ViewPager/ViewPager.native.d.ts +5 -0
  325. package/build/typescript/ViewPager/ViewPagerProps.d.ts +21 -27
  326. package/build/typescript/ViewPager/components/ChildrenMemoizedPage.d.ts +14 -0
  327. package/build/typescript/ViewPager/components/FluxStoreProvider.d.ts +6 -0
  328. package/build/typescript/ViewPager/components/index.d.ts +2 -0
  329. package/build/typescript/ViewPager/hooks/index.d.ts +7 -0
  330. package/build/typescript/ViewPager/hooks/useDispatch.d.ts +2 -0
  331. package/build/typescript/ViewPager/hooks/useEagerState.d.ts +1 -0
  332. package/build/typescript/ViewPager/hooks/useForceRender.d.ts +2 -0
  333. package/build/typescript/ViewPager/hooks/useLazyState.d.ts +2 -0
  334. package/build/typescript/ViewPager/hooks/usePageStore.d.ts +2 -0
  335. package/build/typescript/ViewPager/hooks/useStore.d.ts +2 -0
  336. package/build/typescript/ViewPager/hooks/useViewPagerPageState.d.ts +1 -0
  337. package/build/typescript/ViewPager/index.d.ts +4 -1
  338. package/build/typescript/ViewPager/types.d.ts +12 -0
  339. package/build/typescript/ViewPager/utils.d.ts +5 -20
  340. package/build/typescript/ViewabilityTrackerView/Viewability.d.ts +3 -0
  341. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +3 -0
  342. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerViewProps.d.ts +22 -0
  343. package/build/typescript/ViewabilityTrackerView/index.d.ts +2 -0
  344. package/build/typescript/ViewabilityTrackerView/measureViewability.d.ts +11 -0
  345. package/build/typescript/ViewabilityTrackerView/useViewabilityTracker.d.ts +11 -0
  346. package/build/typescript/hooks/index.d.ts +2 -0
  347. package/build/typescript/hooks/useDeferredExecutor.d.ts +11 -0
  348. package/build/typescript/hooks/useIsMounted.d.ts +4 -0
  349. package/build/typescript/index.d.ts +2 -0
  350. package/package.json +10 -25
  351. package/src/BottomSheet/BottomSheetNative.tsx +76 -21
  352. package/src/BottomSheet/BottomSheetProps.ts +26 -1
  353. package/src/BottomSheet/BottomSheetWeb.tsx +67 -24
  354. package/src/BottomSheet/useDynamicSnapPoints.ts +87 -0
  355. package/src/Carousel/Carousel.tsx +135 -0
  356. package/src/Carousel/CarouselProps.ts +42 -53
  357. package/src/Carousel/animation/animationUtils.ts +1 -0
  358. package/src/Carousel/animation/createDefaultItemStyle.ts +3 -0
  359. package/src/Carousel/animation/createDefaultScrollAnimation.ts +14 -0
  360. package/src/Carousel/animation/index.ts +4 -0
  361. package/src/Carousel/animation/normalItemStyleFactory.ts +19 -0
  362. package/src/Carousel/animation/parallaxItemStyleFactory.ts +79 -0
  363. package/src/Carousel/components/InternalContext.ts +33 -0
  364. package/src/Carousel/components/ItemView.tsx +66 -0
  365. package/src/Carousel/components/RootView.tsx +79 -0
  366. package/src/Carousel/components/ScrollViewGesture.tsx +93 -0
  367. package/src/Carousel/components/index.ts +4 -0
  368. package/src/Carousel/components/useItemInterpolation.ts +107 -0
  369. package/src/Carousel/hooks/index.ts +5 -0
  370. package/src/Carousel/hooks/useAutoplayController.ts +57 -0
  371. package/src/Carousel/hooks/useIndexController.tsx +57 -0
  372. package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
  373. package/src/Carousel/hooks/useLoopedData.ts +26 -0
  374. package/src/Carousel/hooks/usePagingAnimator.ts +255 -0
  375. package/src/Carousel/index.ts +4 -2
  376. package/src/Carousel/tick.ts +6 -0
  377. package/src/Carousel/types.ts +114 -0
  378. package/src/ComicViewer/ComicViewer.tsx +268 -106
  379. package/src/ComicViewer/ComicViewerProps.ts +66 -44
  380. package/src/ComicViewer/EncodedTile.ts +3 -0
  381. package/src/ComicViewer/FastScroll.tsx +176 -0
  382. package/src/ComicViewer/FastScrollProps.ts +88 -0
  383. package/src/ComicViewer/ReloadButton.tsx +36 -0
  384. package/src/ComicViewer/ViewerItem.tsx +104 -62
  385. package/src/ComicViewer/index.ts +8 -2
  386. package/src/ComicViewer/util.ts +15 -0
  387. package/src/DateTimePicker/DateTimePicker.tsx +11 -3
  388. package/src/DateTimePicker/YearPicker.tsx +2 -2
  389. package/src/StatusBarProvider/Provider.ts +14 -0
  390. package/src/StatusBarProvider/StatusBarProvider.tsx +103 -1
  391. package/src/ViewPager/FluxContext.ts +8 -0
  392. package/src/ViewPager/InternalContext.ts +13 -0
  393. package/src/ViewPager/PageStateContext.ts +11 -0
  394. package/src/ViewPager/ViewPager.native.tsx +152 -0
  395. package/src/ViewPager/ViewPager.tsx +69 -0
  396. package/src/ViewPager/ViewPagerProps.ts +25 -34
  397. package/src/ViewPager/components/ChildrenMemoizedPage.tsx +124 -0
  398. package/src/ViewPager/components/FluxStoreProvider.tsx +27 -0
  399. package/src/ViewPager/components/index.ts +2 -0
  400. package/src/ViewPager/hooks/index.ts +7 -0
  401. package/src/ViewPager/hooks/useDispatch.ts +11 -0
  402. package/src/ViewPager/hooks/useEagerState.ts +14 -0
  403. package/src/ViewPager/hooks/useForceRender.ts +7 -0
  404. package/src/ViewPager/hooks/useLazyState.ts +32 -0
  405. package/src/ViewPager/hooks/usePageStore.ts +30 -0
  406. package/src/ViewPager/hooks/useStore.ts +15 -0
  407. package/src/ViewPager/hooks/useViewPagerPageState.ts +6 -0
  408. package/src/ViewPager/index.ts +11 -2
  409. package/src/ViewPager/types.ts +15 -0
  410. package/src/ViewPager/utils.tsx +9 -56
  411. package/src/ViewabilityTrackerView/Viewability.ts +3 -0
  412. package/src/ViewabilityTrackerView/ViewabilityTrackerView.tsx +33 -0
  413. package/src/ViewabilityTrackerView/ViewabilityTrackerViewProps.ts +25 -0
  414. package/src/ViewabilityTrackerView/index.ts +2 -0
  415. package/src/ViewabilityTrackerView/measureViewability.ts +54 -0
  416. package/src/ViewabilityTrackerView/useViewabilityTracker.ts +85 -0
  417. package/src/hooks/index.ts +2 -0
  418. package/src/hooks/useDeferredExecutor.ts +46 -0
  419. package/src/hooks/useHeight.ts +3 -4
  420. package/src/hooks/useIsMounted.ts +19 -0
  421. package/src/hooks/useUnstableCollapsibleAppBar.ts +4 -4
  422. package/src/index.ts +3 -0
  423. package/build/commonjs/Carousel/CarouselNative.js +0 -72
  424. package/build/commonjs/Carousel/CarouselNative.js.map +0 -1
  425. package/build/commonjs/Carousel/CarouselWeb.js +0 -237
  426. package/build/commonjs/Carousel/CarouselWeb.js.map +0 -1
  427. package/build/commonjs/Carousel/index.native.js.map +0 -1
  428. package/build/commonjs/Carousel/utils.js +0 -19
  429. package/build/commonjs/Carousel/utils.js.map +0 -1
  430. package/build/commonjs/ComicViewer/ComicViewerItemProps.js.map +0 -1
  431. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +0 -49
  432. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  433. package/build/commonjs/ViewPager/ViewPagerNative.js +0 -75
  434. package/build/commonjs/ViewPager/ViewPagerNative.js.map +0 -1
  435. package/build/commonjs/ViewPager/ViewPagerWeb.js +0 -55
  436. package/build/commonjs/ViewPager/ViewPagerWeb.js.map +0 -1
  437. package/build/commonjs/ViewPager/index.native.js +0 -16
  438. package/build/commonjs/ViewPager/index.native.js.map +0 -1
  439. package/build/module/Carousel/CarouselNative.js +0 -54
  440. package/build/module/Carousel/CarouselNative.js.map +0 -1
  441. package/build/module/Carousel/CarouselWeb.js +0 -215
  442. package/build/module/Carousel/CarouselWeb.js.map +0 -1
  443. package/build/module/Carousel/index.native.js +0 -2
  444. package/build/module/Carousel/index.native.js.map +0 -1
  445. package/build/module/Carousel/utils.js +0 -7
  446. package/build/module/Carousel/utils.js.map +0 -1
  447. package/build/module/ComicViewer/ComicViewerItemProps.js +0 -2
  448. package/build/module/ComicViewer/ComicViewerItemProps.js.map +0 -1
  449. package/build/module/ViewPager/ChildrenMemoizedPage.js +0 -37
  450. package/build/module/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  451. package/build/module/ViewPager/ViewPagerNative.js +0 -58
  452. package/build/module/ViewPager/ViewPagerNative.js.map +0 -1
  453. package/build/module/ViewPager/ViewPagerWeb.js +0 -41
  454. package/build/module/ViewPager/ViewPagerWeb.js.map +0 -1
  455. package/build/module/ViewPager/index.native.js +0 -2
  456. package/build/module/ViewPager/index.native.js.map +0 -1
  457. package/build/typescript/Carousel/CarouselNative.d.ts +0 -2
  458. package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
  459. package/build/typescript/Carousel/index.native.d.ts +0 -1
  460. package/build/typescript/Carousel/utils.d.ts +0 -6
  461. package/build/typescript/ComicViewer/ComicViewerItemProps.d.ts +0 -12
  462. package/build/typescript/ViewPager/ChildrenMemoizedPage.d.ts +0 -4
  463. package/build/typescript/ViewPager/ViewPagerNative.d.ts +0 -2
  464. package/build/typescript/ViewPager/ViewPagerWeb.d.ts +0 -2
  465. package/build/typescript/ViewPager/index.native.d.ts +0 -1
  466. package/src/Carousel/CarouselNative.tsx +0 -67
  467. package/src/Carousel/CarouselWeb.tsx +0 -222
  468. package/src/Carousel/index.native.ts +0 -1
  469. package/src/Carousel/utils.ts +0 -11
  470. package/src/ComicViewer/ComicViewerItemProps.ts +0 -15
  471. package/src/ViewPager/ChildrenMemoizedPage.tsx +0 -36
  472. package/src/ViewPager/ViewPagerNative.tsx +0 -73
  473. package/src/ViewPager/ViewPagerWeb.tsx +0 -52
  474. package/src/ViewPager/index.native.ts +0 -1
@@ -0,0 +1,65 @@
1
+ import { useCallback, useMemo, useRef, useState } from 'react';
2
+ import { useWindowDimensions } from 'react-native';
3
+ import * as R from 'ramda';
4
+ const INITIAL_CONTAINER_HEIGHT = -999;
5
+
6
+ const convertSnapPoint = (snapPoint, windowHeight, maxDynamicContentSize) => {
7
+ if (typeof snapPoint === 'number') {
8
+ return Math.min(maxDynamicContentSize, snapPoint);
9
+ }
10
+
11
+ const percentageRegex = new RegExp(/^[0-9]+%$/);
12
+
13
+ if (percentageRegex.test(snapPoint)) {
14
+ const percentage = parseFloat(snapPoint) / 100;
15
+ return isNaN(percentage) ? 0 : Math.min(maxDynamicContentSize, Math.round(windowHeight * percentage));
16
+ }
17
+
18
+ return 0;
19
+ };
20
+
21
+ export default function useDynamicSnapPoints(params) {
22
+ const {
23
+ enableDynamicSizing,
24
+ maxDynamicContentSize,
25
+ snapPoints
26
+ } = params;
27
+ const {
28
+ height: windowHeight
29
+ } = useWindowDimensions();
30
+ const [contentHeight, setContentHeight] = useState(INITIAL_CONTAINER_HEIGHT);
31
+ const hasMeasureRef = useRef(false);
32
+ const convertedSnapPoints = useMemo(() => {
33
+ if (contentHeight === INITIAL_CONTAINER_HEIGHT) {
34
+ return [];
35
+ }
36
+
37
+ const convertedSnapPoints = snapPoints.map(snapPoint => {
38
+ return convertSnapPoint(snapPoint, windowHeight, maxDynamicContentSize);
39
+ });
40
+
41
+ if (enableDynamicSizing && contentHeight !== 0) {
42
+ convertedSnapPoints.push(convertSnapPoint(contentHeight, windowHeight, maxDynamicContentSize));
43
+ }
44
+
45
+ return Array.from(new Set(convertedSnapPoints)).sort((a, b) => a - b);
46
+ }, [contentHeight, enableDynamicSizing, maxDynamicContentSize, snapPoints, windowHeight]);
47
+ const highestSnapPoint = R.last(convertedSnapPoints) ?? maxDynamicContentSize;
48
+ const handleLayout = useCallback(event => {
49
+ if (hasMeasureRef.current) {
50
+ return;
51
+ }
52
+
53
+ hasMeasureRef.current = true;
54
+ const {
55
+ height
56
+ } = event.nativeEvent.layout;
57
+ setContentHeight(height);
58
+ }, []);
59
+ return {
60
+ convertedSnapPoints,
61
+ handleLayout,
62
+ highestSnapPoint
63
+ };
64
+ }
65
+ //# sourceMappingURL=useDynamicSnapPoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useMemo","useRef","useState","useWindowDimensions","R","INITIAL_CONTAINER_HEIGHT","convertSnapPoint","snapPoint","windowHeight","maxDynamicContentSize","Math","min","percentageRegex","RegExp","test","percentage","parseFloat","isNaN","round","useDynamicSnapPoints","params","enableDynamicSizing","snapPoints","height","contentHeight","setContentHeight","hasMeasureRef","convertedSnapPoints","map","push","Array","from","Set","sort","a","b","highestSnapPoint","last","handleLayout","event","current","nativeEvent","layout"],"sources":["useDynamicSnapPoints.ts"],"sourcesContent":["import { useCallback, useMemo, useRef, useState } from 'react';\nimport { LayoutChangeEvent, useWindowDimensions } from 'react-native';\nimport * as R from 'ramda';\n\nconst INITIAL_CONTAINER_HEIGHT = -999;\n\ninterface UseDynamicSnapPointsParams {\n enableDynamicSizing: boolean;\n maxDynamicContentSize: number;\n snapPoints: (number | string)[];\n}\n\ninterface UseDynamicSnapPointsReturns {\n convertedSnapPoints: number[];\n handleLayout: (e: LayoutChangeEvent) => void;\n highestSnapPoint: number;\n}\n\nconst convertSnapPoint = (snapPoint: number | string, windowHeight: number, maxDynamicContentSize: number): number => {\n if (typeof snapPoint === 'number') {\n return Math.min(maxDynamicContentSize, snapPoint);\n }\n\n const percentageRegex = new RegExp(/^[0-9]+%$/);\n if (percentageRegex.test(snapPoint)) {\n const percentage = parseFloat(snapPoint) / 100;\n return isNaN(percentage) ? 0 : Math.min(maxDynamicContentSize, Math.round(windowHeight * percentage));\n }\n\n return 0;\n};\n\nexport default function useDynamicSnapPoints(params: UseDynamicSnapPointsParams): UseDynamicSnapPointsReturns {\n const {\n enableDynamicSizing,\n maxDynamicContentSize,\n snapPoints,\n } = params;\n\n const { height: windowHeight } = useWindowDimensions();\n\n const [contentHeight, setContentHeight] = useState<number>(INITIAL_CONTAINER_HEIGHT);\n\n const hasMeasureRef = useRef<boolean>(false);\n\n const convertedSnapPoints = useMemo(() => {\n if (contentHeight === INITIAL_CONTAINER_HEIGHT) {\n return [];\n }\n\n const convertedSnapPoints = snapPoints.map((snapPoint) => {\n return convertSnapPoint(snapPoint, windowHeight, maxDynamicContentSize);\n });\n\n if (enableDynamicSizing && contentHeight !== 0) {\n convertedSnapPoints.push(\n convertSnapPoint(contentHeight, windowHeight, maxDynamicContentSize),\n );\n }\n\n return Array.from(new Set(convertedSnapPoints)).sort((a, b) => a - b);\n }, [\n contentHeight,\n enableDynamicSizing,\n maxDynamicContentSize,\n snapPoints,\n windowHeight,\n ]);\n\n const highestSnapPoint = R.last(convertedSnapPoints) ?? maxDynamicContentSize;\n\n const handleLayout = useCallback((event: LayoutChangeEvent) => {\n if (hasMeasureRef.current) {\n return;\n }\n\n hasMeasureRef.current = true;\n const { height } = event.nativeEvent.layout;\n setContentHeight(height);\n }, []);\n\n return {\n convertedSnapPoints,\n handleLayout,\n highestSnapPoint,\n };\n}\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,OAAtB,EAA+BC,MAA/B,EAAuCC,QAAvC,QAAuD,OAAvD;AACA,SAA4BC,mBAA5B,QAAuD,cAAvD;AACA,OAAO,KAAKC,CAAZ,MAAmB,OAAnB;AAEA,MAAMC,wBAAwB,GAAG,CAAC,GAAlC;;AAcA,MAAMC,gBAAgB,GAAG,CAACC,SAAD,EAA6BC,YAA7B,EAAmDC,qBAAnD,KAA6F;EAClH,IAAI,OAAOF,SAAP,KAAqB,QAAzB,EAAmC;IAC/B,OAAOG,IAAI,CAACC,GAAL,CAASF,qBAAT,EAAgCF,SAAhC,CAAP;EACH;;EAED,MAAMK,eAAe,GAAG,IAAIC,MAAJ,CAAW,WAAX,CAAxB;;EACA,IAAID,eAAe,CAACE,IAAhB,CAAqBP,SAArB,CAAJ,EAAqC;IACjC,MAAMQ,UAAU,GAAGC,UAAU,CAACT,SAAD,CAAV,GAAwB,GAA3C;IACA,OAAOU,KAAK,CAACF,UAAD,CAAL,GAAoB,CAApB,GAAwBL,IAAI,CAACC,GAAL,CAASF,qBAAT,EAAgCC,IAAI,CAACQ,KAAL,CAAWV,YAAY,GAAGO,UAA1B,CAAhC,CAA/B;EACH;;EAED,OAAO,CAAP;AACH,CAZD;;AAcA,eAAe,SAASI,oBAAT,CAA8BC,MAA9B,EAA+F;EAC1G,MAAM;IACFC,mBADE;IAEFZ,qBAFE;IAGFa;EAHE,IAIFF,MAJJ;EAMA,MAAM;IAAEG,MAAM,EAAEf;EAAV,IAA2BL,mBAAmB,EAApD;EAEA,MAAM,CAACqB,aAAD,EAAgBC,gBAAhB,IAAoCvB,QAAQ,CAASG,wBAAT,CAAlD;EAEA,MAAMqB,aAAa,GAAGzB,MAAM,CAAU,KAAV,CAA5B;EAEA,MAAM0B,mBAAmB,GAAG3B,OAAO,CAAC,MAAM;IACtC,IAAIwB,aAAa,KAAKnB,wBAAtB,EAAgD;MAC5C,OAAO,EAAP;IACH;;IAED,MAAMsB,mBAAmB,GAAGL,UAAU,CAACM,GAAX,CAAgBrB,SAAD,IAAe;MACtD,OAAOD,gBAAgB,CAACC,SAAD,EAAYC,YAAZ,EAA0BC,qBAA1B,CAAvB;IACH,CAF2B,CAA5B;;IAIA,IAAIY,mBAAmB,IAAIG,aAAa,KAAK,CAA7C,EAAgD;MAC5CG,mBAAmB,CAACE,IAApB,CACIvB,gBAAgB,CAACkB,aAAD,EAAgBhB,YAAhB,EAA8BC,qBAA9B,CADpB;IAGH;;IAED,OAAOqB,KAAK,CAACC,IAAN,CAAW,IAAIC,GAAJ,CAAQL,mBAAR,CAAX,EAAyCM,IAAzC,CAA8C,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,GAAGC,CAA5D,CAAP;EACH,CAhBkC,EAgBhC,CACCX,aADD,EAECH,mBAFD,EAGCZ,qBAHD,EAICa,UAJD,EAKCd,YALD,CAhBgC,CAAnC;EAwBA,MAAM4B,gBAAgB,GAAGhC,CAAC,CAACiC,IAAF,CAAOV,mBAAP,KAA+BlB,qBAAxD;EAEA,MAAM6B,YAAY,GAAGvC,WAAW,CAAEwC,KAAD,IAA8B;IAC3D,IAAIb,aAAa,CAACc,OAAlB,EAA2B;MACvB;IACH;;IAEDd,aAAa,CAACc,OAAd,GAAwB,IAAxB;IACA,MAAM;MAAEjB;IAAF,IAAagB,KAAK,CAACE,WAAN,CAAkBC,MAArC;IACAjB,gBAAgB,CAACF,MAAD,CAAhB;EACH,CAR+B,EAQ7B,EAR6B,CAAhC;EAUA,OAAO;IACHI,mBADG;IAEHW,YAFG;IAGHF;EAHG,CAAP;AAKH"}
@@ -0,0 +1,109 @@
1
+ import React, { forwardRef, memo, useImperativeHandle, useMemo } from 'react';
2
+ import ViewabilityTrackerView from '../ViewabilityTrackerView';
3
+ import { useAutoplayController, useIndexController, useItemVisibilityStore, useLoopedData, usePagingAnimator } from './hooks';
4
+ import { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';
5
+ import { InternalContext, RootView, ScrollViewGesture } from './components';
6
+ const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
7
+ const {
8
+ autoplay = false,
9
+ autoplayInterval = 3000,
10
+ createItemStyle = createDefaultItemStyle,
11
+ createScrollAnimation = createDefaultScrollAnimation,
12
+ data: originalData,
13
+ disableSmartAutoplay = false,
14
+ initialIndex = 0,
15
+ itemHeight,
16
+ itemWidth,
17
+ loop = false,
18
+ onIndexChange,
19
+ renderItem,
20
+ scrollEnabled = true,
21
+ style,
22
+ windowSize = 5
23
+ } = props;
24
+ const data = useLoopedData(originalData, loop);
25
+ const [itemVisibilityStore, onPositionChange] = useItemVisibilityStore({
26
+ initialIndex,
27
+ numberOfData: data.length,
28
+ windowSize
29
+ });
30
+ const indexController = useIndexController({
31
+ initialIndex,
32
+ itemWidth,
33
+ numberOfData: data.length,
34
+ numberOfOriginalData: originalData.length,
35
+ onIndexChange,
36
+ onPositionChange
37
+ });
38
+ const {
39
+ getCurrentIndex
40
+ } = indexController;
41
+ const {
42
+ gestureTranslationX,
43
+ globalInterpolation,
44
+ interruptAnimation,
45
+ startPagingAnimation
46
+ } = usePagingAnimator({
47
+ createScrollAnimation,
48
+ itemWidth,
49
+ indexController,
50
+ initialIndex,
51
+ loop,
52
+ numberOfData: data.length
53
+ });
54
+ const autoplayController = useAutoplayController({
55
+ enabled: autoplay,
56
+ intervalMillis: autoplayInterval,
57
+ startPagingAnimation
58
+ });
59
+ useImperativeHandle(ref, () => ({
60
+ getCurrentIndex,
61
+ next: () => startPagingAnimation('directional', {
62
+ direction: 'next'
63
+ }),
64
+ prev: () => startPagingAnimation('directional', {
65
+ direction: 'prev'
66
+ }),
67
+ scrollTo: option => startPagingAnimation('index', option)
68
+ }), [startPagingAnimation, getCurrentIndex]);
69
+ const contextValue = useMemo(() => ({
70
+ createItemStyle,
71
+ data,
72
+ globalInterpolation,
73
+ itemHeight,
74
+ itemWidth,
75
+ itemVisibilityStore,
76
+ loop
77
+ }), [createItemStyle, data, globalInterpolation, itemHeight, itemWidth, itemVisibilityStore, loop]);
78
+ return /*#__PURE__*/React.createElement(InternalContext.Provider, {
79
+ value: contextValue
80
+ }, /*#__PURE__*/React.createElement(ViewabilityTrackerView, {
81
+ enabled: autoplay && !disableSmartAutoplay,
82
+ measurementIntervalMillis: Math.max(3000, autoplayInterval),
83
+ onViewabilityChange: _ref => {
84
+ let {
85
+ visible
86
+ } = _ref;
87
+
88
+ if (visible) {
89
+ autoplayController.resume();
90
+ } else {
91
+ autoplayController.pause();
92
+ }
93
+ }
94
+ }, /*#__PURE__*/React.createElement(ScrollViewGesture, {
95
+ autoplayController: autoplayController,
96
+ gestureTranslationX: gestureTranslationX,
97
+ interruptAnimation: interruptAnimation,
98
+ scrollEnabled: scrollEnabled,
99
+ startPagingAnimation: startPagingAnimation
100
+ }, /*#__PURE__*/React.createElement(RootView, {
101
+ data: data,
102
+ itemHeight: itemHeight,
103
+ originalData: originalData,
104
+ renderItem: renderItem,
105
+ style: style
106
+ }))));
107
+ });
108
+ export default /*#__PURE__*/memo(Carousel);
109
+ //# sourceMappingURL=Carousel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","memo","useImperativeHandle","useMemo","ViewabilityTrackerView","useAutoplayController","useIndexController","useItemVisibilityStore","useLoopedData","usePagingAnimator","createDefaultItemStyle","createDefaultScrollAnimation","InternalContext","RootView","ScrollViewGesture","Carousel","props","ref","autoplay","autoplayInterval","createItemStyle","createScrollAnimation","data","originalData","disableSmartAutoplay","initialIndex","itemHeight","itemWidth","loop","onIndexChange","renderItem","scrollEnabled","style","windowSize","itemVisibilityStore","onPositionChange","numberOfData","length","indexController","numberOfOriginalData","getCurrentIndex","gestureTranslationX","globalInterpolation","interruptAnimation","startPagingAnimation","autoplayController","enabled","intervalMillis","next","direction","prev","scrollTo","option","contextValue","Math","max","visible","resume","pause"],"sources":["Carousel.tsx"],"sourcesContent":["import React, { forwardRef, memo, useImperativeHandle, useMemo } from 'react';\nimport ViewabilityTrackerView from '../ViewabilityTrackerView';\nimport type CarouselProps from './CarouselProps';\nimport type { CarouselInstance } from './types';\nimport {\n useAutoplayController,\n useIndexController,\n useItemVisibilityStore,\n useLoopedData,\n usePagingAnimator,\n} from './hooks';\nimport { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';\nimport { InternalContext, RootView, ScrollViewGesture } from './components';\n\nconst Carousel = forwardRef<CarouselInstance, CarouselProps>(function Carousel(props, ref) {\n const {\n autoplay = false,\n autoplayInterval = 3000,\n createItemStyle = createDefaultItemStyle,\n createScrollAnimation = createDefaultScrollAnimation,\n data: originalData,\n disableSmartAutoplay = false,\n initialIndex = 0,\n itemHeight,\n itemWidth,\n loop = false,\n onIndexChange,\n renderItem,\n scrollEnabled = true,\n style,\n windowSize = 5,\n } = props;\n\n const data = useLoopedData(originalData, loop);\n\n const [itemVisibilityStore, onPositionChange] = useItemVisibilityStore({\n initialIndex,\n numberOfData: data.length,\n windowSize,\n });\n\n const indexController = useIndexController({\n initialIndex,\n itemWidth,\n numberOfData: data.length,\n numberOfOriginalData: originalData.length,\n onIndexChange,\n onPositionChange,\n });\n\n const { getCurrentIndex } = indexController;\n\n const {\n gestureTranslationX,\n globalInterpolation,\n interruptAnimation,\n startPagingAnimation,\n } = usePagingAnimator({\n createScrollAnimation,\n itemWidth,\n indexController,\n initialIndex,\n loop,\n numberOfData: data.length,\n });\n\n const autoplayController = useAutoplayController({\n enabled: autoplay,\n intervalMillis: autoplayInterval,\n startPagingAnimation,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n getCurrentIndex,\n next: () => startPagingAnimation('directional', { direction: 'next' }),\n prev: () => startPagingAnimation('directional', { direction: 'prev' }),\n scrollTo: (option) => startPagingAnimation('index', option),\n }),\n [startPagingAnimation, getCurrentIndex],\n );\n\n const contextValue = useMemo(() => ({\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n }), [\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n ]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n <ViewabilityTrackerView\n enabled={autoplay && !disableSmartAutoplay}\n measurementIntervalMillis={Math.max(3000, autoplayInterval)}\n onViewabilityChange={({ visible }) => {\n if (visible) {\n autoplayController.resume();\n } else {\n autoplayController.pause();\n }\n }}\n >\n <ScrollViewGesture\n autoplayController={autoplayController}\n gestureTranslationX={gestureTranslationX}\n interruptAnimation={interruptAnimation}\n scrollEnabled={scrollEnabled}\n startPagingAnimation={startPagingAnimation}\n >\n <RootView\n data={data}\n itemHeight={itemHeight}\n originalData={originalData}\n renderItem={renderItem}\n style={style}\n />\n </ScrollViewGesture>\n </ViewabilityTrackerView>\n </InternalContext.Provider>\n );\n});\n\nexport default memo(Carousel);\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,IAA5B,EAAkCC,mBAAlC,EAAuDC,OAAvD,QAAsE,OAAtE;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAGA,SACIC,qBADJ,EAEIC,kBAFJ,EAGIC,sBAHJ,EAIIC,aAJJ,EAKIC,iBALJ,QAMO,SANP;AAOA,SAASC,sBAAT,EAAiCC,4BAAjC,QAAqE,aAArE;AACA,SAASC,eAAT,EAA0BC,QAA1B,EAAoCC,iBAApC,QAA6D,cAA7D;AAEA,MAAMC,QAAQ,gBAAGf,UAAU,CAAkC,SAASe,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EACvF,MAAM;IACFC,QAAQ,GAAG,KADT;IAEFC,gBAAgB,GAAG,IAFjB;IAGFC,eAAe,GAAGV,sBAHhB;IAIFW,qBAAqB,GAAGV,4BAJtB;IAKFW,IAAI,EAAEC,YALJ;IAMFC,oBAAoB,GAAG,KANrB;IAOFC,YAAY,GAAG,CAPb;IAQFC,UARE;IASFC,SATE;IAUFC,IAAI,GAAG,KAVL;IAWFC,aAXE;IAYFC,UAZE;IAaFC,aAAa,GAAG,IAbd;IAcFC,KAdE;IAeFC,UAAU,GAAG;EAfX,IAgBFjB,KAhBJ;EAkBA,MAAMM,IAAI,GAAGd,aAAa,CAACe,YAAD,EAAeK,IAAf,CAA1B;EAEA,MAAM,CAACM,mBAAD,EAAsBC,gBAAtB,IAA0C5B,sBAAsB,CAAC;IACnEkB,YADmE;IAEnEW,YAAY,EAAEd,IAAI,CAACe,MAFgD;IAGnEJ;EAHmE,CAAD,CAAtE;EAMA,MAAMK,eAAe,GAAGhC,kBAAkB,CAAC;IACvCmB,YADuC;IAEvCE,SAFuC;IAGvCS,YAAY,EAAEd,IAAI,CAACe,MAHoB;IAIvCE,oBAAoB,EAAEhB,YAAY,CAACc,MAJI;IAKvCR,aALuC;IAMvCM;EANuC,CAAD,CAA1C;EASA,MAAM;IAAEK;EAAF,IAAsBF,eAA5B;EAEA,MAAM;IACFG,mBADE;IAEFC,mBAFE;IAGFC,kBAHE;IAIFC;EAJE,IAKFnC,iBAAiB,CAAC;IAClBY,qBADkB;IAElBM,SAFkB;IAGlBW,eAHkB;IAIlBb,YAJkB;IAKlBG,IALkB;IAMlBQ,YAAY,EAAEd,IAAI,CAACe;EAND,CAAD,CALrB;EAcA,MAAMQ,kBAAkB,GAAGxC,qBAAqB,CAAC;IAC7CyC,OAAO,EAAE5B,QADoC;IAE7C6B,cAAc,EAAE5B,gBAF6B;IAG7CyB;EAH6C,CAAD,CAAhD;EAMA1C,mBAAmB,CACfe,GADe,EAEf,OAAO;IACHuB,eADG;IAEHQ,IAAI,EAAE,MAAMJ,oBAAoB,CAAC,aAAD,EAAgB;MAAEK,SAAS,EAAE;IAAb,CAAhB,CAF7B;IAGHC,IAAI,EAAE,MAAMN,oBAAoB,CAAC,aAAD,EAAgB;MAAEK,SAAS,EAAE;IAAb,CAAhB,CAH7B;IAIHE,QAAQ,EAAGC,MAAD,IAAYR,oBAAoB,CAAC,OAAD,EAAUQ,MAAV;EAJvC,CAAP,CAFe,EAQf,CAACR,oBAAD,EAAuBJ,eAAvB,CARe,CAAnB;EAWA,MAAMa,YAAY,GAAGlD,OAAO,CAAC,OAAO;IAChCiB,eADgC;IAEhCE,IAFgC;IAGhCoB,mBAHgC;IAIhChB,UAJgC;IAKhCC,SALgC;IAMhCO,mBANgC;IAOhCN;EAPgC,CAAP,CAAD,EAQxB,CACAR,eADA,EAEAE,IAFA,EAGAoB,mBAHA,EAIAhB,UAJA,EAKAC,SALA,EAMAO,mBANA,EAOAN,IAPA,CARwB,CAA5B;EAkBA,oBACI,oBAAC,eAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAEyB;EAAjC,gBACI,oBAAC,sBAAD;IACI,OAAO,EAAEnC,QAAQ,IAAI,CAACM,oBAD1B;IAEI,yBAAyB,EAAE8B,IAAI,CAACC,GAAL,CAAS,IAAT,EAAepC,gBAAf,CAF/B;IAGI,mBAAmB,EAAE,QAAiB;MAAA,IAAhB;QAAEqC;MAAF,CAAgB;;MAClC,IAAIA,OAAJ,EAAa;QACTX,kBAAkB,CAACY,MAAnB;MACH,CAFD,MAEO;QACHZ,kBAAkB,CAACa,KAAnB;MACH;IACJ;EATL,gBAWI,oBAAC,iBAAD;IACI,kBAAkB,EAAEb,kBADxB;IAEI,mBAAmB,EAAEJ,mBAFzB;IAGI,kBAAkB,EAAEE,kBAHxB;IAII,aAAa,EAAEZ,aAJnB;IAKI,oBAAoB,EAAEa;EAL1B,gBAOI,oBAAC,QAAD;IACI,IAAI,EAAEtB,IADV;IAEI,UAAU,EAAEI,UAFhB;IAGI,YAAY,EAAEH,YAHlB;IAII,UAAU,EAAEO,UAJhB;IAKI,KAAK,EAAEE;EALX,EAPJ,CAXJ,CADJ,CADJ;AA+BH,CAtH0B,CAA3B;AAwHA,4BAAe/B,IAAI,CAACc,QAAD,CAAnB"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import React, { RefObject } from 'react';\nimport type { ListRenderItemInfo } from 'react-native';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * Padding for center slide. If specified, `slidesToScroll` and `slidesToShow` set to 1.\n */\n centerSlidePadding?: number;\n\n /**\n * Delay in ms until navigating to the next item.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * Value of the opacity effect applied to inactive slides.\n * @default 0.7\n */\n inactiveSlideOpacity?: number;\n\n /**\n * Value of the 'scale' transform applied to inactive slides.\n * @default 0.9\n */\n inactiveSlideScale?: number;\n\n /**\n * Web only. Value of the 'scale' transform applied to a active slide.\n * @default 0.990\n */\n activeSlideScale?: number;\n\n /**\n * A number representing the index of the active slide.\n */\n index: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n infinite?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: (info: Omit<ListRenderItemInfo<ItemT>, 'separators'>) => React.ReactElement | null;\n\n /**\n * Web only. Number of slides to scroll at once.\n * @default 1\n */\n slidesToScroll?: number;\n\n /**\n * Web only. Number of slides to display.\n * @default 1\n */\n slidesToShow?: number;\n\n /**\n * Web only. Enable items to display at the center.\n * @default true\n */\n centerMode?: boolean;\n\n /**\n * Web only. Enable arrows to display.\n * @default true\n */\n arrows?: boolean;\n\n /**\n * Web only. Style of arrows\n * @default true\n */\n arrowsStyle?: object;\n\n /**\n * Web only. Style of track\n * @default object\n */\n trackStyle?: object;\n\n /**\n * Only web. Refer slick object\n */\n ref?: RefObject<any>;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type {\n CarouselInstance,\n CreateItemStyle,\n CreateScrollAnimation,\n ItemHeight,\n OnIndexChange,\n RenderItem,\n} from './types';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n ref?: RefObject<CarouselInstance>;\n\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * The item style creator function.\n * @default createDefaultItemStyle\n */\n createItemStyle?: CreateItemStyle;\n\n /**\n * The scroll animation creator function.\n * @default createDefaultScrollAnimation\n */\n createScrollAnimation?: CreateScrollAnimation;\n\n /**\n * Data for render items.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * If `true`, carousel will detect its own viewability and control autoplay automatically.\n * @default false\n */\n disableSmartAutoplay?: boolean;\n\n /**\n * Index of initial item that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * The item height.\n * For a performance reason, always consider to provide a number value.\n */\n itemHeight: ItemHeight;\n\n /**\n * The item width.\n */\n itemWidth: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n loop?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onIndexChange?: OnIndexChange;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: RenderItem<ItemT>;\n\n /**\n * Whether to enable scroll gesture.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * The maximum number of items that can respond to pan gesture events.\n * Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)\n * 0 means all items will respond to pan gesture events.\n * @default 5\n */\n windowSize?: number;\n}> {}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export const itemInterpolationInputRange = [-1, 0, 1];
2
+ //# sourceMappingURL=animationUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["itemInterpolationInputRange"],"sources":["animationUtils.ts"],"sourcesContent":["export const itemInterpolationInputRange = [-1, 0, 1];\n"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,GAAG,CAAC,CAAC,CAAF,EAAK,CAAL,EAAQ,CAAR,CAApC"}
@@ -0,0 +1,3 @@
1
+ import normalItemStyleFactory from './normalItemStyleFactory';
2
+ export default normalItemStyleFactory();
3
+ //# sourceMappingURL=createDefaultItemStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalItemStyleFactory"],"sources":["createDefaultItemStyle.ts"],"sourcesContent":["import normalItemStyleFactory from './normalItemStyleFactory';\n\nexport default normalItemStyleFactory();\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,0BAAnC;AAEA,eAAeA,sBAAsB,EAArC"}
@@ -0,0 +1,12 @@
1
+ import { Animated, Easing, Platform } from 'react-native';
2
+ import * as R from 'ramda';
3
+ export default function createDefaultScrollAnimation(animatedValue, toValue) {
4
+ return Animated.timing(animatedValue, {
5
+ toValue: toValue,
6
+ duration: 180,
7
+ easing: Easing.bezier(0.2, 0.2, 0.2, 1),
8
+ useNativeDriver: R.not(Platform.OS === 'android' && Platform.Version === 31)
9
+ });
10
+ }
11
+ ;
12
+ //# sourceMappingURL=createDefaultScrollAnimation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Animated","Easing","Platform","R","createDefaultScrollAnimation","animatedValue","toValue","timing","duration","easing","bezier","useNativeDriver","not","OS","Version"],"sources":["createDefaultScrollAnimation.ts"],"sourcesContent":["import { Animated, Easing, Platform } from 'react-native';\nimport * as R from 'ramda';\n\nexport default function createDefaultScrollAnimation(\n animatedValue: Animated.Value,\n toValue: number,\n): Animated.CompositeAnimation {\n return Animated.timing(animatedValue, {\n toValue: toValue,\n duration: 180,\n easing: Easing.bezier(0.2, 0.2, 0.2, 1),\n useNativeDriver: R.not(Platform.OS === 'android' && Platform.Version === 31),\n });\n};\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,MAAnB,EAA2BC,QAA3B,QAA2C,cAA3C;AACA,OAAO,KAAKC,CAAZ,MAAmB,OAAnB;AAEA,eAAe,SAASC,4BAAT,CACXC,aADW,EAEXC,OAFW,EAGgB;EAC3B,OAAON,QAAQ,CAACO,MAAT,CAAgBF,aAAhB,EAA+B;IAClCC,OAAO,EAAEA,OADyB;IAElCE,QAAQ,EAAE,GAFwB;IAGlCC,MAAM,EAAER,MAAM,CAACS,MAAP,CAAc,GAAd,EAAmB,GAAnB,EAAwB,GAAxB,EAA6B,CAA7B,CAH0B;IAIlCC,eAAe,EAAER,CAAC,CAACS,GAAF,CAAMV,QAAQ,CAACW,EAAT,KAAgB,SAAhB,IAA6BX,QAAQ,CAACY,OAAT,KAAqB,EAAxD;EAJiB,CAA/B,CAAP;AAMH;AAAA"}
@@ -0,0 +1,5 @@
1
+ export { default as createDefaultItemStyle } from './createDefaultItemStyle';
2
+ export { default as createDefaultScrollAnimation } from './createDefaultScrollAnimation';
3
+ export { default as normalItemStyleFactory } from './normalItemStyleFactory';
4
+ export { default as parallaxItemStyleFactory } from './parallaxItemStyleFactory';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","createDefaultItemStyle","createDefaultScrollAnimation","normalItemStyleFactory","parallaxItemStyleFactory"],"sources":["index.ts"],"sourcesContent":["export { default as createDefaultItemStyle } from './createDefaultItemStyle';\nexport { default as createDefaultScrollAnimation } from './createDefaultScrollAnimation';\nexport { default as normalItemStyleFactory } from './normalItemStyleFactory';\nexport { default as parallaxItemStyleFactory } from './parallaxItemStyleFactory';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,sBAApB,QAAkD,0BAAlD;AACA,SAASD,OAAO,IAAIE,4BAApB,QAAwD,gCAAxD;AACA,SAASF,OAAO,IAAIG,sBAApB,QAAkD,0BAAlD;AACA,SAASH,OAAO,IAAII,wBAApB,QAAoD,4BAApD"}
@@ -0,0 +1,18 @@
1
+ import { itemInterpolationInputRange } from './animationUtils';
2
+ export default function normalItemStyleFactory() {
3
+ const createItemStyle = (itemInterpolation, itemWidth) => {
4
+ const translate = itemInterpolation.interpolate({
5
+ inputRange: itemInterpolationInputRange,
6
+ outputRange: [-itemWidth, 0, itemWidth]
7
+ });
8
+ return {
9
+ transform: [{
10
+ translateX: translate
11
+ }]
12
+ };
13
+ };
14
+
15
+ return createItemStyle;
16
+ }
17
+ ;
18
+ //# sourceMappingURL=normalItemStyleFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["itemInterpolationInputRange","normalItemStyleFactory","createItemStyle","itemInterpolation","itemWidth","translate","interpolate","inputRange","outputRange","transform","translateX"],"sources":["normalItemStyleFactory.ts"],"sourcesContent":["import type { CreateItemStyle } from '../types';\nimport { itemInterpolationInputRange } from './animationUtils';\n\nexport default function normalItemStyleFactory() {\n const createItemStyle: CreateItemStyle = (itemInterpolation, itemWidth) => {\n const translate = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n -itemWidth,\n 0,\n itemWidth,\n ],\n });\n\n return { transform: [{ translateX: translate }] };\n };\n\n return createItemStyle;\n};\n"],"mappings":"AACA,SAASA,2BAAT,QAA4C,kBAA5C;AAEA,eAAe,SAASC,sBAAT,GAAkC;EAC7C,MAAMC,eAAgC,GAAG,CAACC,iBAAD,EAAoBC,SAApB,KAAkC;IACvE,MAAMC,SAAS,GAAGF,iBAAiB,CAACG,WAAlB,CAA8B;MAC5CC,UAAU,EAAEP,2BADgC;MAE5CQ,WAAW,EAAE,CACT,CAACJ,SADQ,EAET,CAFS,EAGTA,SAHS;IAF+B,CAA9B,CAAlB;IASA,OAAO;MAAEK,SAAS,EAAE,CAAC;QAAEC,UAAU,EAAEL;MAAd,CAAD;IAAb,CAAP;EACH,CAXD;;EAaA,OAAOH,eAAP;AACH;AAAA"}
@@ -0,0 +1,55 @@
1
+ import { itemInterpolationInputRange } from './animationUtils';
2
+ const defaultParallaxAnimationConfig = {
3
+ activeItemScale: 0.9,
4
+ activeItemOpacity: 1,
5
+ adjacentItemScale: Math.pow(0.9, 2),
6
+ adjacentItemOpacity: 0.5,
7
+ scrollingOffset: 50
8
+ };
9
+ export default function parallaxItemStyleFactory() {
10
+ let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultParallaxAnimationConfig;
11
+ const {
12
+ activeItemOpacity,
13
+ activeItemScale,
14
+ adjacentItemOpacity,
15
+ adjacentItemScale,
16
+ scrollingOffset
17
+ } = { ...defaultParallaxAnimationConfig,
18
+ ...config
19
+ };
20
+
21
+ const createItemStyle = (itemInterpolation, itemWidth) => {
22
+ const translate = itemInterpolation.interpolate({
23
+ inputRange: itemInterpolationInputRange,
24
+ outputRange: [-itemWidth + scrollingOffset, 0, itemWidth - scrollingOffset]
25
+ });
26
+ const zIndex = itemInterpolation.interpolate({
27
+ inputRange: itemInterpolationInputRange,
28
+ outputRange: [0, itemWidth, 0],
29
+ extrapolate: 'clamp'
30
+ });
31
+ const scale = itemInterpolation.interpolate({
32
+ inputRange: itemInterpolationInputRange,
33
+ outputRange: [adjacentItemScale, activeItemScale, adjacentItemScale],
34
+ extrapolate: 'clamp'
35
+ });
36
+ const opacity = itemInterpolation.interpolate({
37
+ inputRange: itemInterpolationInputRange,
38
+ outputRange: [adjacentItemOpacity, activeItemOpacity, adjacentItemOpacity],
39
+ extrapolate: 'clamp'
40
+ });
41
+ return {
42
+ transform: [{
43
+ translateX: translate
44
+ }, {
45
+ scale
46
+ }],
47
+ zIndex,
48
+ opacity
49
+ };
50
+ };
51
+
52
+ return createItemStyle;
53
+ }
54
+ ;
55
+ //# sourceMappingURL=parallaxItemStyleFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["itemInterpolationInputRange","defaultParallaxAnimationConfig","activeItemScale","activeItemOpacity","adjacentItemScale","Math","pow","adjacentItemOpacity","scrollingOffset","parallaxItemStyleFactory","config","createItemStyle","itemInterpolation","itemWidth","translate","interpolate","inputRange","outputRange","zIndex","extrapolate","scale","opacity","transform","translateX"],"sources":["parallaxItemStyleFactory.ts"],"sourcesContent":["import type { CreateItemStyle } from '../types';\nimport { itemInterpolationInputRange } from './animationUtils';\n\nexport interface ParallaxAnimationConfig {\n activeItemScale?: number;\n activeItemOpacity?: number;\n adjacentItemScale?: number;\n adjacentItemOpacity?: number;\n scrollingOffset?: number;\n}\n\nconst defaultParallaxAnimationConfig: Required<Readonly<ParallaxAnimationConfig>> = {\n activeItemScale: 0.9,\n activeItemOpacity: 1,\n adjacentItemScale: Math.pow(0.9, 2),\n adjacentItemOpacity: 0.5,\n scrollingOffset: 50,\n};\n\nexport default function parallaxItemStyleFactory(config: ParallaxAnimationConfig = defaultParallaxAnimationConfig) {\n const {\n activeItemOpacity,\n activeItemScale,\n adjacentItemOpacity,\n adjacentItemScale,\n scrollingOffset,\n }: Required<ParallaxAnimationConfig> = {\n ...defaultParallaxAnimationConfig,\n ...config,\n };\n\n const createItemStyle: CreateItemStyle = (itemInterpolation, itemWidth) => {\n const translate = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n -itemWidth + scrollingOffset,\n 0,\n itemWidth - scrollingOffset,\n ],\n });\n\n const zIndex = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [0, itemWidth, 0],\n extrapolate: 'clamp',\n });\n\n const scale = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n adjacentItemScale,\n activeItemScale,\n adjacentItemScale,\n ],\n extrapolate: 'clamp',\n });\n\n const opacity = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n adjacentItemOpacity,\n activeItemOpacity,\n adjacentItemOpacity,\n ],\n extrapolate: 'clamp',\n });\n\n return {\n transform: [\n { translateX: translate },\n { scale },\n ],\n zIndex,\n opacity,\n };\n };\n\n return createItemStyle;\n};\n"],"mappings":"AACA,SAASA,2BAAT,QAA4C,kBAA5C;AAUA,MAAMC,8BAA2E,GAAG;EAChFC,eAAe,EAAE,GAD+D;EAEhFC,iBAAiB,EAAE,CAF6D;EAGhFC,iBAAiB,EAAEC,IAAI,CAACC,GAAL,CAAS,GAAT,EAAc,CAAd,CAH6D;EAIhFC,mBAAmB,EAAE,GAJ2D;EAKhFC,eAAe,EAAE;AAL+D,CAApF;AAQA,eAAe,SAASC,wBAAT,GAAoG;EAAA,IAAlEC,MAAkE,uEAAhCT,8BAAgC;EAC/G,MAAM;IACFE,iBADE;IAEFD,eAFE;IAGFK,mBAHE;IAIFH,iBAJE;IAKFI;EALE,IAMiC,EACnC,GAAGP,8BADgC;IAEnC,GAAGS;EAFgC,CANvC;;EAWA,MAAMC,eAAgC,GAAG,CAACC,iBAAD,EAAoBC,SAApB,KAAkC;IACvE,MAAMC,SAAS,GAAGF,iBAAiB,CAACG,WAAlB,CAA8B;MAC5CC,UAAU,EAAEhB,2BADgC;MAE5CiB,WAAW,EAAE,CACT,CAACJ,SAAD,GAAaL,eADJ,EAET,CAFS,EAGTK,SAAS,GAAGL,eAHH;IAF+B,CAA9B,CAAlB;IASA,MAAMU,MAAM,GAAGN,iBAAiB,CAACG,WAAlB,CAA8B;MACzCC,UAAU,EAAEhB,2BAD6B;MAEzCiB,WAAW,EAAE,CAAC,CAAD,EAAIJ,SAAJ,EAAe,CAAf,CAF4B;MAGzCM,WAAW,EAAE;IAH4B,CAA9B,CAAf;IAMA,MAAMC,KAAK,GAAGR,iBAAiB,CAACG,WAAlB,CAA8B;MACxCC,UAAU,EAAEhB,2BAD4B;MAExCiB,WAAW,EAAE,CACTb,iBADS,EAETF,eAFS,EAGTE,iBAHS,CAF2B;MAOxCe,WAAW,EAAE;IAP2B,CAA9B,CAAd;IAUA,MAAME,OAAO,GAAGT,iBAAiB,CAACG,WAAlB,CAA8B;MAC1CC,UAAU,EAAEhB,2BAD8B;MAE1CiB,WAAW,EAAE,CACTV,mBADS,EAETJ,iBAFS,EAGTI,mBAHS,CAF6B;MAO1CY,WAAW,EAAE;IAP6B,CAA9B,CAAhB;IAUA,OAAO;MACHG,SAAS,EAAE,CACP;QAAEC,UAAU,EAAET;MAAd,CADO,EAEP;QAAEM;MAAF,CAFO,CADR;MAKHF,MALG;MAMHG;IANG,CAAP;EAQH,CA5CD;;EA8CA,OAAOV,eAAP;AACH;AAAA"}
@@ -0,0 +1,19 @@
1
+ import { createContext } from 'react';
2
+ import { Animated } from 'react-native';
3
+ const mockItemVisibilityStore = {
4
+ dispatch: () => void 0,
5
+ subscribe: () => () => void 0,
6
+ removeAllListeners: () => void 0
7
+ };
8
+ const initialValue = {
9
+ createItemStyle: () => ({}),
10
+ data: [],
11
+ globalInterpolation: Animated.add(new Animated.Value(0), 0),
12
+ itemHeight: 0,
13
+ itemWidth: 0,
14
+ itemVisibilityStore: mockItemVisibilityStore,
15
+ loop: false
16
+ };
17
+ const InternalContext = /*#__PURE__*/createContext(initialValue);
18
+ export default InternalContext;
19
+ //# sourceMappingURL=InternalContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","Animated","mockItemVisibilityStore","dispatch","subscribe","removeAllListeners","initialValue","createItemStyle","data","globalInterpolation","add","Value","itemHeight","itemWidth","itemVisibilityStore","loop","InternalContext"],"sources":["InternalContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\nimport type { CreateItemStyle, ItemHeight, ItemVisibilityStore } from '../types';\n\nexport interface InternalContextValue<ItemT> {\n createItemStyle: CreateItemStyle;\n data: ReadonlyArray<ItemT>;\n globalInterpolation: Animated.AnimatedInterpolation;\n itemHeight: ItemHeight;\n itemWidth: number;\n itemVisibilityStore: ItemVisibilityStore;\n loop: boolean;\n}\n\nconst mockItemVisibilityStore: ItemVisibilityStore = {\n dispatch: () => void 0,\n subscribe: () => () => void 0,\n removeAllListeners: () => void 0,\n};\n\nconst initialValue: Readonly<InternalContextValue<any>> = {\n createItemStyle: () => ({}),\n data: [],\n globalInterpolation: Animated.add(new Animated.Value(0), 0),\n itemHeight: 0,\n itemWidth: 0,\n itemVisibilityStore: mockItemVisibilityStore,\n loop: false,\n};\n\nconst InternalContext = createContext<InternalContextValue<any>>(initialValue);\n\nexport default InternalContext;\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAaA,MAAMC,uBAA4C,GAAG;EACjDC,QAAQ,EAAE,MAAM,KAAK,CAD4B;EAEjDC,SAAS,EAAE,MAAM,MAAM,KAAK,CAFqB;EAGjDC,kBAAkB,EAAE,MAAM,KAAK;AAHkB,CAArD;AAMA,MAAMC,YAAiD,GAAG;EACtDC,eAAe,EAAE,OAAO,EAAP,CADqC;EAEtDC,IAAI,EAAE,EAFgD;EAGtDC,mBAAmB,EAAER,QAAQ,CAACS,GAAT,CAAa,IAAIT,QAAQ,CAACU,KAAb,CAAmB,CAAnB,CAAb,EAAoC,CAApC,CAHiC;EAItDC,UAAU,EAAE,CAJ0C;EAKtDC,SAAS,EAAE,CAL2C;EAMtDC,mBAAmB,EAAEZ,uBANiC;EAOtDa,IAAI,EAAE;AAPgD,CAA1D;AAUA,MAAMC,eAAe,gBAAGhB,aAAa,CAA4BM,YAA5B,CAArC;AAEA,eAAeU,eAAf"}
@@ -0,0 +1,46 @@
1
+ import React, { useContext, useEffect, useMemo, useState } from 'react';
2
+ import { Animated } from 'react-native';
3
+ import { StyleSheet } from '@fountain-ui/core';
4
+ import useItemInterpolation from './useItemInterpolation';
5
+ import InternalContext from './InternalContext';
6
+ export default function ItemView(props) {
7
+ const {
8
+ children,
9
+ index,
10
+ onLayout
11
+ } = props;
12
+ const {
13
+ createItemStyle,
14
+ itemHeight,
15
+ itemWidth,
16
+ itemVisibilityStore
17
+ } = useContext(InternalContext);
18
+ const [visible, setVisible] = useState(false);
19
+ const interpolation = useItemInterpolation(index);
20
+ const itemStyle = useMemo(() => createItemStyle(interpolation, itemWidth), [createItemStyle, interpolation, itemWidth]);
21
+ useEffect(() => {
22
+ return itemVisibilityStore.subscribe(ranges => {
23
+ const nextVisible = ranges.some(_ref => {
24
+ let [from, to] = _ref;
25
+ return index >= from && index <= to;
26
+ });
27
+ setVisible(nextVisible);
28
+ });
29
+ }, [index, itemVisibilityStore]);
30
+ return /*#__PURE__*/React.createElement(Animated.View, {
31
+ children: visible ? children(interpolation) : null,
32
+ onLayout: onLayout,
33
+ style: [{
34
+ width: itemWidth,
35
+ height: itemHeight !== 'auto' ? itemHeight : undefined
36
+ }, styles.absolute, // @ts-ignore
37
+ itemStyle]
38
+ });
39
+ }
40
+ ;
41
+ const styles = StyleSheet.create({
42
+ absolute: {
43
+ position: 'absolute'
44
+ }
45
+ });
46
+ //# sourceMappingURL=ItemView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useContext","useEffect","useMemo","useState","Animated","StyleSheet","useItemInterpolation","InternalContext","ItemView","props","children","index","onLayout","createItemStyle","itemHeight","itemWidth","itemVisibilityStore","visible","setVisible","interpolation","itemStyle","subscribe","ranges","nextVisible","some","from","to","width","height","undefined","styles","absolute","create","position"],"sources":["ItemView.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport useItemInterpolation from './useItemInterpolation';\nimport InternalContext from './InternalContext';\n\nexport interface ItemViewProps {\n children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;\n index: number;\n onLayout?: ViewProps['onLayout'];\n}\n\nexport default function ItemView(props: ItemViewProps) {\n const {\n children,\n index,\n onLayout,\n } = props;\n\n const {\n createItemStyle,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n } = useContext(InternalContext);\n\n const [visible, setVisible] = useState(false);\n\n const interpolation = useItemInterpolation(index);\n\n const itemStyle = useMemo(\n () => createItemStyle(interpolation, itemWidth),\n [createItemStyle, interpolation, itemWidth],\n );\n\n useEffect(() => {\n return itemVisibilityStore.subscribe(ranges => {\n const nextVisible = ranges.some(([from, to]) => index >= from && index <= to);\n setVisible(nextVisible);\n });\n }, [index, itemVisibilityStore]);\n\n return (\n <Animated.View\n children={visible ? children(interpolation) : null}\n onLayout={onLayout}\n style={[\n {\n width: itemWidth,\n height: itemHeight !== 'auto' ? itemHeight : undefined,\n },\n styles.absolute,\n // @ts-ignore\n itemStyle,\n ]}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: 'absolute',\n },\n});\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,SAA5B,EAAuCC,OAAvC,EAAgDC,QAAhD,QAAgE,OAAhE;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAQA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;EACnD,MAAM;IACFC,QADE;IAEFC,KAFE;IAGFC;EAHE,IAIFH,KAJJ;EAMA,MAAM;IACFI,eADE;IAEFC,UAFE;IAGFC,SAHE;IAIFC;EAJE,IAKFhB,UAAU,CAACO,eAAD,CALd;EAOA,MAAM,CAACU,OAAD,EAAUC,UAAV,IAAwBf,QAAQ,CAAC,KAAD,CAAtC;EAEA,MAAMgB,aAAa,GAAGb,oBAAoB,CAACK,KAAD,CAA1C;EAEA,MAAMS,SAAS,GAAGlB,OAAO,CACrB,MAAMW,eAAe,CAACM,aAAD,EAAgBJ,SAAhB,CADA,EAErB,CAACF,eAAD,EAAkBM,aAAlB,EAAiCJ,SAAjC,CAFqB,CAAzB;EAKAd,SAAS,CAAC,MAAM;IACZ,OAAOe,mBAAmB,CAACK,SAApB,CAA8BC,MAAM,IAAI;MAC3C,MAAMC,WAAW,GAAGD,MAAM,CAACE,IAAP,CAAY;QAAA,IAAC,CAACC,IAAD,EAAOC,EAAP,CAAD;QAAA,OAAgBf,KAAK,IAAIc,IAAT,IAAiBd,KAAK,IAAIe,EAA1C;MAAA,CAAZ,CAApB;MACAR,UAAU,CAACK,WAAD,CAAV;IACH,CAHM,CAAP;EAIH,CALQ,EAKN,CAACZ,KAAD,EAAQK,mBAAR,CALM,CAAT;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,QAAQ,EAAEC,OAAO,GAAGP,QAAQ,CAACS,aAAD,CAAX,GAA6B,IADlD;IAEI,QAAQ,EAAEP,QAFd;IAGI,KAAK,EAAE,CACH;MACIe,KAAK,EAAEZ,SADX;MAEIa,MAAM,EAAEd,UAAU,KAAK,MAAf,GAAwBA,UAAxB,GAAqCe;IAFjD,CADG,EAKHC,MAAM,CAACC,QALJ,EAMH;IACAX,SAPG;EAHX,EADJ;AAeH;AAAA;AAED,MAAMU,MAAM,GAAGzB,UAAU,CAAC2B,MAAX,CAAkB;EAC7BD,QAAQ,EAAE;IACNE,QAAQ,EAAE;EADJ;AADmB,CAAlB,CAAf"}
@@ -0,0 +1,65 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React, { forwardRef, memo, useState } from 'react';
4
+ import { Animated } from 'react-native';
5
+ import { StyleSheet } from '@fountain-ui/core';
6
+ import ItemView from './ItemView';
7
+ const styles = StyleSheet.create({
8
+ root: {
9
+ width: '100%',
10
+ justifyContent: 'center'
11
+ },
12
+ horizontal: {
13
+ flexDirection: 'row',
14
+ overflowX: 'hidden',
15
+ overflowY: 'visible'
16
+ }
17
+ });
18
+ const RootView = /*#__PURE__*/forwardRef(function RootView(props, ref) {
19
+ const {
20
+ data,
21
+ itemHeight,
22
+ originalData,
23
+ renderItem,
24
+ style,
25
+ ...otherProps
26
+ } = props;
27
+ const [maxHeightOfRenderedItems, setMaxHeightOfRenderedItems] = useState(0);
28
+
29
+ const handleItemLayout = e => {
30
+ const {
31
+ nativeEvent: {
32
+ layout: {
33
+ height
34
+ }
35
+ }
36
+ } = e;
37
+ const heightInt = Math.round(height);
38
+
39
+ if (heightInt > maxHeightOfRenderedItems) {
40
+ setMaxHeightOfRenderedItems(heightInt);
41
+ }
42
+ };
43
+
44
+ const renderItemView = (item, index) => /*#__PURE__*/React.createElement(ItemView, {
45
+ key: index,
46
+ index: index,
47
+ onLayout: itemHeight === 'auto' ? handleItemLayout : undefined
48
+ }, interpolation => renderItem({
49
+ item,
50
+ index: index % originalData.length,
51
+ interpolation
52
+ }));
53
+
54
+ const viewStyles = [styles.root, styles.horizontal, {
55
+ height: itemHeight === 'auto' ? maxHeightOfRenderedItems : itemHeight
56
+ }, style];
57
+ return /*#__PURE__*/React.createElement(Animated.View, _extends({
58
+ ref: ref
59
+ }, otherProps, {
60
+ children: data.map(renderItemView),
61
+ style: viewStyles
62
+ }));
63
+ });
64
+ export default /*#__PURE__*/memo(RootView);
65
+ //# sourceMappingURL=RootView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","memo","useState","Animated","StyleSheet","ItemView","styles","create","root","width","justifyContent","horizontal","flexDirection","overflowX","overflowY","RootView","props","ref","data","itemHeight","originalData","renderItem","style","otherProps","maxHeightOfRenderedItems","setMaxHeightOfRenderedItems","handleItemLayout","e","nativeEvent","layout","height","heightInt","Math","round","renderItemView","item","index","undefined","interpolation","length","viewStyles","map"],"sources":["RootView.tsx"],"sourcesContent":["import React, { forwardRef, memo, ReactElement, useState } from 'react';\nimport type { View, ViewProps, LayoutChangeEvent } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type { ItemHeight, RenderItem } from '../types';\nimport ItemView from './ItemView';\n\nconst styles = StyleSheet.create({\n root: {\n width: '100%',\n justifyContent: 'center',\n },\n horizontal: {\n flexDirection: 'row',\n overflowX: 'hidden',\n overflowY: 'visible',\n },\n});\n\nexport type RootViewProps<ItemT> = ViewProps & {\n data: ReadonlyArray<ItemT>;\n itemHeight: ItemHeight;\n originalData: ReadonlyArray<ItemT>;\n renderItem: RenderItem<ItemT>;\n};\n\nconst RootView = forwardRef<View, RootViewProps<any>>(function RootView(props, ref) {\n const {\n data,\n itemHeight,\n originalData,\n renderItem,\n style,\n ...otherProps\n } = props;\n\n const [maxHeightOfRenderedItems, setMaxHeightOfRenderedItems] = useState(0);\n\n const handleItemLayout = (e: LayoutChangeEvent) => {\n const { nativeEvent: { layout: { height } } } = e;\n\n const heightInt = Math.round(height);\n if (heightInt > maxHeightOfRenderedItems) {\n setMaxHeightOfRenderedItems(heightInt);\n }\n };\n\n const renderItemView = (item: any, index: number): ReactElement => (\n <ItemView\n key={index}\n index={index}\n onLayout={itemHeight === 'auto' ? handleItemLayout : undefined}\n >\n {(interpolation) => renderItem({\n item,\n index: index % originalData.length,\n interpolation,\n })}\n </ItemView>\n );\n\n const viewStyles = [\n styles.root,\n styles.horizontal,\n { height: itemHeight === 'auto' ? maxHeightOfRenderedItems : itemHeight },\n style,\n ];\n\n return (\n <Animated.View\n ref={ref}\n {...otherProps}\n children={data.map(renderItemView)}\n style={viewStyles}\n />\n );\n});\n\nexport default memo(RootView);\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,IAA5B,EAAgDC,QAAhD,QAAgE,OAAhE;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA,OAAOC,QAAP,MAAqB,YAArB;AAEA,MAAMC,MAAM,GAAGF,UAAU,CAACG,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,KAAK,EAAE,MADL;IAEFC,cAAc,EAAE;EAFd,CADuB;EAK7BC,UAAU,EAAE;IACRC,aAAa,EAAE,KADP;IAERC,SAAS,EAAE,QAFH;IAGRC,SAAS,EAAE;EAHH;AALiB,CAAlB,CAAf;AAmBA,MAAMC,QAAQ,gBAAGf,UAAU,CAA2B,SAASe,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EAChF,MAAM;IACFC,IADE;IAEFC,UAFE;IAGFC,YAHE;IAIFC,UAJE;IAKFC,KALE;IAMF,GAAGC;EAND,IAOFP,KAPJ;EASA,MAAM,CAACQ,wBAAD,EAA2BC,2BAA3B,IAA0DvB,QAAQ,CAAC,CAAD,CAAxE;;EAEA,MAAMwB,gBAAgB,GAAIC,CAAD,IAA0B;IAC/C,MAAM;MAAEC,WAAW,EAAE;QAAEC,MAAM,EAAE;UAAEC;QAAF;MAAV;IAAf,IAA0CH,CAAhD;IAEA,MAAMI,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,MAAX,CAAlB;;IACA,IAAIC,SAAS,GAAGP,wBAAhB,EAA0C;MACtCC,2BAA2B,CAACM,SAAD,CAA3B;IACH;EACJ,CAPD;;EASA,MAAMG,cAAc,GAAG,CAACC,IAAD,EAAYC,KAAZ,kBACnB,oBAAC,QAAD;IACI,GAAG,EAAEA,KADT;IAEI,KAAK,EAAEA,KAFX;IAGI,QAAQ,EAAEjB,UAAU,KAAK,MAAf,GAAwBO,gBAAxB,GAA2CW;EAHzD,GAKMC,aAAD,IAAmBjB,UAAU,CAAC;IAC3Bc,IAD2B;IAE3BC,KAAK,EAAEA,KAAK,GAAGhB,YAAY,CAACmB,MAFD;IAG3BD;EAH2B,CAAD,CALlC,CADJ;;EAcA,MAAME,UAAU,GAAG,CACflC,MAAM,CAACE,IADQ,EAEfF,MAAM,CAACK,UAFQ,EAGf;IAAEmB,MAAM,EAAEX,UAAU,KAAK,MAAf,GAAwBK,wBAAxB,GAAmDL;EAA7D,CAHe,EAIfG,KAJe,CAAnB;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,GAAG,EAAEL;EADT,GAEQM,UAFR;IAGI,QAAQ,EAAEL,IAAI,CAACuB,GAAL,CAASP,cAAT,CAHd;IAII,KAAK,EAAEM;EAJX,GADJ;AAQH,CAlD0B,CAA3B;AAoDA,4BAAevC,IAAI,CAACc,QAAD,CAAnB"}
@@ -0,0 +1,69 @@
1
+ import React, { useCallback } from 'react';
2
+ import { Animated, Platform } from 'react-native';
3
+ import { PanGestureHandler, State as GestureHandlerState } from 'react-native-gesture-handler';
4
+ import * as R from 'ramda';
5
+ const SCROLL_TO_ADJACENT_TX_THRESHOLD = 80;
6
+ const SCROLL_TO_ADJACENT_VX_THRESHOLD = 1000;
7
+ const ACTIVE_OFFSET_ABS_X = 5;
8
+ const activeOffsetX = [-ACTIVE_OFFSET_ABS_X, ACTIVE_OFFSET_ABS_X];
9
+ const endAnimationStates = [GestureHandlerState.CANCELLED, GestureHandlerState.END, GestureHandlerState.FAILED];
10
+
11
+ function shouldScrollToAdjacent(translationX, velocityX) {
12
+ const isSameDirection = translationX * velocityX > 0;
13
+ const isEnoughMovement = Math.abs(translationX) >= SCROLL_TO_ADJACENT_TX_THRESHOLD || Math.abs(velocityX) >= SCROLL_TO_ADJACENT_VX_THRESHOLD;
14
+ return isSameDirection && isEnoughMovement;
15
+ }
16
+
17
+ export default function ScrollViewGesture(props) {
18
+ const {
19
+ autoplayController,
20
+ children,
21
+ interruptAnimation,
22
+ gestureTranslationX,
23
+ scrollEnabled,
24
+ startPagingAnimation
25
+ } = props;
26
+ const {
27
+ pause: pauseAutoplay,
28
+ resume: resumeAutoplay
29
+ } = autoplayController;
30
+ const handleGestureBegin = useCallback(() => {
31
+ pauseAutoplay();
32
+ interruptAnimation();
33
+ }, [interruptAnimation, pauseAutoplay]);
34
+ const handleGestureEvent = useCallback(Animated.event([{
35
+ nativeEvent: {
36
+ translationX: gestureTranslationX
37
+ }
38
+ }], {
39
+ useNativeDriver: R.not(Platform.OS === 'android' && Platform.Version === 31)
40
+ }), []);
41
+ const handleHandlerStateChange = useCallback(event => {
42
+ const {
43
+ nativeEvent: {
44
+ translationX,
45
+ velocityX,
46
+ state
47
+ }
48
+ } = event;
49
+
50
+ if (endAnimationStates.includes(state)) {
51
+ const direction = shouldScrollToAdjacent(translationX, velocityX) ? translationX < 0 ? 'next' : 'prev' : 'stay';
52
+ startPagingAnimation('directional', {
53
+ direction: direction,
54
+ isOriginatedFromGesture: true,
55
+ lastGestureTranslationX: translationX
56
+ });
57
+ resumeAutoplay();
58
+ }
59
+ }, [startPagingAnimation, resumeAutoplay]);
60
+ return /*#__PURE__*/React.createElement(PanGestureHandler, {
61
+ activeOffsetX: activeOffsetX,
62
+ children: children,
63
+ enabled: scrollEnabled,
64
+ onBegan: handleGestureBegin,
65
+ onGestureEvent: handleGestureEvent,
66
+ onHandlerStateChange: handleHandlerStateChange
67
+ });
68
+ }
69
+ //# sourceMappingURL=ScrollViewGesture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","Animated","Platform","PanGestureHandler","State","GestureHandlerState","R","SCROLL_TO_ADJACENT_TX_THRESHOLD","SCROLL_TO_ADJACENT_VX_THRESHOLD","ACTIVE_OFFSET_ABS_X","activeOffsetX","endAnimationStates","CANCELLED","END","FAILED","shouldScrollToAdjacent","translationX","velocityX","isSameDirection","isEnoughMovement","Math","abs","ScrollViewGesture","props","autoplayController","children","interruptAnimation","gestureTranslationX","scrollEnabled","startPagingAnimation","pause","pauseAutoplay","resume","resumeAutoplay","handleGestureBegin","handleGestureEvent","event","nativeEvent","useNativeDriver","not","OS","Version","handleHandlerStateChange","state","includes","direction","isOriginatedFromGesture","lastGestureTranslationX"],"sources":["ScrollViewGesture.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport React, { useCallback } from 'react';\nimport { Animated, Platform } from 'react-native';\nimport type { PanGestureHandlerStateChangeEvent } from 'react-native-gesture-handler';\nimport { PanGestureHandler, State as GestureHandlerState } from 'react-native-gesture-handler';\nimport * as R from 'ramda';\nimport type { AutoplayController, PagingDirection, StartPagingAnimation } from '../types';\n\nexport interface ScrollViewGestureProps {\n autoplayController: AutoplayController;\n children: ReactNode;\n gestureTranslationX: Animated.Value,\n interruptAnimation: () => void;\n scrollEnabled: boolean;\n startPagingAnimation: StartPagingAnimation;\n}\n\nconst SCROLL_TO_ADJACENT_TX_THRESHOLD = 80;\nconst SCROLL_TO_ADJACENT_VX_THRESHOLD = 1000;\n\nconst ACTIVE_OFFSET_ABS_X = 5;\nconst activeOffsetX: number[] = [-ACTIVE_OFFSET_ABS_X, ACTIVE_OFFSET_ABS_X];\n\nconst endAnimationStates: Readonly<GestureHandlerState[]> = [\n GestureHandlerState.CANCELLED,\n GestureHandlerState.END,\n GestureHandlerState.FAILED,\n];\n\nfunction shouldScrollToAdjacent(translationX: number, velocityX: number): boolean {\n const isSameDirection = translationX * velocityX > 0;\n const isEnoughMovement =\n Math.abs(translationX) >= SCROLL_TO_ADJACENT_TX_THRESHOLD\n || Math.abs(velocityX) >= SCROLL_TO_ADJACENT_VX_THRESHOLD;\n\n return isSameDirection && isEnoughMovement;\n}\n\nexport default function ScrollViewGesture(props: ScrollViewGestureProps) {\n const {\n autoplayController,\n children,\n interruptAnimation,\n gestureTranslationX,\n scrollEnabled,\n startPagingAnimation,\n } = props;\n\n const { pause: pauseAutoplay, resume: resumeAutoplay } = autoplayController;\n\n const handleGestureBegin = useCallback(() => {\n pauseAutoplay();\n\n interruptAnimation();\n }, [interruptAnimation, pauseAutoplay]);\n\n const handleGestureEvent = useCallback(Animated.event(\n [{ nativeEvent: { translationX: gestureTranslationX } }],\n { useNativeDriver: R.not(Platform.OS === 'android' && Platform.Version === 31) },\n ), []);\n\n const handleHandlerStateChange = useCallback((event: PanGestureHandlerStateChangeEvent) => {\n const { nativeEvent: { translationX, velocityX, state } } = event;\n\n if (endAnimationStates.includes(state)) {\n const direction: PagingDirection = shouldScrollToAdjacent(translationX, velocityX)\n ? (translationX < 0 ? 'next' : 'prev')\n : 'stay';\n\n startPagingAnimation(\n 'directional',\n {\n direction: direction,\n isOriginatedFromGesture: true,\n lastGestureTranslationX: translationX,\n },\n );\n\n resumeAutoplay();\n }\n }, [startPagingAnimation, resumeAutoplay]);\n\n return (\n <PanGestureHandler\n activeOffsetX={activeOffsetX}\n children={children}\n enabled={scrollEnabled}\n onBegan={handleGestureBegin}\n onGestureEvent={handleGestureEvent}\n onHandlerStateChange={handleHandlerStateChange}\n />\n );\n}\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,cAAnC;AAEA,SAASC,iBAAT,EAA4BC,KAAK,IAAIC,mBAArC,QAAgE,8BAAhE;AACA,OAAO,KAAKC,CAAZ,MAAmB,OAAnB;AAYA,MAAMC,+BAA+B,GAAG,EAAxC;AACA,MAAMC,+BAA+B,GAAG,IAAxC;AAEA,MAAMC,mBAAmB,GAAG,CAA5B;AACA,MAAMC,aAAuB,GAAG,CAAC,CAACD,mBAAF,EAAuBA,mBAAvB,CAAhC;AAEA,MAAME,kBAAmD,GAAG,CACxDN,mBAAmB,CAACO,SADoC,EAExDP,mBAAmB,CAACQ,GAFoC,EAGxDR,mBAAmB,CAACS,MAHoC,CAA5D;;AAMA,SAASC,sBAAT,CAAgCC,YAAhC,EAAsDC,SAAtD,EAAkF;EAC9E,MAAMC,eAAe,GAAGF,YAAY,GAAGC,SAAf,GAA2B,CAAnD;EACA,MAAME,gBAAgB,GAClBC,IAAI,CAACC,GAAL,CAASL,YAAT,KAA0BT,+BAA1B,IACGa,IAAI,CAACC,GAAL,CAASJ,SAAT,KAAuBT,+BAF9B;EAIA,OAAOU,eAAe,IAAIC,gBAA1B;AACH;;AAED,eAAe,SAASG,iBAAT,CAA2BC,KAA3B,EAA0D;EACrE,MAAM;IACFC,kBADE;IAEFC,QAFE;IAGFC,kBAHE;IAIFC,mBAJE;IAKFC,aALE;IAMFC;EANE,IAOFN,KAPJ;EASA,MAAM;IAAEO,KAAK,EAAEC,aAAT;IAAwBC,MAAM,EAAEC;EAAhC,IAAmDT,kBAAzD;EAEA,MAAMU,kBAAkB,GAAGlC,WAAW,CAAC,MAAM;IACzC+B,aAAa;IAEbL,kBAAkB;EACrB,CAJqC,EAInC,CAACA,kBAAD,EAAqBK,aAArB,CAJmC,CAAtC;EAMA,MAAMI,kBAAkB,GAAGnC,WAAW,CAACC,QAAQ,CAACmC,KAAT,CACnC,CAAC;IAAEC,WAAW,EAAE;MAAErB,YAAY,EAAEW;IAAhB;EAAf,CAAD,CADmC,EAEnC;IAAEW,eAAe,EAAEhC,CAAC,CAACiC,GAAF,CAAMrC,QAAQ,CAACsC,EAAT,KAAgB,SAAhB,IAA6BtC,QAAQ,CAACuC,OAAT,KAAqB,EAAxD;EAAnB,CAFmC,CAAD,EAGnC,EAHmC,CAAtC;EAKA,MAAMC,wBAAwB,GAAG1C,WAAW,CAAEoC,KAAD,IAA8C;IACvF,MAAM;MAAEC,WAAW,EAAE;QAAErB,YAAF;QAAgBC,SAAhB;QAA2B0B;MAA3B;IAAf,IAAsDP,KAA5D;;IAEA,IAAIzB,kBAAkB,CAACiC,QAAnB,CAA4BD,KAA5B,CAAJ,EAAwC;MACpC,MAAME,SAA0B,GAAG9B,sBAAsB,CAACC,YAAD,EAAeC,SAAf,CAAtB,GAC5BD,YAAY,GAAG,CAAf,GAAmB,MAAnB,GAA4B,MADA,GAE7B,MAFN;MAIAa,oBAAoB,CAChB,aADgB,EAEhB;QACIgB,SAAS,EAAEA,SADf;QAEIC,uBAAuB,EAAE,IAF7B;QAGIC,uBAAuB,EAAE/B;MAH7B,CAFgB,CAApB;MASAiB,cAAc;IACjB;EACJ,CAnB2C,EAmBzC,CAACJ,oBAAD,EAAuBI,cAAvB,CAnByC,CAA5C;EAqBA,oBACI,oBAAC,iBAAD;IACI,aAAa,EAAEvB,aADnB;IAEI,QAAQ,EAAEe,QAFd;IAGI,OAAO,EAAEG,aAHb;IAII,OAAO,EAAEM,kBAJb;IAKI,cAAc,EAAEC,kBALpB;IAMI,oBAAoB,EAAEO;EAN1B,EADJ;AAUH"}
@@ -0,0 +1,5 @@
1
+ export { default as InternalContext } from './InternalContext';
2
+ export { default as ItemView } from './ItemView';
3
+ export { default as RootView } from './RootView';
4
+ export { default as ScrollViewGesture } from './ScrollViewGesture';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","InternalContext","ItemView","RootView","ScrollViewGesture"],"sources":["index.ts"],"sourcesContent":["export { default as InternalContext } from './InternalContext';\nexport { default as ItemView } from './ItemView';\nexport { default as RootView } from './RootView';\nexport { default as ScrollViewGesture } from './ScrollViewGesture';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,eAApB,QAA2C,mBAA3C;AACA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,SAASF,OAAO,IAAIG,QAApB,QAAoC,YAApC;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,qBAA7C"}