@fountain-ui/lab 2.0.0-beta.6 → 2.0.0-beta.61

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 (520) hide show
  1. package/build/commonjs/AnimatedY/AnimatedY.js +10 -14
  2. package/build/commonjs/AnimatedY/AnimatedY.js.map +1 -1
  3. package/build/commonjs/AnimatedY/AnimatedYProps.js.map +1 -1
  4. package/build/commonjs/AnimatedY/index.js.map +1 -1
  5. package/build/commonjs/BottomSheet/BottomSheetNative.js +33 -8
  6. package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
  7. package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
  8. package/build/commonjs/BottomSheet/BottomSheetWeb.js +30 -16
  9. package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
  10. package/build/commonjs/BottomSheet/TransparentBackdrop.js +1 -1
  11. package/build/commonjs/BottomSheet/TransparentBackdrop.js.map +1 -1
  12. package/build/commonjs/BottomSheet/index.js.map +1 -1
  13. package/build/commonjs/BottomSheet/index.native.js.map +1 -1
  14. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js +65 -0
  15. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js.map +1 -0
  16. package/build/commonjs/Carousel/Carousel.js +130 -0
  17. package/build/commonjs/Carousel/Carousel.js.map +1 -0
  18. package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
  19. package/build/commonjs/Carousel/animation/animationUtils.js +9 -0
  20. package/build/commonjs/Carousel/animation/animationUtils.js.map +1 -0
  21. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js +15 -0
  22. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  23. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +20 -0
  24. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  25. package/build/commonjs/Carousel/animation/index.js +40 -0
  26. package/build/commonjs/Carousel/animation/index.js.map +1 -0
  27. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js +27 -0
  28. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  29. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +65 -0
  30. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  31. package/build/commonjs/Carousel/components/InternalContext.js +29 -0
  32. package/build/commonjs/Carousel/components/InternalContext.js.map +1 -0
  33. package/build/commonjs/Carousel/components/ItemView.js +66 -0
  34. package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
  35. package/build/commonjs/Carousel/components/RootView.js +86 -0
  36. package/build/commonjs/Carousel/components/RootView.js.map +1 -0
  37. package/build/commonjs/Carousel/components/ScrollViewGesture.js +82 -0
  38. package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -0
  39. package/build/commonjs/Carousel/components/index.js +40 -0
  40. package/build/commonjs/Carousel/components/index.js.map +1 -0
  41. package/build/commonjs/Carousel/components/useItemInterpolation.js +65 -0
  42. package/build/commonjs/Carousel/components/useItemInterpolation.js.map +1 -0
  43. package/build/commonjs/Carousel/hooks/index.js +48 -0
  44. package/build/commonjs/Carousel/hooks/index.js.map +1 -0
  45. package/build/commonjs/Carousel/hooks/useAutoplayController.js +58 -0
  46. package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
  47. package/build/commonjs/Carousel/hooks/useIndexController.js +55 -0
  48. package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
  49. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +95 -0
  50. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  51. package/build/commonjs/Carousel/hooks/useLoopedData.js +33 -0
  52. package/build/commonjs/Carousel/hooks/useLoopedData.js.map +1 -0
  53. package/build/commonjs/Carousel/hooks/usePagingAnimator.js +205 -0
  54. package/build/commonjs/Carousel/hooks/usePagingAnimator.js.map +1 -0
  55. package/build/commonjs/Carousel/index.js +16 -2
  56. package/build/commonjs/Carousel/index.js.map +1 -1
  57. package/build/commonjs/Carousel/tick.js +16 -0
  58. package/build/commonjs/Carousel/tick.js.map +1 -0
  59. package/build/commonjs/Carousel/types.js +8 -0
  60. package/build/commonjs/Carousel/types.js.map +1 -0
  61. package/build/commonjs/ComicViewer/ComicViewer.js +215 -95
  62. package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
  63. package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
  64. package/build/commonjs/ComicViewer/EncodedTile.js +10 -0
  65. package/build/commonjs/ComicViewer/EncodedTile.js.map +1 -0
  66. package/build/commonjs/ComicViewer/FastScroll.js +176 -0
  67. package/build/commonjs/ComicViewer/FastScroll.js.map +1 -0
  68. package/build/commonjs/ComicViewer/{ComicViewerItemProps.js → FastScrollProps.js} +1 -1
  69. package/build/commonjs/ComicViewer/FastScrollProps.js.map +1 -0
  70. package/build/commonjs/ComicViewer/ReloadButton.js +48 -0
  71. package/build/commonjs/ComicViewer/ReloadButton.js.map +1 -0
  72. package/build/commonjs/ComicViewer/ViewerItem.js +53 -58
  73. package/build/commonjs/ComicViewer/ViewerItem.js.map +1 -1
  74. package/build/commonjs/ComicViewer/index.js.map +1 -1
  75. package/build/commonjs/ComicViewer/util.js +27 -0
  76. package/build/commonjs/ComicViewer/util.js.map +1 -0
  77. package/build/commonjs/DateTimePicker/DateTimePicker.js +10 -1
  78. package/build/commonjs/DateTimePicker/DateTimePicker.js.map +1 -1
  79. package/build/commonjs/DateTimePicker/DateTimePickerProps.js.map +1 -1
  80. package/build/commonjs/DateTimePicker/DateTimePickerProvider.js.map +1 -1
  81. package/build/commonjs/DateTimePicker/YearPicker.js +21 -17
  82. package/build/commonjs/DateTimePicker/YearPicker.js.map +1 -1
  83. package/build/commonjs/DateTimePicker/index.js +4 -4
  84. package/build/commonjs/DateTimePicker/index.js.map +1 -1
  85. package/build/commonjs/DateTimePicker/utils.js +2 -1
  86. package/build/commonjs/DateTimePicker/utils.js.map +1 -1
  87. package/build/commonjs/FlipCard/FlipCard.js +7 -13
  88. package/build/commonjs/FlipCard/FlipCard.js.map +1 -1
  89. package/build/commonjs/FlipCard/FlipCardProps.js.map +1 -1
  90. package/build/commonjs/FlipCard/index.js.map +1 -1
  91. package/build/commonjs/StatusBarProvider/Provider.js +1 -1
  92. package/build/commonjs/StatusBarProvider/Provider.js.map +1 -1
  93. package/build/commonjs/StatusBarProvider/StatusBarProvider.js.map +1 -1
  94. package/build/commonjs/StatusBarProvider/StatusBarProviderProps.js.map +1 -1
  95. package/build/commonjs/StatusBarProvider/index.js.map +1 -1
  96. package/build/commonjs/ViewPager/FluxContext.js +13 -0
  97. package/build/commonjs/ViewPager/FluxContext.js.map +1 -0
  98. package/build/commonjs/ViewPager/InternalContext.js +17 -0
  99. package/build/commonjs/ViewPager/InternalContext.js.map +1 -0
  100. package/build/commonjs/ViewPager/PageStateContext.js +16 -0
  101. package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
  102. package/build/commonjs/ViewPager/ViewPager.js +81 -0
  103. package/build/commonjs/ViewPager/ViewPager.js.map +1 -0
  104. package/build/commonjs/ViewPager/ViewPager.native.js +152 -0
  105. package/build/commonjs/ViewPager/ViewPager.native.js.map +1 -0
  106. package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
  107. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js +122 -0
  108. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  109. package/build/commonjs/ViewPager/components/FluxStoreProvider.js +37 -0
  110. package/build/commonjs/ViewPager/components/FluxStoreProvider.js.map +1 -0
  111. package/build/commonjs/ViewPager/components/index.js +24 -0
  112. package/build/commonjs/ViewPager/components/index.js.map +1 -0
  113. package/build/commonjs/ViewPager/hooks/index.js +64 -0
  114. package/build/commonjs/ViewPager/hooks/index.js.map +1 -0
  115. package/build/commonjs/ViewPager/hooks/useDispatch.js +22 -0
  116. package/build/commonjs/ViewPager/hooks/useDispatch.js.map +1 -0
  117. package/build/commonjs/ViewPager/hooks/useEagerState.js +24 -0
  118. package/build/commonjs/ViewPager/hooks/useEagerState.js.map +1 -0
  119. package/build/commonjs/ViewPager/hooks/useForceRender.js +16 -0
  120. package/build/commonjs/ViewPager/hooks/useForceRender.js.map +1 -0
  121. package/build/commonjs/ViewPager/hooks/useLazyState.js +45 -0
  122. package/build/commonjs/ViewPager/hooks/useLazyState.js.map +1 -0
  123. package/build/commonjs/ViewPager/hooks/usePageStore.js +35 -0
  124. package/build/commonjs/ViewPager/hooks/usePageStore.js.map +1 -0
  125. package/build/commonjs/ViewPager/hooks/useStore.js +26 -0
  126. package/build/commonjs/ViewPager/hooks/useStore.js.map +1 -0
  127. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js +19 -0
  128. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  129. package/build/commonjs/ViewPager/index.js +42 -2
  130. package/build/commonjs/ViewPager/index.js.map +1 -1
  131. package/build/commonjs/ViewPager/types.js +2 -0
  132. package/build/commonjs/ViewPager/types.js.map +1 -0
  133. package/build/commonjs/ViewPager/utils.js +12 -43
  134. package/build/commonjs/ViewPager/utils.js.map +1 -1
  135. package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
  136. package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
  137. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
  138. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  139. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  140. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  141. package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
  142. package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
  143. package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
  144. package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
  145. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
  146. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  147. package/build/commonjs/hooks/index.js +16 -0
  148. package/build/commonjs/hooks/index.js.map +1 -1
  149. package/build/commonjs/hooks/useAppbarStyles.js.map +1 -1
  150. package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
  151. package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
  152. package/build/commonjs/hooks/useElevationStyle.js.map +1 -1
  153. package/build/commonjs/hooks/useHeight.js +7 -6
  154. package/build/commonjs/hooks/useHeight.js.map +1 -1
  155. package/build/commonjs/hooks/useIsMounted.js +22 -0
  156. package/build/commonjs/hooks/useIsMounted.js.map +1 -0
  157. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +56 -57
  158. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  159. package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js +9 -11
  160. package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
  161. package/build/commonjs/index.js +28 -7
  162. package/build/commonjs/index.js.map +1 -1
  163. package/build/module/AnimatedY/AnimatedY.js +11 -10
  164. package/build/module/AnimatedY/AnimatedY.js.map +1 -1
  165. package/build/module/AnimatedY/AnimatedYProps.js.map +1 -1
  166. package/build/module/AnimatedY/index.js.map +1 -1
  167. package/build/module/BottomSheet/BottomSheetNative.js +34 -10
  168. package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
  169. package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
  170. package/build/module/BottomSheet/BottomSheetWeb.js +28 -16
  171. package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
  172. package/build/module/BottomSheet/TransparentBackdrop.js +1 -1
  173. package/build/module/BottomSheet/TransparentBackdrop.js.map +1 -1
  174. package/build/module/BottomSheet/index.js.map +1 -1
  175. package/build/module/BottomSheet/index.native.js.map +1 -1
  176. package/build/module/BottomSheet/useDynamicSnapPoints.js +52 -0
  177. package/build/module/BottomSheet/useDynamicSnapPoints.js.map +1 -0
  178. package/build/module/Carousel/Carousel.js +109 -0
  179. package/build/module/Carousel/Carousel.js.map +1 -0
  180. package/build/module/Carousel/CarouselProps.js.map +1 -1
  181. package/build/module/Carousel/animation/animationUtils.js +2 -0
  182. package/build/module/Carousel/animation/animationUtils.js.map +1 -0
  183. package/build/module/Carousel/animation/createDefaultItemStyle.js +3 -0
  184. package/build/module/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  185. package/build/module/Carousel/animation/createDefaultScrollAnimation.js +11 -0
  186. package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  187. package/build/module/Carousel/animation/index.js +5 -0
  188. package/build/module/Carousel/animation/index.js.map +1 -0
  189. package/build/module/Carousel/animation/normalItemStyleFactory.js +18 -0
  190. package/build/module/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  191. package/build/module/Carousel/animation/parallaxItemStyleFactory.js +55 -0
  192. package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  193. package/build/module/Carousel/components/InternalContext.js +19 -0
  194. package/build/module/Carousel/components/InternalContext.js.map +1 -0
  195. package/build/module/Carousel/components/ItemView.js +46 -0
  196. package/build/module/Carousel/components/ItemView.js.map +1 -0
  197. package/build/module/Carousel/components/RootView.js +65 -0
  198. package/build/module/Carousel/components/RootView.js.map +1 -0
  199. package/build/module/Carousel/components/ScrollViewGesture.js +68 -0
  200. package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -0
  201. package/build/module/Carousel/components/index.js +5 -0
  202. package/build/module/Carousel/components/index.js.map +1 -0
  203. package/build/module/Carousel/components/useItemInterpolation.js +51 -0
  204. package/build/module/Carousel/components/useItemInterpolation.js.map +1 -0
  205. package/build/module/Carousel/hooks/index.js +6 -0
  206. package/build/module/Carousel/hooks/index.js.map +1 -0
  207. package/build/module/Carousel/hooks/useAutoplayController.js +48 -0
  208. package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
  209. package/build/module/Carousel/hooks/useIndexController.js +44 -0
  210. package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
  211. package/build/module/Carousel/hooks/useItemVisibilityStore.js +86 -0
  212. package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  213. package/build/module/Carousel/hooks/useLoopedData.js +24 -0
  214. package/build/module/Carousel/hooks/useLoopedData.js.map +1 -0
  215. package/build/module/Carousel/hooks/usePagingAnimator.js +195 -0
  216. package/build/module/Carousel/hooks/usePagingAnimator.js.map +1 -0
  217. package/build/module/Carousel/index.js +2 -1
  218. package/build/module/Carousel/index.js.map +1 -1
  219. package/build/module/Carousel/tick.js +6 -0
  220. package/build/module/Carousel/tick.js.map +1 -0
  221. package/build/module/Carousel/types.js +4 -0
  222. package/build/module/Carousel/types.js.map +1 -0
  223. package/build/module/ComicViewer/ComicViewer.js +214 -96
  224. package/build/module/ComicViewer/ComicViewer.js.map +1 -1
  225. package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
  226. package/build/module/ComicViewer/EncodedTile.js +3 -0
  227. package/build/module/ComicViewer/EncodedTile.js.map +1 -0
  228. package/build/module/ComicViewer/FastScroll.js +153 -0
  229. package/build/module/ComicViewer/FastScroll.js.map +1 -0
  230. package/build/module/ComicViewer/FastScrollProps.js +2 -0
  231. package/build/module/ComicViewer/FastScrollProps.js.map +1 -0
  232. package/build/module/ComicViewer/ReloadButton.js +33 -0
  233. package/build/module/ComicViewer/ReloadButton.js.map +1 -0
  234. package/build/module/ComicViewer/ViewerItem.js +53 -59
  235. package/build/module/ComicViewer/ViewerItem.js.map +1 -1
  236. package/build/module/ComicViewer/index.js.map +1 -1
  237. package/build/module/ComicViewer/util.js +15 -0
  238. package/build/module/ComicViewer/util.js.map +1 -0
  239. package/build/module/DateTimePicker/DateTimePicker.js +11 -2
  240. package/build/module/DateTimePicker/DateTimePicker.js.map +1 -1
  241. package/build/module/DateTimePicker/DateTimePickerProps.js.map +1 -1
  242. package/build/module/DateTimePicker/DateTimePickerProvider.js.map +1 -1
  243. package/build/module/DateTimePicker/YearPicker.js +21 -17
  244. package/build/module/DateTimePicker/YearPicker.js.map +1 -1
  245. package/build/module/DateTimePicker/index.js.map +1 -1
  246. package/build/module/DateTimePicker/utils.js +2 -1
  247. package/build/module/DateTimePicker/utils.js.map +1 -1
  248. package/build/module/FlipCard/FlipCard.js +7 -7
  249. package/build/module/FlipCard/FlipCard.js.map +1 -1
  250. package/build/module/FlipCard/FlipCardProps.js.map +1 -1
  251. package/build/module/FlipCard/index.js.map +1 -1
  252. package/build/module/StatusBarProvider/Provider.js.map +1 -1
  253. package/build/module/StatusBarProvider/StatusBarProvider.js.map +1 -1
  254. package/build/module/StatusBarProvider/StatusBarProviderProps.js.map +1 -1
  255. package/build/module/StatusBarProvider/index.js.map +1 -1
  256. package/build/module/ViewPager/FluxContext.js +4 -0
  257. package/build/module/ViewPager/FluxContext.js.map +1 -0
  258. package/build/module/ViewPager/InternalContext.js +7 -0
  259. package/build/module/ViewPager/InternalContext.js.map +1 -0
  260. package/build/module/ViewPager/PageStateContext.js +7 -0
  261. package/build/module/ViewPager/PageStateContext.js.map +1 -0
  262. package/build/module/ViewPager/ViewPager.js +57 -0
  263. package/build/module/ViewPager/ViewPager.js.map +1 -0
  264. package/build/module/ViewPager/ViewPager.native.js +129 -0
  265. package/build/module/ViewPager/ViewPager.native.js.map +1 -0
  266. package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
  267. package/build/module/ViewPager/components/ChildrenMemoizedPage.js +101 -0
  268. package/build/module/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  269. package/build/module/ViewPager/components/FluxStoreProvider.js +20 -0
  270. package/build/module/ViewPager/components/FluxStoreProvider.js.map +1 -0
  271. package/build/module/ViewPager/components/index.js +3 -0
  272. package/build/module/ViewPager/components/index.js.map +1 -0
  273. package/build/module/ViewPager/hooks/index.js +8 -0
  274. package/build/module/ViewPager/hooks/index.js.map +1 -0
  275. package/build/module/ViewPager/hooks/useDispatch.js +10 -0
  276. package/build/module/ViewPager/hooks/useDispatch.js.map +1 -0
  277. package/build/module/ViewPager/hooks/useEagerState.js +12 -0
  278. package/build/module/ViewPager/hooks/useEagerState.js.map +1 -0
  279. package/build/module/ViewPager/hooks/useForceRender.js +7 -0
  280. package/build/module/ViewPager/hooks/useForceRender.js.map +1 -0
  281. package/build/module/ViewPager/hooks/useLazyState.js +30 -0
  282. package/build/module/ViewPager/hooks/useLazyState.js.map +1 -0
  283. package/build/module/ViewPager/hooks/usePageStore.js +25 -0
  284. package/build/module/ViewPager/hooks/usePageStore.js.map +1 -0
  285. package/build/module/ViewPager/hooks/useStore.js +14 -0
  286. package/build/module/ViewPager/hooks/useStore.js.map +1 -0
  287. package/build/module/ViewPager/hooks/useViewPagerPageState.js +7 -0
  288. package/build/module/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  289. package/build/module/ViewPager/index.js +3 -1
  290. package/build/module/ViewPager/index.js.map +1 -1
  291. package/build/module/ViewPager/types.js +2 -0
  292. package/build/module/ViewPager/types.js.map +1 -0
  293. package/build/module/ViewPager/utils.js +6 -33
  294. package/build/module/ViewPager/utils.js.map +1 -1
  295. package/build/module/ViewabilityTrackerView/Viewability.js +2 -0
  296. package/build/module/ViewabilityTrackerView/Viewability.js.map +1 -0
  297. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js +28 -0
  298. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  299. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  300. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  301. package/build/module/ViewabilityTrackerView/index.js +2 -0
  302. package/build/module/ViewabilityTrackerView/index.js.map +1 -0
  303. package/build/module/ViewabilityTrackerView/measureViewability.js +34 -0
  304. package/build/module/ViewabilityTrackerView/measureViewability.js.map +1 -0
  305. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js +73 -0
  306. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  307. package/build/module/hooks/index.js +2 -0
  308. package/build/module/hooks/index.js.map +1 -1
  309. package/build/module/hooks/useAppbarStyles.js.map +1 -1
  310. package/build/module/hooks/useDeferredExecutor.js +33 -0
  311. package/build/module/hooks/useDeferredExecutor.js.map +1 -0
  312. package/build/module/hooks/useElevationStyle.js.map +1 -1
  313. package/build/module/hooks/useHeight.js +4 -4
  314. package/build/module/hooks/useHeight.js.map +1 -1
  315. package/build/module/hooks/useIsMounted.js +13 -0
  316. package/build/module/hooks/useIsMounted.js.map +1 -0
  317. package/build/module/hooks/useUnstableCollapsibleAppBar.js +56 -41
  318. package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  319. package/build/module/hooks/useUnstableToggleDisplayStyle.js +9 -7
  320. package/build/module/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
  321. package/build/module/index.js +2 -0
  322. package/build/module/index.js.map +1 -1
  323. package/build/typescript/BottomSheet/BottomSheetProps.d.ts +28 -1
  324. package/build/typescript/BottomSheet/useDynamicSnapPoints.d.ts +12 -0
  325. package/build/typescript/Carousel/Carousel.d.ts +5 -0
  326. package/build/typescript/Carousel/CarouselProps.d.ts +33 -48
  327. package/build/typescript/Carousel/animation/animationUtils.d.ts +1 -0
  328. package/build/typescript/Carousel/animation/createDefaultItemStyle.d.ts +2 -0
  329. package/build/typescript/Carousel/animation/createDefaultScrollAnimation.d.ts +2 -0
  330. package/build/typescript/Carousel/animation/index.d.ts +4 -0
  331. package/build/typescript/Carousel/animation/normalItemStyleFactory.d.ts +2 -0
  332. package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +9 -0
  333. package/build/typescript/Carousel/components/InternalContext.d.ts +14 -0
  334. package/build/typescript/Carousel/components/ItemView.d.ts +9 -0
  335. package/build/typescript/Carousel/components/RootView.d.ts +16 -0
  336. package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +12 -0
  337. package/build/typescript/Carousel/components/index.d.ts +4 -0
  338. package/build/typescript/Carousel/components/useItemInterpolation.d.ts +2 -0
  339. package/build/typescript/Carousel/hooks/index.d.ts +5 -0
  340. package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
  341. package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
  342. package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +7 -0
  343. package/build/typescript/Carousel/hooks/useLoopedData.d.ts +1 -0
  344. package/build/typescript/Carousel/hooks/usePagingAnimator.d.ts +17 -0
  345. package/build/typescript/Carousel/index.d.ts +3 -1
  346. package/build/typescript/Carousel/tick.d.ts +2 -0
  347. package/build/typescript/Carousel/types.d.ts +91 -0
  348. package/build/typescript/ComicViewer/ComicViewer.d.ts +1 -1
  349. package/build/typescript/ComicViewer/ComicViewerProps.d.ts +56 -43
  350. package/build/typescript/ComicViewer/EncodedTile.d.ts +2 -0
  351. package/build/typescript/ComicViewer/FastScroll.d.ts +4 -0
  352. package/build/typescript/ComicViewer/FastScrollProps.d.ts +74 -0
  353. package/build/typescript/ComicViewer/ReloadButton.d.ts +7 -0
  354. package/build/typescript/ComicViewer/ViewerItem.d.ts +46 -7
  355. package/build/typescript/ComicViewer/index.d.ts +3 -2
  356. package/build/typescript/ComicViewer/util.d.ts +2 -0
  357. package/build/typescript/ViewPager/FluxContext.d.ts +5 -0
  358. package/build/typescript/ViewPager/InternalContext.d.ts +7 -0
  359. package/build/typescript/ViewPager/PageStateContext.d.ts +6 -0
  360. package/build/typescript/ViewPager/ViewPager.d.ts +5 -0
  361. package/build/typescript/ViewPager/ViewPager.native.d.ts +5 -0
  362. package/build/typescript/ViewPager/ViewPagerProps.d.ts +21 -27
  363. package/build/typescript/ViewPager/components/ChildrenMemoizedPage.d.ts +14 -0
  364. package/build/typescript/ViewPager/components/FluxStoreProvider.d.ts +6 -0
  365. package/build/typescript/ViewPager/components/index.d.ts +2 -0
  366. package/build/typescript/ViewPager/hooks/index.d.ts +7 -0
  367. package/build/typescript/ViewPager/hooks/useDispatch.d.ts +2 -0
  368. package/build/typescript/ViewPager/hooks/useEagerState.d.ts +1 -0
  369. package/build/typescript/ViewPager/hooks/useForceRender.d.ts +2 -0
  370. package/build/typescript/ViewPager/hooks/useLazyState.d.ts +2 -0
  371. package/build/typescript/ViewPager/hooks/usePageStore.d.ts +2 -0
  372. package/build/typescript/ViewPager/hooks/useStore.d.ts +2 -0
  373. package/build/typescript/ViewPager/hooks/useViewPagerPageState.d.ts +1 -0
  374. package/build/typescript/ViewPager/index.d.ts +4 -1
  375. package/build/typescript/ViewPager/types.d.ts +12 -0
  376. package/build/typescript/ViewPager/utils.d.ts +5 -20
  377. package/build/typescript/ViewabilityTrackerView/Viewability.d.ts +3 -0
  378. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +3 -0
  379. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerViewProps.d.ts +22 -0
  380. package/build/typescript/ViewabilityTrackerView/index.d.ts +2 -0
  381. package/build/typescript/ViewabilityTrackerView/measureViewability.d.ts +11 -0
  382. package/build/typescript/ViewabilityTrackerView/useViewabilityTracker.d.ts +11 -0
  383. package/build/typescript/hooks/index.d.ts +2 -0
  384. package/build/typescript/hooks/useDeferredExecutor.d.ts +11 -0
  385. package/build/typescript/hooks/useIsMounted.d.ts +4 -0
  386. package/build/typescript/hooks/useUnstableCollapsibleAppBar.d.ts +2 -2
  387. package/build/typescript/hooks/useUnstableToggleDisplayStyle.d.ts +2 -2
  388. package/build/typescript/index.d.ts +2 -0
  389. package/package.json +13 -27
  390. package/src/AnimatedY/AnimatedY.tsx +13 -10
  391. package/src/BottomSheet/BottomSheetNative.tsx +35 -6
  392. package/src/BottomSheet/BottomSheetProps.ts +33 -1
  393. package/src/BottomSheet/BottomSheetWeb.tsx +36 -14
  394. package/src/BottomSheet/useDynamicSnapPoints.ts +73 -0
  395. package/src/Carousel/Carousel.tsx +135 -0
  396. package/src/Carousel/CarouselProps.ts +42 -53
  397. package/src/Carousel/animation/animationUtils.ts +1 -0
  398. package/src/Carousel/animation/createDefaultItemStyle.ts +3 -0
  399. package/src/Carousel/animation/createDefaultScrollAnimation.ts +13 -0
  400. package/src/Carousel/animation/index.ts +4 -0
  401. package/src/Carousel/animation/normalItemStyleFactory.ts +19 -0
  402. package/src/Carousel/animation/parallaxItemStyleFactory.ts +79 -0
  403. package/src/Carousel/components/InternalContext.ts +33 -0
  404. package/src/Carousel/components/ItemView.tsx +66 -0
  405. package/src/Carousel/components/RootView.tsx +79 -0
  406. package/src/Carousel/components/ScrollViewGesture.tsx +92 -0
  407. package/src/Carousel/components/index.ts +4 -0
  408. package/src/Carousel/components/useItemInterpolation.ts +107 -0
  409. package/src/Carousel/hooks/index.ts +5 -0
  410. package/src/Carousel/hooks/useAutoplayController.ts +57 -0
  411. package/src/Carousel/hooks/useIndexController.tsx +57 -0
  412. package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
  413. package/src/Carousel/hooks/useLoopedData.ts +26 -0
  414. package/src/Carousel/hooks/usePagingAnimator.ts +260 -0
  415. package/src/Carousel/index.ts +4 -2
  416. package/src/Carousel/tick.ts +6 -0
  417. package/src/Carousel/types.ts +114 -0
  418. package/src/ComicViewer/ComicViewer.tsx +243 -107
  419. package/src/ComicViewer/ComicViewerProps.ts +60 -44
  420. package/src/ComicViewer/EncodedTile.ts +3 -0
  421. package/src/ComicViewer/FastScroll.tsx +176 -0
  422. package/src/ComicViewer/FastScrollProps.ts +88 -0
  423. package/src/ComicViewer/ReloadButton.tsx +36 -0
  424. package/src/ComicViewer/ViewerItem.tsx +104 -62
  425. package/src/ComicViewer/index.ts +8 -2
  426. package/src/ComicViewer/util.ts +15 -0
  427. package/src/DateTimePicker/DateTimePicker.tsx +9 -1
  428. package/src/FlipCard/FlipCard.tsx +8 -8
  429. package/src/ViewPager/FluxContext.ts +8 -0
  430. package/src/ViewPager/InternalContext.ts +13 -0
  431. package/src/ViewPager/PageStateContext.ts +11 -0
  432. package/src/ViewPager/ViewPager.native.tsx +152 -0
  433. package/src/ViewPager/ViewPager.tsx +69 -0
  434. package/src/ViewPager/ViewPagerProps.ts +25 -34
  435. package/src/ViewPager/components/ChildrenMemoizedPage.tsx +124 -0
  436. package/src/ViewPager/components/FluxStoreProvider.tsx +27 -0
  437. package/src/ViewPager/components/index.ts +2 -0
  438. package/src/ViewPager/hooks/index.ts +7 -0
  439. package/src/ViewPager/hooks/useDispatch.ts +11 -0
  440. package/src/ViewPager/hooks/useEagerState.ts +14 -0
  441. package/src/ViewPager/hooks/useForceRender.ts +7 -0
  442. package/src/ViewPager/hooks/useLazyState.ts +32 -0
  443. package/src/ViewPager/hooks/usePageStore.ts +30 -0
  444. package/src/ViewPager/hooks/useStore.ts +15 -0
  445. package/src/ViewPager/hooks/useViewPagerPageState.ts +6 -0
  446. package/src/ViewPager/index.ts +11 -2
  447. package/src/ViewPager/types.ts +15 -0
  448. package/src/ViewPager/utils.tsx +9 -56
  449. package/src/ViewabilityTrackerView/Viewability.ts +3 -0
  450. package/src/ViewabilityTrackerView/ViewabilityTrackerView.tsx +33 -0
  451. package/src/ViewabilityTrackerView/ViewabilityTrackerViewProps.ts +25 -0
  452. package/src/ViewabilityTrackerView/index.ts +2 -0
  453. package/src/ViewabilityTrackerView/measureViewability.ts +54 -0
  454. package/src/ViewabilityTrackerView/useViewabilityTracker.ts +85 -0
  455. package/src/hooks/index.ts +2 -0
  456. package/src/hooks/useDeferredExecutor.ts +46 -0
  457. package/src/hooks/useHeight.ts +3 -4
  458. package/src/hooks/useIsMounted.ts +19 -0
  459. package/src/hooks/useUnstableCollapsibleAppBar.ts +60 -38
  460. package/src/hooks/useUnstableToggleDisplayStyle.ts +8 -6
  461. package/src/index.ts +3 -0
  462. package/yarn-error.log +103 -0
  463. package/build/commonjs/Carousel/CarouselNative.js +0 -72
  464. package/build/commonjs/Carousel/CarouselNative.js.map +0 -1
  465. package/build/commonjs/Carousel/CarouselWeb.js +0 -237
  466. package/build/commonjs/Carousel/CarouselWeb.js.map +0 -1
  467. package/build/commonjs/Carousel/index.native.js.map +0 -1
  468. package/build/commonjs/Carousel/utils.js +0 -19
  469. package/build/commonjs/Carousel/utils.js.map +0 -1
  470. package/build/commonjs/ComicViewer/ComicViewerItemProps.js.map +0 -1
  471. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +0 -49
  472. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  473. package/build/commonjs/ViewPager/ViewPagerNative.js +0 -72
  474. package/build/commonjs/ViewPager/ViewPagerNative.js.map +0 -1
  475. package/build/commonjs/ViewPager/ViewPagerWeb.js +0 -55
  476. package/build/commonjs/ViewPager/ViewPagerWeb.js.map +0 -1
  477. package/build/commonjs/ViewPager/index.native.js +0 -16
  478. package/build/commonjs/ViewPager/index.native.js.map +0 -1
  479. package/build/commonjs/hooks/useWidth.js +0 -29
  480. package/build/commonjs/hooks/useWidth.js.map +0 -1
  481. package/build/module/Carousel/CarouselNative.js +0 -54
  482. package/build/module/Carousel/CarouselNative.js.map +0 -1
  483. package/build/module/Carousel/CarouselWeb.js +0 -215
  484. package/build/module/Carousel/CarouselWeb.js.map +0 -1
  485. package/build/module/Carousel/index.native.js +0 -2
  486. package/build/module/Carousel/index.native.js.map +0 -1
  487. package/build/module/Carousel/utils.js +0 -7
  488. package/build/module/Carousel/utils.js.map +0 -1
  489. package/build/module/ComicViewer/ComicViewerItemProps.js +0 -2
  490. package/build/module/ComicViewer/ComicViewerItemProps.js.map +0 -1
  491. package/build/module/ViewPager/ChildrenMemoizedPage.js +0 -37
  492. package/build/module/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  493. package/build/module/ViewPager/ViewPagerNative.js +0 -53
  494. package/build/module/ViewPager/ViewPagerNative.js.map +0 -1
  495. package/build/module/ViewPager/ViewPagerWeb.js +0 -41
  496. package/build/module/ViewPager/ViewPagerWeb.js.map +0 -1
  497. package/build/module/ViewPager/index.native.js +0 -2
  498. package/build/module/ViewPager/index.native.js.map +0 -1
  499. package/build/module/hooks/useWidth.js +0 -15
  500. package/build/module/hooks/useWidth.js.map +0 -1
  501. package/build/typescript/Carousel/CarouselNative.d.ts +0 -3
  502. package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
  503. package/build/typescript/Carousel/index.native.d.ts +0 -1
  504. package/build/typescript/Carousel/utils.d.ts +0 -6
  505. package/build/typescript/ComicViewer/ComicViewerItemProps.d.ts +0 -12
  506. package/build/typescript/ViewPager/ChildrenMemoizedPage.d.ts +0 -4
  507. package/build/typescript/ViewPager/ViewPagerNative.d.ts +0 -3
  508. package/build/typescript/ViewPager/ViewPagerWeb.d.ts +0 -3
  509. package/build/typescript/ViewPager/index.native.d.ts +0 -1
  510. package/build/typescript/hooks/useWidth.d.ts +0 -2
  511. package/src/Carousel/CarouselNative.tsx +0 -67
  512. package/src/Carousel/CarouselWeb.tsx +0 -222
  513. package/src/Carousel/index.native.ts +0 -1
  514. package/src/Carousel/utils.ts +0 -11
  515. package/src/ComicViewer/ComicViewerItemProps.ts +0 -15
  516. package/src/ViewPager/ChildrenMemoizedPage.tsx +0 -36
  517. package/src/ViewPager/ViewPagerNative.tsx +0 -66
  518. package/src/ViewPager/ViewPagerWeb.tsx +0 -52
  519. package/src/ViewPager/index.native.ts +0 -1
  520. package/src/hooks/useWidth.ts +0 -17
@@ -0,0 +1,195 @@
1
+ import { useCallback, useMemo, useRef } from 'react';
2
+ import { Animated } from 'react-native';
3
+ import { useAnimatedValue } from '@fountain-ui/core';
4
+
5
+ function directionToValue(itemWidth) {
6
+ return function (direction) {
7
+ switch (direction) {
8
+ case 'next':
9
+ return -itemWidth;
10
+
11
+ case 'prev':
12
+ return itemWidth;
13
+
14
+ case 'stay':
15
+ return 0;
16
+ }
17
+ };
18
+ }
19
+
20
+ function toValueCompensator(itemWidth) {
21
+ return function (toValue, currentOffset) {
22
+ const remainder = Math.abs(currentOffset % itemWidth);
23
+ const halfOfItemWidth = Math.abs(itemWidth / 2);
24
+ const compensateVector = remainder > halfOfItemWidth ? remainder - itemWidth : remainder;
25
+ const direction = currentOffset > 0 ? -1 : 1;
26
+ return toValue + direction * compensateVector;
27
+ };
28
+ }
29
+
30
+ export default function usePagingAnimator(config) {
31
+ const {
32
+ createScrollAnimation,
33
+ itemWidth,
34
+ indexController,
35
+ initialIndex,
36
+ loop,
37
+ numberOfData
38
+ } = config;
39
+ const {
40
+ getCurrentIndex,
41
+ lastIndex,
42
+ notifyScrollStateHasChanged
43
+ } = indexController;
44
+ const initialOffsetX = itemWidth * initialIndex;
45
+ const accumulativeOffsetX = useAnimatedValue(initialOffsetX);
46
+ const animationOffsetX = useAnimatedValue(0);
47
+ const gestureTranslationX = useAnimatedValue(0);
48
+ const globalInterpolation = useMemo(() => {
49
+ return Animated.add(Animated.add(accumulativeOffsetX, animationOffsetX), gestureTranslationX);
50
+ }, []);
51
+ const toValueRef = useRef(0);
52
+ const currentOffsetRef = useRef(0);
53
+ const isAnimatingRef = useRef(false);
54
+ const maxWidth = Math.abs(numberOfData * itemWidth);
55
+ const ensureOffsetBoundary = useCallback(offset => {
56
+ if (loop) {
57
+ const isCloseToEnd = Math.abs(offset) >= maxWidth - itemWidth;
58
+
59
+ if (isCloseToEnd) {
60
+ const signOfOffset = offset > 0 ? 1 : -1;
61
+ return offset + -signOfOffset * maxWidth;
62
+ }
63
+ }
64
+
65
+ return offset % maxWidth;
66
+ }, [itemWidth, loop, maxWidth]);
67
+ const requireNewOffset = useCallback(newOffset => {
68
+ const nextOffset = ensureOffsetBoundary(newOffset);
69
+ currentOffsetRef.current = nextOffset;
70
+ accumulativeOffsetX.setValue(nextOffset);
71
+ toValueRef.current = 0;
72
+ animationOffsetX.setValue(0);
73
+ }, [ensureOffsetBoundary]);
74
+ const interruptAnimation = useCallback(() => {
75
+ if (!isAnimatingRef.current) {
76
+ return;
77
+ }
78
+
79
+ animationOffsetX.stopAnimation(lastValue => {
80
+ isAnimatingRef.current = false;
81
+ const prevOffset = currentOffsetRef.current;
82
+ const totalOffset = prevOffset + lastValue;
83
+ requireNewOffset(totalOffset);
84
+ notifyScrollStateHasChanged({
85
+ offset: totalOffset,
86
+ state: 'interrupted'
87
+ });
88
+ });
89
+ }, [notifyScrollStateHasChanged, requireNewOffset]);
90
+ const finalizeAnimation = useCallback(() => {
91
+ isAnimatingRef.current = false;
92
+ const prevOffset = currentOffsetRef.current;
93
+ const toValue = toValueRef.current;
94
+ const totalOffset = prevOffset + toValue;
95
+ requireNewOffset(totalOffset);
96
+ notifyScrollStateHasChanged({
97
+ offset: totalOffset,
98
+ state: 'idle'
99
+ });
100
+ }, [notifyScrollStateHasChanged, requireNewOffset]);
101
+ const startPagingAnimation = useCallback((type, config) => {
102
+ // NOTE: Prevent animation blocking when events either triggered by gesture or triggered by non-gesture occur simultaneously
103
+ const shouldBlockPagingAnimation = isAnimatingRef.current && 'isOriginatedFromGesture' in config && config.isOriginatedFromGesture;
104
+
105
+ if (shouldBlockPagingAnimation) {
106
+ return;
107
+ }
108
+
109
+ const configWithDefaults = {
110
+ animated: true,
111
+ ...config
112
+ };
113
+ const currentIndex = getCurrentIndex();
114
+ const getValueByDirectionOnAllAdjacentItemsVisible = directionToValue(itemWidth);
115
+ const compensateToValue = toValueCompensator(itemWidth);
116
+
117
+ const getValueByDirectionalPagingOnLoopDisabled = _config => {
118
+ const {
119
+ direction,
120
+ isOriginatedFromGesture
121
+ } = _config;
122
+
123
+ if (currentIndex === 0 && direction === 'prev') {
124
+ return isOriginatedFromGesture ? getValueByDirectionOnAllAdjacentItemsVisible('stay') : -lastIndex * itemWidth; // last position
125
+ } else if (currentIndex === lastIndex && direction === 'next') {
126
+ return isOriginatedFromGesture ? getValueByDirectionOnAllAdjacentItemsVisible('stay') : lastIndex * itemWidth; // first position
127
+ }
128
+
129
+ return getValueByDirectionOnAllAdjacentItemsVisible(direction);
130
+ };
131
+
132
+ const getValueByDirectionalPaging = _config => {
133
+ const _configWithDefaults = {
134
+ isOriginatedFromGesture: false,
135
+ ..._config
136
+ };
137
+ return loop ? getValueByDirectionOnAllAdjacentItemsVisible(_configWithDefaults.direction) : getValueByDirectionalPagingOnLoopDisabled(_configWithDefaults);
138
+ };
139
+
140
+ const getValueByIndexPaging = _ref => {
141
+ let {
142
+ index
143
+ } = _ref;
144
+
145
+ if (index < 0 || index > lastIndex || index === currentIndex) {
146
+ // no animation if index is invalid or equals to current index
147
+ return 0;
148
+ }
149
+
150
+ const distance = Math.abs(currentIndex - index) * itemWidth;
151
+ const direction = index > currentIndex ? -1 : 1;
152
+ return distance * direction;
153
+ };
154
+
155
+ const wantedToValue = type === 'directional' // @ts-ignore
156
+ ? getValueByDirectionalPaging(configWithDefaults) // @ts-ignore
157
+ : getValueByIndexPaging(configWithDefaults);
158
+ const toValue = compensateToValue(wantedToValue, currentOffsetRef.current);
159
+ toValueRef.current = toValue;
160
+ isAnimatingRef.current = true;
161
+ notifyScrollStateHasChanged({
162
+ offset: currentOffsetRef.current + toValue,
163
+ state: 'dragging'
164
+ });
165
+ const lastGestureTranslationX = configWithDefaults.lastGestureTranslationX ?? 0;
166
+
167
+ if (Number.isFinite(lastGestureTranslationX)) {
168
+ animationOffsetX.setValue(lastGestureTranslationX);
169
+ gestureTranslationX.setValue(0);
170
+ }
171
+
172
+ if (configWithDefaults.animated) {
173
+ const animation = createScrollAnimation(animationOffsetX, toValue);
174
+ animation.start(_ref2 => {
175
+ let {
176
+ finished
177
+ } = _ref2;
178
+
179
+ if (finished) {
180
+ finalizeAnimation();
181
+ }
182
+ });
183
+ } else {
184
+ finalizeAnimation();
185
+ }
186
+ }, [createScrollAnimation, getCurrentIndex, finalizeAnimation, itemWidth, lastIndex, loop, notifyScrollStateHasChanged]);
187
+ return {
188
+ gestureTranslationX,
189
+ globalInterpolation,
190
+ interruptAnimation,
191
+ startPagingAnimation
192
+ };
193
+ }
194
+ ;
195
+ //# sourceMappingURL=usePagingAnimator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useMemo","useRef","Animated","useAnimatedValue","directionToValue","itemWidth","direction","toValueCompensator","toValue","currentOffset","remainder","Math","abs","halfOfItemWidth","compensateVector","usePagingAnimator","config","createScrollAnimation","indexController","initialIndex","loop","numberOfData","getCurrentIndex","lastIndex","notifyScrollStateHasChanged","initialOffsetX","accumulativeOffsetX","animationOffsetX","gestureTranslationX","globalInterpolation","add","toValueRef","currentOffsetRef","isAnimatingRef","maxWidth","ensureOffsetBoundary","offset","isCloseToEnd","signOfOffset","requireNewOffset","newOffset","nextOffset","current","setValue","interruptAnimation","stopAnimation","lastValue","prevOffset","totalOffset","state","finalizeAnimation","startPagingAnimation","type","shouldBlockPagingAnimation","isOriginatedFromGesture","configWithDefaults","animated","currentIndex","getValueByDirectionOnAllAdjacentItemsVisible","compensateToValue","getValueByDirectionalPagingOnLoopDisabled","_config","getValueByDirectionalPaging","_configWithDefaults","getValueByIndexPaging","index","distance","wantedToValue","lastGestureTranslationX","Number","isFinite","animation","start","finished"],"sources":["usePagingAnimator.ts"],"sourcesContent":["import { useCallback, useMemo, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport { useAnimatedValue } from '@fountain-ui/core';\nimport type {\n CreateScrollAnimation,\n DirectionalPagingAnimationConfig,\n IndexController,\n IndexPagingAnimationConfig,\n PagingAnimationConfig,\n PagingAnimationType,\n PagingDirection,\n StartPagingAnimation,\n} from '../types';\n\nexport interface PagingAnimatorConfig {\n createScrollAnimation: CreateScrollAnimation;\n itemWidth: number;\n indexController: IndexController;\n initialIndex: number;\n loop: boolean;\n numberOfData: number;\n}\n\nexport interface PagingAnimator {\n gestureTranslationX: Animated.Value;\n globalInterpolation: Animated.AnimatedInterpolation;\n interruptAnimation: () => void;\n startPagingAnimation: StartPagingAnimation;\n}\n\nfunction directionToValue(itemWidth: number) {\n return function (direction: PagingDirection): number {\n switch (direction) {\n case 'next':\n return -itemWidth;\n case 'prev':\n return itemWidth;\n case 'stay':\n return 0;\n }\n };\n}\n\nfunction toValueCompensator(itemWidth: number) {\n return function (toValue: number, currentOffset: number): number {\n const remainder = Math.abs(currentOffset % itemWidth);\n\n const halfOfItemWidth = Math.abs(itemWidth / 2);\n const compensateVector = remainder > halfOfItemWidth\n ? remainder - itemWidth\n : remainder;\n\n const direction = currentOffset > 0 ? -1 : 1;\n\n return toValue + (direction * compensateVector);\n };\n}\n\nexport default function usePagingAnimator(config: PagingAnimatorConfig): PagingAnimator {\n const {\n createScrollAnimation,\n itemWidth,\n indexController,\n initialIndex,\n loop,\n numberOfData,\n } = config;\n\n const {\n getCurrentIndex,\n lastIndex,\n notifyScrollStateHasChanged,\n } = indexController;\n\n const initialOffsetX = itemWidth * initialIndex;\n const accumulativeOffsetX = useAnimatedValue(initialOffsetX);\n const animationOffsetX = useAnimatedValue(0);\n const gestureTranslationX = useAnimatedValue(0);\n\n const globalInterpolation = useMemo(() => {\n return Animated.add(\n Animated.add(accumulativeOffsetX, animationOffsetX),\n gestureTranslationX,\n );\n }, []);\n\n const toValueRef = useRef<number>(0);\n const currentOffsetRef = useRef<number>(0);\n\n const isAnimatingRef = useRef<boolean>(false);\n\n const maxWidth = Math.abs(numberOfData * itemWidth);\n\n const ensureOffsetBoundary: (offset: number) => number = useCallback((offset: number) => {\n if (loop) {\n const isCloseToEnd = Math.abs(offset) >= (maxWidth - itemWidth);\n if (isCloseToEnd) {\n const signOfOffset = offset > 0 ? 1 : -1;\n return offset + (-signOfOffset * maxWidth);\n }\n }\n\n return offset % maxWidth;\n }, [itemWidth, loop, maxWidth]);\n\n const requireNewOffset = useCallback((newOffset: number) => {\n const nextOffset = ensureOffsetBoundary(newOffset);\n\n currentOffsetRef.current = nextOffset;\n accumulativeOffsetX.setValue(nextOffset);\n\n toValueRef.current = 0;\n animationOffsetX.setValue(0);\n }, [\n ensureOffsetBoundary,\n ]);\n\n const interruptAnimation = useCallback(() => {\n if (!isAnimatingRef.current) {\n return;\n }\n\n animationOffsetX.stopAnimation(lastValue => {\n isAnimatingRef.current = false;\n\n const prevOffset = currentOffsetRef.current;\n const totalOffset = prevOffset + lastValue;\n\n requireNewOffset(totalOffset);\n\n notifyScrollStateHasChanged({ offset: totalOffset, state: 'interrupted' });\n });\n }, [\n notifyScrollStateHasChanged,\n requireNewOffset,\n ]);\n\n const finalizeAnimation = useCallback(() => {\n isAnimatingRef.current = false;\n\n const prevOffset = currentOffsetRef.current;\n const toValue = toValueRef.current;\n const totalOffset = prevOffset + toValue;\n\n requireNewOffset(totalOffset);\n\n notifyScrollStateHasChanged({ offset: totalOffset, state: 'idle' });\n }, [\n notifyScrollStateHasChanged,\n requireNewOffset,\n ]);\n\n const startPagingAnimation = useCallback((type: PagingAnimationType, config: PagingAnimationConfig) => {\n // NOTE: Prevent animation blocking when events either triggered by gesture or triggered by non-gesture occur simultaneously\n const shouldBlockPagingAnimation = isAnimatingRef.current &&\n 'isOriginatedFromGesture' in config &&\n config.isOriginatedFromGesture;\n\n if (shouldBlockPagingAnimation) {\n return;\n }\n\n const configWithDefaults: PagingAnimationConfig = {\n animated: true,\n ...config,\n };\n\n const currentIndex = getCurrentIndex();\n\n const getValueByDirectionOnAllAdjacentItemsVisible = directionToValue(itemWidth);\n const compensateToValue = toValueCompensator(itemWidth);\n\n const getValueByDirectionalPagingOnLoopDisabled = (_config: DirectionalPagingAnimationConfig): number => {\n const { direction, isOriginatedFromGesture } = _config;\n\n if (currentIndex === 0 && direction === 'prev') {\n return isOriginatedFromGesture\n ? getValueByDirectionOnAllAdjacentItemsVisible('stay')\n : -lastIndex * itemWidth; // last position\n } else if (currentIndex === lastIndex && direction === 'next') {\n return isOriginatedFromGesture\n ? getValueByDirectionOnAllAdjacentItemsVisible('stay')\n : lastIndex * itemWidth; // first position\n }\n return getValueByDirectionOnAllAdjacentItemsVisible(direction);\n };\n\n const getValueByDirectionalPaging = (_config: DirectionalPagingAnimationConfig): number => {\n const _configWithDefaults: DirectionalPagingAnimationConfig = {\n isOriginatedFromGesture: false,\n ..._config,\n };\n\n return loop\n ? getValueByDirectionOnAllAdjacentItemsVisible(_configWithDefaults.direction)\n : getValueByDirectionalPagingOnLoopDisabled(_configWithDefaults);\n };\n\n const getValueByIndexPaging = ({ index }: IndexPagingAnimationConfig): number => {\n if (index < 0 || index > lastIndex || index === currentIndex) {\n // no animation if index is invalid or equals to current index\n return 0;\n }\n\n const distance = Math.abs(currentIndex - index) * itemWidth;\n const direction = index > currentIndex ? -1 : 1;\n\n return distance * direction;\n };\n\n const wantedToValue = type === 'directional'\n // @ts-ignore\n ? getValueByDirectionalPaging(configWithDefaults)\n // @ts-ignore\n : getValueByIndexPaging(configWithDefaults);\n\n const toValue = compensateToValue(wantedToValue, currentOffsetRef.current);\n\n toValueRef.current = toValue;\n isAnimatingRef.current = true;\n\n notifyScrollStateHasChanged({\n offset: currentOffsetRef.current + toValue,\n state: 'dragging',\n });\n\n const lastGestureTranslationX: number = configWithDefaults.lastGestureTranslationX ?? 0;\n if (Number.isFinite(lastGestureTranslationX)) {\n animationOffsetX.setValue(lastGestureTranslationX);\n gestureTranslationX.setValue(0);\n }\n\n if (configWithDefaults.animated) {\n const animation = createScrollAnimation(animationOffsetX, toValue);\n\n animation.start(({ finished }) => {\n if (finished) {\n finalizeAnimation();\n }\n });\n } else {\n finalizeAnimation();\n }\n }, [\n createScrollAnimation,\n getCurrentIndex,\n finalizeAnimation,\n itemWidth,\n lastIndex,\n loop,\n notifyScrollStateHasChanged,\n ]);\n\n return {\n gestureTranslationX,\n globalInterpolation,\n interruptAnimation,\n startPagingAnimation,\n };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,OAAtB,EAA+BC,MAA/B,QAA6C,OAA7C;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,gBAAT,QAAiC,mBAAjC;;AA4BA,SAASC,gBAAT,CAA0BC,SAA1B,EAA6C;EACzC,OAAO,UAAUC,SAAV,EAA8C;IACjD,QAAQA,SAAR;MACI,KAAK,MAAL;QACI,OAAO,CAACD,SAAR;;MACJ,KAAK,MAAL;QACI,OAAOA,SAAP;;MACJ,KAAK,MAAL;QACI,OAAO,CAAP;IANR;EA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ACU,OAAjC,CAAjC;IAEAX,UAAU,CAACW,OAAX,GAAqBlC,OAArB;IACAyB,cAAc,CAACS,OAAf,GAAyB,IAAzB;IAEAlB,2BAA2B,CAAC;MACxBY,MAAM,EAAEJ,gBAAgB,CAACU,OAAjB,GAA2BlC,OADX;MAExByC,KAAK,EAAE;IAFiB,CAAD,CAA3B;IAKA,MAAMmB,uBAA+B,GAAGb,kBAAkB,CAACa,uBAAnB,IAA8C,CAAtF;;IACA,IAAIC,MAAM,CAACC,QAAP,CAAgBF,uBAAhB,CAAJ,EAA8C;MAC1CzC,gBAAgB,CAACgB,QAAjB,CAA0ByB,uBAA1B;MACAxC,mBAAmB,CAACe,QAApB,CAA6B,CAA7B;IACH;;IAED,IAAIY,kBAAkB,CAACC,QAAvB,EAAiC;MAC7B,MAAMe,SAAS,GAAGtD,qBAAqB,CAACU,gBAAD,EAAmBnB,OAAnB,CAAvC;MAEA+D,SAAS,CAACC,KAAV,CAAgB,SAAkB;QAAA,IAAjB;UAAEC;QAAF,CAAiB;;QAC9B,IAAIA,QAAJ,EAAc;UACVvB,iBAAiB;QACpB;MACJ,CAJD;IAKH,CARD,MAQO;MACHA,iBAAiB;IACpB;EACJ,CA3FuC,EA2FrC,CACCjC,qBADD,EAECK,eAFD,EAGC4B,iBAHD,EAIC7C,SAJD,EAKCkB,SALD,EAMCH,IAND,EAOCI,2BAPD,CA3FqC,CAAxC;EAqGA,OAAO;IACHI,mBADG;IAEHC,mBAFG;IAGHe,kBAHG;IAIHO;EAJG,CAAP;AAMH;AAAA"}
@@ -1,2 +1,3 @@
1
- export { default } from './CarouselWeb';
1
+ export { default } from './Carousel';
2
+ export { normalItemStyleFactory, parallaxItemStyleFactory } from './animation';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["default"],"mappings":"AAAA,SAASA,OAAT,QAAwB,eAAxB","sourcesContent":["export { default } from './CarouselWeb';\nexport type { default as CarouselProps } from './CarouselProps';"]}
1
+ {"version":3,"names":["default","normalItemStyleFactory","parallaxItemStyleFactory"],"sources":["index.ts"],"sourcesContent":["export { default } from './Carousel';\nexport type { default as CarouselProps } from './CarouselProps';\nexport type { CarouselInstance } from './types';\nexport { normalItemStyleFactory, parallaxItemStyleFactory } from './animation';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,YAAxB;AAGA,SAASC,sBAAT,EAAiCC,wBAAjC,QAAiE,aAAjE"}
@@ -0,0 +1,6 @@
1
+ import { logger } from '@fountain-ui/utils';
2
+ export default logger('Carousel', {
3
+ enabled: __DEV__,
4
+ format: 'diff'
5
+ });
6
+ //# sourceMappingURL=tick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["logger","enabled","__DEV__","format"],"sources":["tick.ts"],"sourcesContent":["import { logger } from '@fountain-ui/utils';\n\nexport default logger('Carousel', {\n enabled: __DEV__,\n format: 'diff',\n});\n"],"mappings":"AAAA,SAASA,MAAT,QAAuB,oBAAvB;AAEA,eAAeA,MAAM,CAAC,UAAD,EAAa;EAC9BC,OAAO,EAAEC,OADqB;EAE9BC,MAAM,EAAE;AAFsB,CAAb,CAArB"}
@@ -0,0 +1,4 @@
1
+ const directions = ['next', 'prev', 'stay'];
2
+ const scrollStates = ['idle', 'dragging', 'interrupted'];
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["directions","scrollStates"],"sources":["types.ts"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type { Animated, ViewProps } from 'react-native';\n\nconst directions = ['next', 'prev', 'stay'] as const;\n\nexport type PagingDirection = (typeof directions)[number];\n\nconst scrollStates = ['idle', 'dragging', 'interrupted'] as const;\n\nexport type ScrollState = (typeof scrollStates)[number];\n\nexport type ItemHeight = number | 'auto';\n\nexport interface RenderItem<T> {\n (info: { item: T, index: number, interpolation: Animated.AnimatedInterpolation }): ReactElement | null;\n}\n\nexport interface CreateScrollAnimation {\n (aValue: Animated.AnimatedValue, toValue: number): Animated.CompositeAnimation;\n}\n\nexport interface CreateItemStyle {\n (itemInterpolation: Animated.AnimatedInterpolation, itemWidth: number): Animated.AnimatedProps<ViewProps['style']>;\n}\n\nexport interface GetCurrentIndex {\n (): number;\n}\n\nexport interface OnIndexChange {\n (itemIndex: number): void;\n}\n\nexport interface OnPositionChange {\n (position: number): void;\n}\n\nexport interface ScrollStateChangeEvent {\n offset: number;\n state: ScrollState;\n}\n\nexport interface IndexController {\n getCurrentIndex: GetCurrentIndex;\n lastIndex: number;\n notifyScrollStateHasChanged: (event: ScrollStateChangeEvent) => void;\n}\n\nexport type PagingAnimationType = 'directional' | 'index';\n\nexport interface BasePagingAnimationConfig {\n animated?: boolean;\n lastGestureTranslationX?: number;\n}\n\nexport interface DirectionalPagingAnimationConfig extends BasePagingAnimationConfig {\n direction: PagingDirection;\n isOriginatedFromGesture?: boolean;\n}\n\nexport interface IndexPagingAnimationConfig extends BasePagingAnimationConfig {\n index: number;\n}\n\nexport type PagingAnimationConfig = DirectionalPagingAnimationConfig | IndexPagingAnimationConfig;\n\nexport interface StartPagingAnimation {\n (type: PagingAnimationType, config: PagingAnimationConfig): void;\n}\n\nexport type VisibleIndexRanges = Array<[number, number]>;\n\nexport interface StoreSubscription {\n (): void;\n}\n\nexport interface ItemVisibilityStore {\n dispatch: (ranges: VisibleIndexRanges) => void;\n subscribe: (listener: (ranges: VisibleIndexRanges) => void) => StoreSubscription;\n removeAllListeners: () => void;\n}\n\nexport interface AutoplayController {\n pause: () => void;\n resume: () => void;\n}\n\nexport interface ScrollToOption {\n index: number;\n animated?: boolean;\n}\n\nexport interface CarouselInstance {\n /**\n * Get current visible item index.\n */\n getCurrentIndex: GetCurrentIndex;\n\n /**\n * Scroll to next visible item.\n */\n next: () => void;\n\n /**\n * Scroll to previous visible item.\n */\n prev: () => void;\n\n /**\n * Scroll to desired indexed item.\n * Invalid index is ignored.\n */\n scrollTo: (option: ScrollToOption) => void;\n}\n"],"mappings":"AAGA,MAAMA,UAAU,GAAG,CAAC,MAAD,EAAS,MAAT,EAAiB,MAAjB,CAAnB;AAIA,MAAMC,YAAY,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,aAArB,CAArB"}
@@ -1,137 +1,250 @@
1
- function _extends() { _extends = Object.assign || 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); }
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
2
 
3
3
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
- import { FlatList } from 'react-native';
4
+ import { FlatList, Platform } from 'react-native';
5
5
  import * as R from 'ramda';
6
6
  import ViewerItem from './ViewerItem';
7
-
8
- const getItemHeights = items => R.map(content => content.height)(items);
7
+ import FastScroll from './FastScroll';
9
8
 
10
9
  const appender = (left, right) => [left + right, left + right];
11
10
 
12
- const getHeightAccum = itemHeights => R.mapAccum(appender, 0, itemHeights);
11
+ const getHeightAccum = heights => R.mapAccum(appender, 0, heights);
12
+
13
+ const keyExtractor = item => String(item.index);
14
+
15
+ const createInitialImageState = image => ({
16
+ totalErrorCount: 0,
17
+ dimension: image.dimension,
18
+ tryRenderingMillis: 0,
19
+ urlState: {
20
+ url: image.url,
21
+ validity: 'unknown'
22
+ }
23
+ });
24
+
25
+ const mapImageStateToItemState = (index, imageState, autoHandleErrorCount) => {
26
+ var _imageState$urlState, _imageState$urlState2;
13
27
 
14
- const keyExtractor = item => item.id;
28
+ return {
29
+ index,
30
+ url: (_imageState$urlState = imageState.urlState) === null || _imageState$urlState === void 0 ? void 0 : _imageState$urlState.url,
31
+ imageKey: `${imageState.tryRenderingMillis}-${index}`,
32
+ reloadButtonVisible: ((_imageState$urlState2 = imageState.urlState) === null || _imageState$urlState2 === void 0 ? void 0 : _imageState$urlState2.validity) !== 'valid' && imageState.totalErrorCount >= autoHandleErrorCount,
33
+ dimension: imageState.dimension
34
+ };
35
+ };
15
36
 
37
+ const mapIndexed = R.addIndex(R.map);
38
+ const MAXIMUM_WIDTH = 720;
16
39
  export default function ComicViewer(props) {
17
40
  const {
18
- data,
19
- errorDebounceMillis = 500,
20
- errorRetryCount = 3,
41
+ debounceMillis = 100,
42
+ autoHandleErrorCount = 3,
43
+ fastScrollOptions,
21
44
  initialNumToRender = 1,
22
45
  initialScrollPercentage = 0,
23
46
  itemVisiblePercentThreshold = 0,
47
+ intrinsicImages,
48
+ maxContentWidth = MAXIMUM_WIDTH,
49
+ onItemPress,
50
+ onScroll,
24
51
  onError,
25
- viewerWidth,
52
+ onReloadPress,
53
+ viewportWidth,
54
+ invisiblePaddingTop = 0,
26
55
  windowSize = 3,
27
56
  ...otherProps
28
57
  } = props;
58
+ const fastScrollRef = fastScrollOptions === null || fastScrollOptions === void 0 ? void 0 : fastScrollOptions.ref;
29
59
  const flatListRef = useRef(null);
30
- const errors = useRef(new Map());
31
- const debounceTimeOut = useRef(null);
32
- const resourceString = R.toString(R.map(itemData => itemData.sourceUrl)(data));
33
- const initialItems = R.map(itemData => ({ ...itemData,
34
- isViewable: false,
35
- width: viewerWidth,
36
- height: itemData.height * viewerWidth / itemData.width
37
- }))(data);
38
- const [items, setItems] = useState(initialItems);
39
- const itemHeights = getItemHeights(items);
40
- const itemHeightAccum = getHeightAccum(itemHeights);
60
+ const actualImageWidth = Math.min(viewportWidth, maxContentWidth);
61
+ const initialImageStates = useMemo(() => R.map(createInitialImageState, intrinsicImages), []);
62
+ const imageStatesRef = useRef(initialImageStates);
63
+
64
+ const mapImageStatesToItemStates = imageStates => {
65
+ return imageStates.map((image, index) => mapImageStateToItemState(index, image, autoHandleErrorCount));
66
+ };
67
+
68
+ const [itemStates, setItemStates] = useState(() => {
69
+ return mapImageStatesToItemStates(imageStatesRef.current);
70
+ });
71
+ const renderedDimensions = useMemo(() => {
72
+ return mapIndexed((intrinsicImage, index) => {
73
+ const height = intrinsicImage.dimension.height * actualImageWidth / intrinsicImage.dimension.width + (index === 0 ? invisiblePaddingTop : 0);
74
+ return {
75
+ width: actualImageWidth,
76
+ height: isNaN(height) ? 0 : height
77
+ };
78
+ }, intrinsicImages);
79
+ }, [actualImageWidth]);
80
+ const layoutFromDimensions = useCallback(() => {
81
+ const itemHeights = R.map(dimension => dimension.height, renderedDimensions);
82
+ const [totalHeight, heightAccum] = getHeightAccum(itemHeights);
83
+ const itemOffsets = R.prepend(0, heightAccum);
84
+
85
+ const getItemLayout = (data, index) => ({
86
+ index,
87
+ length: itemHeights[index],
88
+ offset: itemOffsets[index]
89
+ });
90
+
91
+ return {
92
+ totalHeight,
93
+ getItemLayout
94
+ };
95
+ }, [renderedDimensions]);
96
+ const {
97
+ totalHeight,
98
+ getItemLayout
99
+ } = layoutFromDimensions();
41
100
  const viewabilityConfig = useMemo(() => ({
42
101
  itemVisiblePercentThreshold
43
102
  }), [itemVisiblePercentThreshold]);
44
- const getItemLayout = useCallback((data, index) => {
45
- const offsets = R.prepend(0, itemHeightAccum[1]);
46
- return {
47
- length: itemHeights[index],
48
- offset: offsets[index],
49
- index
50
- };
51
- }, [itemHeights]);
52
- const onViewableItemsChanged = useRef(({
53
- viewableItems
54
- }) => {
55
- setItems(prev => {
56
- const viewableItemIds = R.map(viewableItem => viewableItem.item.id)(viewableItems);
57
- return R.map(prevItem => ({ ...prevItem,
58
- isViewable: R.includes(prevItem.id, viewableItemIds)
59
- }))([...prev]);
103
+
104
+ const updateImageState = updateFunction => {
105
+ const prevImageStates = imageStatesRef.current;
106
+ const newImageStates = prevImageStates.map(updateFunction);
107
+ imageStatesRef.current = newImageStates;
108
+ setItemStates(prevItemStates => {
109
+ const newItemStates = mapImageStatesToItemStates(newImageStates);
110
+ return R.equals(prevItemStates, newItemStates) ? prevItemStates : newItemStates;
111
+ });
112
+ };
113
+
114
+ const updateTryRenderingMillis = () => {
115
+ const tryRenderingMillis = new Date().getTime();
116
+ updateImageState((imageState, i) => {
117
+ const urlState = imageState.urlState;
118
+
119
+ if ((urlState === null || urlState === void 0 ? void 0 : urlState.validity) === 'invalid') {
120
+ return { ...imageState,
121
+ tryRenderingMillis
122
+ };
123
+ }
124
+
125
+ return imageState;
60
126
  });
127
+ };
128
+
129
+ const onViewableItemsChanged = useRef(_ref => {
130
+ let {
131
+ viewableItems
132
+ } = _ref;
133
+ updateTryRenderingMillis();
61
134
  });
135
+ const handleScroll = useCallback(event => {
136
+ var _fastScrollRef$curren;
62
137
 
63
- const onErrorHandler = errors => {
64
- const isRetryLimited = R.any(error => error.count >= errorRetryCount)(errors);
138
+ fastScrollRef === null || fastScrollRef === void 0 ? void 0 : (_fastScrollRef$curren = fastScrollRef.current) === null || _fastScrollRef$curren === void 0 ? void 0 : _fastScrollRef$curren.onContentScroll(event);
139
+ onScroll === null || onScroll === void 0 ? void 0 : onScroll(event);
140
+ }, [onScroll]);
65
141
 
66
- if (isRetryLimited) {
67
- return;
68
- }
142
+ const scrollContentToOffset = offset => {
143
+ var _flatListRef$current;
69
144
 
70
- onError && onError(errors);
145
+ (_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 ? void 0 : _flatListRef$current.scrollToOffset({
146
+ offset,
147
+ animated: false
148
+ });
71
149
  };
72
150
 
73
- const itemErrorHandler = useCallback(errorInfo => {
74
- errors.current.set(errorInfo.id, errorInfo.count);
151
+ const renderItem = useCallback(_ref2 => {
152
+ var _renderedDimensions$i, _renderedDimensions$i2;
75
153
 
76
- if (debounceTimeOut.current) {
77
- clearTimeout(debounceTimeOut.current);
78
- }
154
+ let {
155
+ item,
156
+ index
157
+ } = _ref2;
158
+
159
+ const handleError = () => {
160
+ onError && onError();
161
+ updateImageState((imageState, i) => {
162
+ const urlState = imageState.urlState;
79
163
 
80
- debounceTimeOut.current = setTimeout(function () {
81
- const errorsArray = Array.from(errors.current.entries());
82
- const errorsInfo = R.map(([key, value]) => ({
83
- id: key,
84
- count: value
85
- }))(errorsArray);
86
- onErrorHandler([...errorsInfo]);
87
- errors.current.clear();
88
- }, errorDebounceMillis);
89
- }, [errorDebounceMillis, errors.current]);
90
- const renderItem = useCallback(({
91
- item
92
- }) => {
93
- const props = { ...item,
94
- onError: itemErrorHandler
164
+ if (i === index) {
165
+ return { ...imageState,
166
+ totalErrorCount: imageState.totalErrorCount + 1,
167
+ urlState: { ...urlState,
168
+ validity: 'invalid'
169
+ }
170
+ };
171
+ }
172
+
173
+ return imageState;
174
+ });
175
+
176
+ if (item.reloadButtonVisible) {
177
+ return;
178
+ }
179
+
180
+ updateTryRenderingMillis();
95
181
  };
96
- return /*#__PURE__*/React.createElement(ViewerItem, {
97
- props: props
98
- });
99
- }, []);
100
- useEffect(() => {
101
- setItems(prev => {
102
- return R.map(prevItem => {
103
- const currentData = R.find(currentItemData => prevItem.id === currentItemData.id)(data);
104
182
 
105
- if (currentData && currentData.sourceUrl !== prevItem.sourceUrl) {
106
- return { ...prevItem,
107
- sourceUrl: currentData.sourceUrl
183
+ const handleReloadPress = () => {
184
+ onReloadPress && onReloadPress();
185
+ updateTryRenderingMillis();
186
+ };
187
+
188
+ const onLoad = () => {
189
+ updateImageState((imageState, i) => {
190
+ const urlState = imageState.urlState;
191
+
192
+ if (i === index && urlState !== undefined) {
193
+ return { ...imageState,
194
+ urlState: { ...urlState,
195
+ validity: 'valid'
196
+ }
108
197
  };
109
198
  }
110
199
 
111
- return prevItem;
112
- })([...prev]);
200
+ return imageState;
201
+ });
202
+ };
203
+
204
+ return /*#__PURE__*/React.createElement(ViewerItem, {
205
+ onError: handleError,
206
+ onLoad: onLoad,
207
+ onPress: onItemPress,
208
+ onReloadPress: handleReloadPress,
209
+ url: item.url,
210
+ imageKey: item.imageKey,
211
+ invisiblePaddingTop: index === 0 ? invisiblePaddingTop : 0,
212
+ width: ((_renderedDimensions$i = renderedDimensions[index]) === null || _renderedDimensions$i === void 0 ? void 0 : _renderedDimensions$i.width) ?? 0,
213
+ height: ((_renderedDimensions$i2 = renderedDimensions[index]) === null || _renderedDimensions$i2 === void 0 ? void 0 : _renderedDimensions$i2.height) ?? 0,
214
+ reloadButtonVisible: item.reloadButtonVisible
113
215
  });
114
- }, [resourceString]);
115
- useEffect(() => {
116
- const newItems = R.map(item => ({ ...item,
117
- width: viewerWidth,
118
- height: item.height * viewerWidth / item.width
119
- }))(items);
120
- setItems(newItems);
121
- }, [viewerWidth]);
216
+ }, [onItemPress, renderedDimensions]);
122
217
  useEffect(() => {
123
- const totalHeight = itemHeightAccum[0];
124
- const offset = Math.floor(initialScrollPercentage / 100 * totalHeight);
218
+ const scroll = () => {
219
+ const offset = Math.floor(initialScrollPercentage / 100 * totalHeight);
125
220
 
126
- if (flatListRef.current) {
127
- flatListRef.current.scrollToOffset({
128
- offset,
129
- animated: false
130
- });
221
+ if (flatListRef.current) {
222
+ flatListRef.current.scrollToOffset({
223
+ offset,
224
+ animated: false
225
+ });
226
+ }
227
+ };
228
+
229
+ let timeoutId = undefined;
230
+ /**
231
+ * @FIXME
232
+ * scrollToOffset has issue(no effect) in useEffect hook on iOS.
233
+ * ref: https://github.com/facebook/react-native/issues/35575
234
+ */
235
+
236
+ if (Platform.OS === 'ios') {
237
+ timeoutId = setTimeout(scroll, 0);
238
+ } else {
239
+ scroll();
131
240
  }
132
- }, [flatListRef.current]);
133
- return /*#__PURE__*/React.createElement(FlatList, _extends({
134
- data: items,
241
+
242
+ return () => {
243
+ timeoutId && clearTimeout(timeoutId);
244
+ };
245
+ }, []);
246
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FlatList, _extends({
247
+ data: itemStates,
135
248
  getItemLayout: getItemLayout,
136
249
  initialNumToRender: initialNumToRender,
137
250
  keyExtractor: keyExtractor,
@@ -139,8 +252,13 @@ export default function ComicViewer(props) {
139
252
  ref: flatListRef,
140
253
  renderItem: renderItem,
141
254
  viewabilityConfig: viewabilityConfig,
142
- windowSize: windowSize
143
- }, otherProps));
255
+ windowSize: windowSize,
256
+ onScroll: handleScroll
257
+ }, otherProps)), /*#__PURE__*/React.createElement(FastScroll, _extends({}, fastScrollOptions, {
258
+ contentLength: totalHeight,
259
+ initialScrollPercentage: initialScrollPercentage,
260
+ scrollContentToOffset: scrollContentToOffset
261
+ })));
144
262
  }
145
263
  ;
146
264
  //# sourceMappingURL=ComicViewer.js.map