@fountain-ui/lab 2.0.0-beta.7 → 2.0.0-beta.71

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 (481) hide show
  1. package/build/commonjs/AnimatedY/AnimatedY.js +8 -10
  2. package/build/commonjs/AnimatedY/AnimatedY.js.map +1 -1
  3. package/build/commonjs/BottomSheet/BottomSheetNative.js +65 -7
  4. package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
  5. package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
  6. package/build/commonjs/BottomSheet/BottomSheetWeb.js +41 -13
  7. package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
  8. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js +65 -0
  9. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js.map +1 -0
  10. package/build/commonjs/Carousel/Carousel.js +130 -0
  11. package/build/commonjs/Carousel/Carousel.js.map +1 -0
  12. package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
  13. package/build/commonjs/Carousel/animation/animationUtils.js +9 -0
  14. package/build/commonjs/Carousel/animation/animationUtils.js.map +1 -0
  15. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js +15 -0
  16. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  17. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +26 -0
  18. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  19. package/build/commonjs/Carousel/animation/index.js +40 -0
  20. package/build/commonjs/Carousel/animation/index.js.map +1 -0
  21. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js +27 -0
  22. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  23. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +65 -0
  24. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  25. package/build/commonjs/Carousel/components/InternalContext.js +29 -0
  26. package/build/commonjs/Carousel/components/InternalContext.js.map +1 -0
  27. package/build/commonjs/Carousel/components/ItemView.js +66 -0
  28. package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
  29. package/build/commonjs/Carousel/components/RootView.js +86 -0
  30. package/build/commonjs/Carousel/components/RootView.js.map +1 -0
  31. package/build/commonjs/Carousel/components/ScrollViewGesture.js +84 -0
  32. package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -0
  33. package/build/commonjs/Carousel/components/index.js +40 -0
  34. package/build/commonjs/Carousel/components/index.js.map +1 -0
  35. package/build/commonjs/Carousel/components/useItemInterpolation.js +65 -0
  36. package/build/commonjs/Carousel/components/useItemInterpolation.js.map +1 -0
  37. package/build/commonjs/Carousel/hooks/index.js +48 -0
  38. package/build/commonjs/Carousel/hooks/index.js.map +1 -0
  39. package/build/commonjs/Carousel/hooks/useAutoplayController.js +58 -0
  40. package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
  41. package/build/commonjs/Carousel/hooks/useIndexController.js +55 -0
  42. package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
  43. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +95 -0
  44. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  45. package/build/commonjs/Carousel/hooks/useLoopedData.js +33 -0
  46. package/build/commonjs/Carousel/hooks/useLoopedData.js.map +1 -0
  47. package/build/commonjs/Carousel/hooks/usePagingAnimator.js +202 -0
  48. package/build/commonjs/Carousel/hooks/usePagingAnimator.js.map +1 -0
  49. package/build/commonjs/Carousel/index.js +16 -2
  50. package/build/commonjs/Carousel/index.js.map +1 -1
  51. package/build/commonjs/Carousel/tick.js +16 -0
  52. package/build/commonjs/Carousel/tick.js.map +1 -0
  53. package/build/commonjs/Carousel/types.js +8 -0
  54. package/build/commonjs/Carousel/types.js.map +1 -0
  55. package/build/commonjs/ComicViewer/ComicViewer.js +230 -92
  56. package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
  57. package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
  58. package/build/commonjs/ComicViewer/EncodedTile.js +10 -0
  59. package/build/commonjs/ComicViewer/EncodedTile.js.map +1 -0
  60. package/build/commonjs/ComicViewer/FastScroll.js +175 -0
  61. package/build/commonjs/ComicViewer/FastScroll.js.map +1 -0
  62. package/build/commonjs/ComicViewer/{ComicViewerItemProps.js → FastScrollProps.js} +1 -1
  63. package/build/commonjs/ComicViewer/FastScrollProps.js.map +1 -0
  64. package/build/commonjs/ComicViewer/ReloadButton.js +48 -0
  65. package/build/commonjs/ComicViewer/ReloadButton.js.map +1 -0
  66. package/build/commonjs/ComicViewer/ViewerItem.js +53 -59
  67. package/build/commonjs/ComicViewer/ViewerItem.js.map +1 -1
  68. package/build/commonjs/ComicViewer/index.js.map +1 -1
  69. package/build/commonjs/ComicViewer/util.js +27 -0
  70. package/build/commonjs/ComicViewer/util.js.map +1 -0
  71. package/build/commonjs/DateTimePicker/DateTimePicker.js +10 -1
  72. package/build/commonjs/DateTimePicker/DateTimePicker.js.map +1 -1
  73. package/build/commonjs/FlipCard/FlipCard.js +2 -2
  74. package/build/commonjs/FlipCard/FlipCard.js.map +1 -1
  75. package/build/commonjs/ViewPager/FluxContext.js +13 -0
  76. package/build/commonjs/ViewPager/FluxContext.js.map +1 -0
  77. package/build/commonjs/ViewPager/InternalContext.js +17 -0
  78. package/build/commonjs/ViewPager/InternalContext.js.map +1 -0
  79. package/build/commonjs/ViewPager/PageStateContext.js +16 -0
  80. package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
  81. package/build/commonjs/ViewPager/ViewPager.js +81 -0
  82. package/build/commonjs/ViewPager/ViewPager.js.map +1 -0
  83. package/build/commonjs/ViewPager/ViewPager.native.js +152 -0
  84. package/build/commonjs/ViewPager/ViewPager.native.js.map +1 -0
  85. package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
  86. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js +122 -0
  87. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  88. package/build/commonjs/ViewPager/components/FluxStoreProvider.js +37 -0
  89. package/build/commonjs/ViewPager/components/FluxStoreProvider.js.map +1 -0
  90. package/build/commonjs/ViewPager/components/index.js +24 -0
  91. package/build/commonjs/ViewPager/components/index.js.map +1 -0
  92. package/build/commonjs/ViewPager/hooks/index.js +64 -0
  93. package/build/commonjs/ViewPager/hooks/index.js.map +1 -0
  94. package/build/commonjs/ViewPager/hooks/useDispatch.js +22 -0
  95. package/build/commonjs/ViewPager/hooks/useDispatch.js.map +1 -0
  96. package/build/commonjs/ViewPager/hooks/useEagerState.js +24 -0
  97. package/build/commonjs/ViewPager/hooks/useEagerState.js.map +1 -0
  98. package/build/commonjs/ViewPager/hooks/useForceRender.js +16 -0
  99. package/build/commonjs/ViewPager/hooks/useForceRender.js.map +1 -0
  100. package/build/commonjs/ViewPager/hooks/useLazyState.js +45 -0
  101. package/build/commonjs/ViewPager/hooks/useLazyState.js.map +1 -0
  102. package/build/commonjs/ViewPager/hooks/usePageStore.js +35 -0
  103. package/build/commonjs/ViewPager/hooks/usePageStore.js.map +1 -0
  104. package/build/commonjs/ViewPager/hooks/useStore.js +26 -0
  105. package/build/commonjs/ViewPager/hooks/useStore.js.map +1 -0
  106. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js +19 -0
  107. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  108. package/build/commonjs/ViewPager/index.js +42 -2
  109. package/build/commonjs/ViewPager/index.js.map +1 -1
  110. package/build/commonjs/ViewPager/types.js +2 -0
  111. package/build/commonjs/ViewPager/types.js.map +1 -0
  112. package/build/commonjs/ViewPager/utils.js +12 -45
  113. package/build/commonjs/ViewPager/utils.js.map +1 -1
  114. package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
  115. package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
  116. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
  117. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  118. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  119. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  120. package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
  121. package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
  122. package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
  123. package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
  124. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
  125. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  126. package/build/commonjs/hooks/index.js +16 -0
  127. package/build/commonjs/hooks/index.js.map +1 -1
  128. package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
  129. package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
  130. package/build/commonjs/hooks/useHeight.js +4 -4
  131. package/build/commonjs/hooks/useHeight.js.map +1 -1
  132. package/build/commonjs/hooks/useIsMounted.js +22 -0
  133. package/build/commonjs/hooks/useIsMounted.js.map +1 -0
  134. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +41 -31
  135. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  136. package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js +2 -2
  137. package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
  138. package/build/commonjs/index.js +22 -1
  139. package/build/commonjs/index.js.map +1 -1
  140. package/build/module/AnimatedY/AnimatedY.js +8 -7
  141. package/build/module/AnimatedY/AnimatedY.js.map +1 -1
  142. package/build/module/BottomSheet/BottomSheetNative.js +64 -9
  143. package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
  144. package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
  145. package/build/module/BottomSheet/BottomSheetWeb.js +40 -14
  146. package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
  147. package/build/module/BottomSheet/useDynamicSnapPoints.js +52 -0
  148. package/build/module/BottomSheet/useDynamicSnapPoints.js.map +1 -0
  149. package/build/module/Carousel/Carousel.js +109 -0
  150. package/build/module/Carousel/Carousel.js.map +1 -0
  151. package/build/module/Carousel/CarouselProps.js.map +1 -1
  152. package/build/module/Carousel/animation/animationUtils.js +2 -0
  153. package/build/module/Carousel/animation/animationUtils.js.map +1 -0
  154. package/build/module/Carousel/animation/createDefaultItemStyle.js +3 -0
  155. package/build/module/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  156. package/build/module/Carousel/animation/createDefaultScrollAnimation.js +12 -0
  157. package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  158. package/build/module/Carousel/animation/index.js +5 -0
  159. package/build/module/Carousel/animation/index.js.map +1 -0
  160. package/build/module/Carousel/animation/normalItemStyleFactory.js +18 -0
  161. package/build/module/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  162. package/build/module/Carousel/animation/parallaxItemStyleFactory.js +55 -0
  163. package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  164. package/build/module/Carousel/components/InternalContext.js +19 -0
  165. package/build/module/Carousel/components/InternalContext.js.map +1 -0
  166. package/build/module/Carousel/components/ItemView.js +46 -0
  167. package/build/module/Carousel/components/ItemView.js.map +1 -0
  168. package/build/module/Carousel/components/RootView.js +65 -0
  169. package/build/module/Carousel/components/RootView.js.map +1 -0
  170. package/build/module/Carousel/components/ScrollViewGesture.js +69 -0
  171. package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -0
  172. package/build/module/Carousel/components/index.js +5 -0
  173. package/build/module/Carousel/components/index.js.map +1 -0
  174. package/build/module/Carousel/components/useItemInterpolation.js +51 -0
  175. package/build/module/Carousel/components/useItemInterpolation.js.map +1 -0
  176. package/build/module/Carousel/hooks/index.js +6 -0
  177. package/build/module/Carousel/hooks/index.js.map +1 -0
  178. package/build/module/Carousel/hooks/useAutoplayController.js +48 -0
  179. package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
  180. package/build/module/Carousel/hooks/useIndexController.js +44 -0
  181. package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
  182. package/build/module/Carousel/hooks/useItemVisibilityStore.js +86 -0
  183. package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  184. package/build/module/Carousel/hooks/useLoopedData.js +24 -0
  185. package/build/module/Carousel/hooks/useLoopedData.js.map +1 -0
  186. package/build/module/Carousel/hooks/usePagingAnimator.js +192 -0
  187. package/build/module/Carousel/hooks/usePagingAnimator.js.map +1 -0
  188. package/build/module/Carousel/index.js +2 -1
  189. package/build/module/Carousel/index.js.map +1 -1
  190. package/build/module/Carousel/tick.js +6 -0
  191. package/build/module/Carousel/tick.js.map +1 -0
  192. package/build/module/Carousel/types.js +4 -0
  193. package/build/module/Carousel/types.js.map +1 -0
  194. package/build/module/ComicViewer/ComicViewer.js +229 -93
  195. package/build/module/ComicViewer/ComicViewer.js.map +1 -1
  196. package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
  197. package/build/module/ComicViewer/EncodedTile.js +3 -0
  198. package/build/module/ComicViewer/EncodedTile.js.map +1 -0
  199. package/build/module/ComicViewer/FastScroll.js +152 -0
  200. package/build/module/ComicViewer/FastScroll.js.map +1 -0
  201. package/build/module/ComicViewer/FastScrollProps.js +2 -0
  202. package/build/module/ComicViewer/FastScrollProps.js.map +1 -0
  203. package/build/module/ComicViewer/ReloadButton.js +33 -0
  204. package/build/module/ComicViewer/ReloadButton.js.map +1 -0
  205. package/build/module/ComicViewer/ViewerItem.js +53 -60
  206. package/build/module/ComicViewer/ViewerItem.js.map +1 -1
  207. package/build/module/ComicViewer/index.js.map +1 -1
  208. package/build/module/ComicViewer/util.js +15 -0
  209. package/build/module/ComicViewer/util.js.map +1 -0
  210. package/build/module/DateTimePicker/DateTimePicker.js +11 -2
  211. package/build/module/DateTimePicker/DateTimePicker.js.map +1 -1
  212. package/build/module/FlipCard/FlipCard.js +2 -2
  213. package/build/module/FlipCard/FlipCard.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 +7 -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 +30 -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 +40 -24
  274. package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  275. package/build/module/hooks/useUnstableToggleDisplayStyle.js +2 -2
  276. package/build/module/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
  277. package/build/module/index.js +2 -0
  278. package/build/module/index.js.map +1 -1
  279. package/build/typescript/AnimatedY/AnimatedY.d.ts +1 -0
  280. package/build/typescript/BottomSheet/BottomSheetNative.d.ts +1 -0
  281. package/build/typescript/BottomSheet/BottomSheetProps.d.ts +32 -1
  282. package/build/typescript/BottomSheet/BottomSheetWeb.d.ts +1 -0
  283. package/build/typescript/BottomSheet/TransparentBackdrop.d.ts +1 -0
  284. package/build/typescript/BottomSheet/useDynamicSnapPoints.d.ts +12 -0
  285. package/build/typescript/Carousel/Carousel.d.ts +5 -0
  286. package/build/typescript/Carousel/CarouselProps.d.ts +33 -48
  287. package/build/typescript/Carousel/animation/animationUtils.d.ts +1 -0
  288. package/build/typescript/Carousel/animation/createDefaultItemStyle.d.ts +2 -0
  289. package/build/typescript/Carousel/animation/createDefaultScrollAnimation.d.ts +2 -0
  290. package/build/typescript/Carousel/animation/index.d.ts +4 -0
  291. package/build/typescript/Carousel/animation/normalItemStyleFactory.d.ts +2 -0
  292. package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +9 -0
  293. package/build/typescript/Carousel/components/InternalContext.d.ts +14 -0
  294. package/build/typescript/Carousel/components/ItemView.d.ts +9 -0
  295. package/build/typescript/Carousel/components/RootView.d.ts +16 -0
  296. package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +12 -0
  297. package/build/typescript/Carousel/components/index.d.ts +4 -0
  298. package/build/typescript/Carousel/components/useItemInterpolation.d.ts +2 -0
  299. package/build/typescript/Carousel/hooks/index.d.ts +5 -0
  300. package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
  301. package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
  302. package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +7 -0
  303. package/build/typescript/Carousel/hooks/useLoopedData.d.ts +1 -0
  304. package/build/typescript/Carousel/hooks/usePagingAnimator.d.ts +17 -0
  305. package/build/typescript/Carousel/index.d.ts +3 -1
  306. package/build/typescript/Carousel/tick.d.ts +2 -0
  307. package/build/typescript/Carousel/types.d.ts +91 -0
  308. package/build/typescript/ComicViewer/ComicViewer.d.ts +2 -1
  309. package/build/typescript/ComicViewer/ComicViewerProps.d.ts +61 -43
  310. package/build/typescript/ComicViewer/EncodedTile.d.ts +2 -0
  311. package/build/typescript/ComicViewer/FastScroll.d.ts +4 -0
  312. package/build/typescript/ComicViewer/FastScrollProps.d.ts +74 -0
  313. package/build/typescript/ComicViewer/ReloadButton.d.ts +7 -0
  314. package/build/typescript/ComicViewer/ViewerItem.d.ts +46 -7
  315. package/build/typescript/ComicViewer/index.d.ts +3 -2
  316. package/build/typescript/ComicViewer/util.d.ts +2 -0
  317. package/build/typescript/DateTimePicker/DateTimePicker.d.ts +1 -0
  318. package/build/typescript/DateTimePicker/YearPicker.d.ts +1 -0
  319. package/build/typescript/FlipCard/FlipCard.d.ts +1 -0
  320. package/build/typescript/StatusBarProvider/StatusBarProvider.d.ts +1 -0
  321. package/build/typescript/ViewPager/FluxContext.d.ts +5 -0
  322. package/build/typescript/ViewPager/InternalContext.d.ts +7 -0
  323. package/build/typescript/ViewPager/PageStateContext.d.ts +6 -0
  324. package/build/typescript/ViewPager/ViewPager.d.ts +5 -0
  325. package/build/typescript/ViewPager/ViewPager.native.d.ts +5 -0
  326. package/build/typescript/ViewPager/ViewPagerProps.d.ts +21 -27
  327. package/build/typescript/ViewPager/components/ChildrenMemoizedPage.d.ts +14 -0
  328. package/build/typescript/ViewPager/components/FluxStoreProvider.d.ts +6 -0
  329. package/build/typescript/ViewPager/components/index.d.ts +2 -0
  330. package/build/typescript/ViewPager/hooks/index.d.ts +7 -0
  331. package/build/typescript/ViewPager/hooks/useDispatch.d.ts +2 -0
  332. package/build/typescript/ViewPager/hooks/useEagerState.d.ts +1 -0
  333. package/build/typescript/ViewPager/hooks/useForceRender.d.ts +2 -0
  334. package/build/typescript/ViewPager/hooks/useLazyState.d.ts +2 -0
  335. package/build/typescript/ViewPager/hooks/usePageStore.d.ts +2 -0
  336. package/build/typescript/ViewPager/hooks/useStore.d.ts +2 -0
  337. package/build/typescript/ViewPager/hooks/useViewPagerPageState.d.ts +1 -0
  338. package/build/typescript/ViewPager/index.d.ts +4 -1
  339. package/build/typescript/ViewPager/types.d.ts +12 -0
  340. package/build/typescript/ViewPager/utils.d.ts +5 -20
  341. package/build/typescript/ViewabilityTrackerView/Viewability.d.ts +3 -0
  342. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +3 -0
  343. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerViewProps.d.ts +22 -0
  344. package/build/typescript/ViewabilityTrackerView/index.d.ts +2 -0
  345. package/build/typescript/ViewabilityTrackerView/measureViewability.d.ts +11 -0
  346. package/build/typescript/ViewabilityTrackerView/useViewabilityTracker.d.ts +11 -0
  347. package/build/typescript/hooks/index.d.ts +2 -0
  348. package/build/typescript/hooks/useDeferredExecutor.d.ts +11 -0
  349. package/build/typescript/hooks/useIsMounted.d.ts +4 -0
  350. package/build/typescript/index.d.ts +2 -0
  351. package/package.json +10 -25
  352. package/src/AnimatedY/AnimatedY.tsx +10 -7
  353. package/src/BottomSheet/BottomSheetNative.tsx +68 -6
  354. package/src/BottomSheet/BottomSheetProps.ts +38 -1
  355. package/src/BottomSheet/BottomSheetWeb.tsx +54 -16
  356. package/src/BottomSheet/useDynamicSnapPoints.ts +73 -0
  357. package/src/Carousel/Carousel.tsx +135 -0
  358. package/src/Carousel/CarouselProps.ts +42 -53
  359. package/src/Carousel/animation/animationUtils.ts +1 -0
  360. package/src/Carousel/animation/createDefaultItemStyle.ts +3 -0
  361. package/src/Carousel/animation/createDefaultScrollAnimation.ts +14 -0
  362. package/src/Carousel/animation/index.ts +4 -0
  363. package/src/Carousel/animation/normalItemStyleFactory.ts +19 -0
  364. package/src/Carousel/animation/parallaxItemStyleFactory.ts +79 -0
  365. package/src/Carousel/components/InternalContext.ts +33 -0
  366. package/src/Carousel/components/ItemView.tsx +66 -0
  367. package/src/Carousel/components/RootView.tsx +79 -0
  368. package/src/Carousel/components/ScrollViewGesture.tsx +93 -0
  369. package/src/Carousel/components/index.ts +4 -0
  370. package/src/Carousel/components/useItemInterpolation.ts +107 -0
  371. package/src/Carousel/hooks/index.ts +5 -0
  372. package/src/Carousel/hooks/useAutoplayController.ts +57 -0
  373. package/src/Carousel/hooks/useIndexController.tsx +57 -0
  374. package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
  375. package/src/Carousel/hooks/useLoopedData.ts +26 -0
  376. package/src/Carousel/hooks/usePagingAnimator.ts +255 -0
  377. package/src/Carousel/index.ts +4 -2
  378. package/src/Carousel/tick.ts +6 -0
  379. package/src/Carousel/types.ts +114 -0
  380. package/src/ComicViewer/ComicViewer.tsx +268 -106
  381. package/src/ComicViewer/ComicViewerProps.ts +66 -44
  382. package/src/ComicViewer/EncodedTile.ts +3 -0
  383. package/src/ComicViewer/FastScroll.tsx +176 -0
  384. package/src/ComicViewer/FastScrollProps.ts +88 -0
  385. package/src/ComicViewer/ReloadButton.tsx +36 -0
  386. package/src/ComicViewer/ViewerItem.tsx +104 -62
  387. package/src/ComicViewer/index.ts +8 -2
  388. package/src/ComicViewer/util.ts +15 -0
  389. package/src/DateTimePicker/DateTimePicker.tsx +9 -1
  390. package/src/FlipCard/FlipCard.tsx +2 -2
  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 +38 -23
  422. package/src/hooks/useUnstableToggleDisplayStyle.ts +2 -1
  423. package/src/index.ts +3 -0
  424. package/build/commonjs/Carousel/CarouselNative.js +0 -72
  425. package/build/commonjs/Carousel/CarouselNative.js.map +0 -1
  426. package/build/commonjs/Carousel/CarouselWeb.js +0 -237
  427. package/build/commonjs/Carousel/CarouselWeb.js.map +0 -1
  428. package/build/commonjs/Carousel/index.native.js.map +0 -1
  429. package/build/commonjs/Carousel/utils.js +0 -19
  430. package/build/commonjs/Carousel/utils.js.map +0 -1
  431. package/build/commonjs/ComicViewer/ComicViewerItemProps.js.map +0 -1
  432. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +0 -49
  433. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  434. package/build/commonjs/ViewPager/ViewPagerNative.js +0 -72
  435. package/build/commonjs/ViewPager/ViewPagerNative.js.map +0 -1
  436. package/build/commonjs/ViewPager/ViewPagerWeb.js +0 -55
  437. package/build/commonjs/ViewPager/ViewPagerWeb.js.map +0 -1
  438. package/build/commonjs/ViewPager/index.native.js +0 -16
  439. package/build/commonjs/ViewPager/index.native.js.map +0 -1
  440. package/build/commonjs/hooks/useWidth.js +0 -29
  441. package/build/commonjs/hooks/useWidth.js.map +0 -1
  442. package/build/module/Carousel/CarouselNative.js +0 -54
  443. package/build/module/Carousel/CarouselNative.js.map +0 -1
  444. package/build/module/Carousel/CarouselWeb.js +0 -215
  445. package/build/module/Carousel/CarouselWeb.js.map +0 -1
  446. package/build/module/Carousel/index.native.js +0 -2
  447. package/build/module/Carousel/index.native.js.map +0 -1
  448. package/build/module/Carousel/utils.js +0 -7
  449. package/build/module/Carousel/utils.js.map +0 -1
  450. package/build/module/ComicViewer/ComicViewerItemProps.js +0 -2
  451. package/build/module/ComicViewer/ComicViewerItemProps.js.map +0 -1
  452. package/build/module/ViewPager/ChildrenMemoizedPage.js +0 -37
  453. package/build/module/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  454. package/build/module/ViewPager/ViewPagerNative.js +0 -53
  455. package/build/module/ViewPager/ViewPagerNative.js.map +0 -1
  456. package/build/module/ViewPager/ViewPagerWeb.js +0 -41
  457. package/build/module/ViewPager/ViewPagerWeb.js.map +0 -1
  458. package/build/module/ViewPager/index.native.js +0 -2
  459. package/build/module/ViewPager/index.native.js.map +0 -1
  460. package/build/module/hooks/useWidth.js +0 -15
  461. package/build/module/hooks/useWidth.js.map +0 -1
  462. package/build/typescript/Carousel/CarouselNative.d.ts +0 -2
  463. package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
  464. package/build/typescript/Carousel/index.native.d.ts +0 -1
  465. package/build/typescript/Carousel/utils.d.ts +0 -6
  466. package/build/typescript/ComicViewer/ComicViewerItemProps.d.ts +0 -12
  467. package/build/typescript/ViewPager/ChildrenMemoizedPage.d.ts +0 -4
  468. package/build/typescript/ViewPager/ViewPagerNative.d.ts +0 -2
  469. package/build/typescript/ViewPager/ViewPagerWeb.d.ts +0 -2
  470. package/build/typescript/ViewPager/index.native.d.ts +0 -1
  471. package/build/typescript/hooks/useWidth.d.ts +0 -2
  472. package/src/Carousel/CarouselNative.tsx +0 -67
  473. package/src/Carousel/CarouselWeb.tsx +0 -222
  474. package/src/Carousel/index.native.ts +0 -1
  475. package/src/Carousel/utils.ts +0 -11
  476. package/src/ComicViewer/ComicViewerItemProps.ts +0 -15
  477. package/src/ViewPager/ChildrenMemoizedPage.tsx +0 -36
  478. package/src/ViewPager/ViewPagerNative.tsx +0 -66
  479. package/src/ViewPager/ViewPagerWeb.tsx +0 -52
  480. package/src/ViewPager/index.native.ts +0 -1
  481. package/src/hooks/useWidth.ts +0 -17
@@ -0,0 +1,33 @@
1
+ import { useCallback, useEffect, useRef } from 'react';
2
+ import useIsMounted from './useIsMounted';
3
+ export default function useDeferredExecutor() {
4
+ const isMounted = useIsMounted();
5
+ const timeoutIdRef = useRef(null);
6
+ const cancel = useCallback(() => {
7
+ if (timeoutIdRef.current) {
8
+ clearTimeout(timeoutIdRef.current);
9
+ }
10
+ }, []);
11
+ useEffect(() => {
12
+ return cancel;
13
+ }, []);
14
+ const execute = useCallback((runnable, delay) => {
15
+ if (!isMounted()) {
16
+ return;
17
+ }
18
+
19
+ cancel();
20
+
21
+ if (Number.isFinite(delay)) {
22
+ timeoutIdRef.current = setTimeout(() => runnable(), delay);
23
+ } else {
24
+ runnable();
25
+ }
26
+ }, []);
27
+ return {
28
+ cancel,
29
+ execute
30
+ };
31
+ }
32
+ ;
33
+ //# sourceMappingURL=useDeferredExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useEffect","useRef","useIsMounted","useDeferredExecutor","isMounted","timeoutIdRef","cancel","current","clearTimeout","execute","runnable","delay","Number","isFinite","setTimeout"],"sources":["useDeferredExecutor.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport useIsMounted from './useIsMounted';\n\nexport interface Runnable {\n (): void;\n}\n\nexport interface DeferredExecute {\n (runnable: Runnable, delay?: number): void;\n}\n\nexport interface DeferredExecutor {\n cancel: () => void;\n execute: DeferredExecute;\n}\n\nexport default function useDeferredExecutor(): DeferredExecutor {\n const isMounted = useIsMounted();\n const timeoutIdRef = useRef<NodeJS.Timer | null>(null);\n\n const cancel = useCallback(() => {\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n }\n }, []);\n\n useEffect(() => {\n return cancel;\n }, []);\n\n const execute = useCallback<DeferredExecute>((runnable, delay) => {\n if (!isMounted()) {\n return;\n }\n\n cancel();\n\n if (Number.isFinite(delay)) {\n timeoutIdRef.current = setTimeout(() => runnable(), delay);\n } else {\n runnable();\n }\n }, []);\n\n return { cancel, execute };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAeA,eAAe,SAASC,mBAAT,GAAiD;EAC5D,MAAMC,SAAS,GAAGF,YAAY,EAA9B;EACA,MAAMG,YAAY,GAAGJ,MAAM,CAAsB,IAAtB,CAA3B;EAEA,MAAMK,MAAM,GAAGP,WAAW,CAAC,MAAM;IAC7B,IAAIM,YAAY,CAACE,OAAjB,EAA0B;MACtBC,YAAY,CAACH,YAAY,CAACE,OAAd,CAAZ;IACH;EACJ,CAJyB,EAIvB,EAJuB,CAA1B;EAMAP,SAAS,CAAC,MAAM;IACZ,OAAOM,MAAP;EACH,CAFQ,EAEN,EAFM,CAAT;EAIA,MAAMG,OAAO,GAAGV,WAAW,CAAkB,CAACW,QAAD,EAAWC,KAAX,KAAqB;IAC9D,IAAI,CAACP,SAAS,EAAd,EAAkB;MACd;IACH;;IAEDE,MAAM;;IAEN,IAAIM,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAAJ,EAA4B;MACxBN,YAAY,CAACE,OAAb,GAAuBO,UAAU,CAAC,MAAMJ,QAAQ,EAAf,EAAmBC,KAAnB,CAAjC;IACH,CAFD,MAEO;MACHD,QAAQ;IACX;EACJ,CAZ0B,EAYxB,EAZwB,CAA3B;EAcA,OAAO;IAAEJ,MAAF;IAAUG;EAAV,CAAP;AACH;AAAA"}
@@ -1,9 +1,8 @@
1
- import React from 'react';
2
- import { useWorkletCallback } from 'react-native-reanimated';
1
+ import React, { useCallback } from 'react';
3
2
  export default function useHeight() {
4
3
  let initialHeight = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
5
4
  const [height, setHeight] = React.useState(initialHeight);
6
- const onLayout = useWorkletCallback(e => {
5
+ const onLayout = useCallback(e => {
7
6
  setHeight(e.nativeEvent.layout.height);
8
7
  }, []);
9
8
  return [height, onLayout];
@@ -1 +1 @@
1
- {"version":3,"names":["React","useWorkletCallback","useHeight","initialHeight","height","setHeight","useState","onLayout","e","nativeEvent","layout"],"sources":["useHeight.ts"],"sourcesContent":["import React from 'react';\nimport { ViewProps } from 'react-native';\nimport { useWorkletCallback } from 'react-native-reanimated';\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport default function useHeight(initialHeight = 0): [number, OnLayoutCallback] {\n const [height, setHeight] = React.useState<number>(initialHeight);\n\n const onLayout = useWorkletCallback((e) => {\n setHeight(e.nativeEvent.layout.height);\n }, []);\n\n return [height, onLayout];\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,kBAAT,QAAmC,yBAAnC;AAIA,eAAe,SAASC,SAAT,GAAkE;EAAA,IAA/CC,aAA+C,uEAA/B,CAA+B;EAC7E,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBL,KAAK,CAACM,QAAN,CAAuBH,aAAvB,CAA5B;EAEA,MAAMI,QAAQ,GAAGN,kBAAkB,CAAEO,CAAD,IAAO;IACvCH,SAAS,CAACG,CAAC,CAACC,WAAF,CAAcC,MAAd,CAAqBN,MAAtB,CAAT;EACH,CAFkC,EAEhC,EAFgC,CAAnC;EAIA,OAAO,CAACA,MAAD,EAASG,QAAT,CAAP;AACH;AAAA"}
1
+ {"version":3,"names":["React","useCallback","useHeight","initialHeight","height","setHeight","useState","onLayout","e","nativeEvent","layout"],"sources":["useHeight.ts"],"sourcesContent":["import React, { useCallback } from 'react';\nimport { LayoutChangeEvent, ViewProps } from 'react-native';\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport default function useHeight(initialHeight = 0): [number, OnLayoutCallback] {\n const [height, setHeight] = React.useState<number>(initialHeight);\n\n const onLayout = useCallback((e: LayoutChangeEvent) => {\n setHeight(e.nativeEvent.layout.height);\n }, []);\n\n return [height, onLayout];\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AAKA,eAAe,SAASC,SAAT,GAAkE;EAAA,IAA/CC,aAA+C,uEAA/B,CAA+B;EAC7E,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBL,KAAK,CAACM,QAAN,CAAuBH,aAAvB,CAA5B;EAEA,MAAMI,QAAQ,GAAGN,WAAW,CAAEO,CAAD,IAA0B;IACnDH,SAAS,CAACG,CAAC,CAACC,WAAF,CAAcC,MAAd,CAAqBN,MAAtB,CAAT;EACH,CAF2B,EAEzB,EAFyB,CAA5B;EAIA,OAAO,CAACA,MAAD,EAASG,QAAT,CAAP;AACH;AAAA"}
@@ -0,0 +1,13 @@
1
+ import { useCallback, useEffect, useRef } from 'react';
2
+ export default function useIsMounted() {
3
+ const mountedRef = useRef(false);
4
+ useEffect(() => {
5
+ mountedRef.current = true;
6
+ return () => {
7
+ mountedRef.current = false;
8
+ };
9
+ }, []);
10
+ return useCallback(() => mountedRef.current, []);
11
+ }
12
+ ;
13
+ //# sourceMappingURL=useIsMounted.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useEffect","useRef","useIsMounted","mountedRef","current"],"sources":["useIsMounted.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\nexport interface UseIsMounted {\n (): boolean;\n}\n\nexport default function useIsMounted(): UseIsMounted {\n const mountedRef = useRef<boolean>(false);\n\n useEffect(() => {\n mountedRef.current = true;\n\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n return useCallback(() => mountedRef.current, []);\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;AAMA,eAAe,SAASC,YAAT,GAAsC;EACjD,MAAMC,UAAU,GAAGF,MAAM,CAAU,KAAV,CAAzB;EAEAD,SAAS,CAAC,MAAM;IACZG,UAAU,CAACC,OAAX,GAAqB,IAArB;IAEA,OAAO,MAAM;MACTD,UAAU,CAACC,OAAX,GAAqB,KAArB;IACH,CAFD;EAGH,CANQ,EAMN,EANM,CAAT;EAQA,OAAOL,WAAW,CAAC,MAAMI,UAAU,CAACC,OAAlB,EAA2B,EAA3B,CAAlB;AACH;AAAA"}
@@ -1,4 +1,4 @@
1
- import React, { useRef } from 'react';
1
+ import { useCallback, useRef } from 'react';
2
2
  import { Platform } from 'react-native';
3
3
  import { useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useSharedValue, withTiming } from 'react-native-reanimated';
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -30,7 +30,7 @@ export default function useUnstableCollapsibleAppBar() {
30
30
  const [appBarHeight, onAppBarLayout] = useHeight();
31
31
  const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);
32
32
  const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();
33
- const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight);
33
+ const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight, [collapsibleToolbarHeight]);
34
34
  const translateY = useSharedValue(0);
35
35
  const lastTranslateY = useSharedValue(0);
36
36
  const lastOffsetY = useSharedValue(0);
@@ -39,26 +39,43 @@ export default function useUnstableCollapsibleAppBar() {
39
39
  const vectorY = useSharedValue(0);
40
40
  const elevationStyle = useElevationStyle(4);
41
41
  const animatedStyle = useAnimatedStyle(() => {
42
- return Platform.OS === 'web' ? {
43
- transform: [{
44
- translateY: translateY.value
45
- }],
46
- boxShadow: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.boxShadow : 0
47
- } : {
48
- transform: [{
49
- translateY: translateY.value
50
- }],
51
- elevation: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.elevation : 0,
52
- shadowColor: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowColor,
53
- shadowOffset: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowOffset,
54
- shadowRadius: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowRadius,
55
- shadowOpacity: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowOpacity : 0
56
- };
57
- });
58
- const indexRef = React.useRef(0);
59
- const offsetsRef = React.useRef([]);
42
+ const transform = [{
43
+ translateY: translateY.value
44
+ }];
60
45
 
61
- const onScrollViewChanged = nextIndex => {
46
+ if (Platform.OS === 'web') {
47
+ return {
48
+ transform,
49
+ boxShadow: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.boxShadow : 0
50
+ };
51
+ }
52
+
53
+ if (Platform.OS === 'android') {
54
+ return {
55
+ transform,
56
+ elevation: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.elevation : 0
57
+ };
58
+ }
59
+
60
+ if (Platform.OS === 'ios') {
61
+ return {
62
+ transform,
63
+ shadowColor: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowColor,
64
+ shadowOffset: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowOffset,
65
+ shadowRadius: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowRadius,
66
+ shadowOpacity: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowOpacity : 0
67
+ };
68
+ }
69
+
70
+ return {};
71
+ }, [
72
+ /**
73
+ * FIXME: Consider add `elevationStyle` to dependencies.
74
+ */
75
+ ]);
76
+ const indexRef = useRef(0);
77
+ const offsetsRef = useRef([]);
78
+ const onScrollViewChanged = useCallback(nextIndex => {
62
79
  const prevIndex = indexRef.current;
63
80
 
64
81
  if (prevIndex === nextIndex) {
@@ -87,8 +104,7 @@ export default function useUnstableCollapsibleAppBar() {
87
104
  });
88
105
  vectorY.value = 0;
89
106
  }
90
- };
91
-
107
+ }, [appBarHeight]);
92
108
  const scrollHandler = useAnimatedScrollHandler({
93
109
  onBeginDrag: () => {
94
110
  lastTranslateY.value = translateY.value;
@@ -147,7 +163,7 @@ export default function useUnstableCollapsibleAppBar() {
147
163
  duration: ANIMATION_DURATION_MILLIS
148
164
  });
149
165
  }
150
- });
166
+ }, [appBarHeight]);
151
167
  const hasCollapsible = collapsibleToolbarHeight > 0;
152
168
  const appBarStyle = [animatedStyle, {
153
169
  paddingTop: safeAreaInsets.top
@@ -1 +1 @@
1
- {"version":3,"names":["React","useRef","Platform","useAnimatedScrollHandler","useAnimatedStyle","useDerivedValue","useSharedValue","withTiming","useSafeAreaInsets","useAppbarStyles","useElevationStyle","useHeight","defaultOptions","shouldTranslateYReset","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useLargerValueOfLastTwoValues","value","refLatestTwoValues","current","shift","push","Math","max","useUnstableCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","appBarMaxHeight","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","translateY","lastTranslateY","lastOffsetY","prevOffsetY","overlapped","vectorY","elevationStyle","animatedStyle","transform","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","duration","savedOffsetY","scrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","deltaY","dy","min","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","floating","undefined","scrollContentInsets"],"sources":["useUnstableCollapsibleAppBar.ts"],"sourcesContent":["import React, { useRef } from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport {\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport useAppbarStyles from './useAppbarStyles';\nimport useElevationStyle from './useElevationStyle';\nimport useHeight from './useHeight';\n\ntype WebOnlyStyle = { boxShadow: any };\n\ntype ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | WebOnlyStyle | Falsy>;\n\ntype OnScroll = ScrollViewProps['onScroll'];\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport interface ContentInsets {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n}\n\nexport interface Options {\n shouldTranslateYReset?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n vectorY: SharedValue<number>;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n shouldTranslateYReset: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\n\nfunction useLargerValueOfLastTwoValues(value: number) {\n const refLatestTwoValues = useRef([0, 0]);\n\n refLatestTwoValues.current.shift();\n refLatestTwoValues.current.push(value);\n\n return Math.max(...refLatestTwoValues.current);\n}\n\n\nexport default function useUnstableCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { shouldTranslateYReset }: Required<Options> = {\n ...defaultOptions,\n ...userOptions,\n };\n\n const styles = useAppbarStyles();\n\n const safeAreaInsets = useSafeAreaInsets();\n\n const [appBarHeight, onAppBarLayout] = useHeight();\n const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight);\n\n const translateY = useSharedValue<number>(0);\n const lastTranslateY = useSharedValue<number>(0);\n const lastOffsetY = useSharedValue<number>(0);\n const prevOffsetY = useSharedValue<number>(0);\n const overlapped = useSharedValue<boolean>(false);\n const vectorY = useSharedValue<number>(0);\n\n const elevationStyle = useElevationStyle(4);\n const animatedStyle = useAnimatedStyle(() => {\n return Platform.OS === 'web' ? ({\n transform: [{ translateY: translateY.value }],\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n }) : ({\n transform: [{ translateY: translateY.value }],\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n });\n });\n\n const indexRef = React.useRef<number>(0);\n const offsetsRef = React.useRef<Array<number>>([]);\n\n const onScrollViewChanged = (nextIndex: number) => {\n const prevIndex = indexRef.current;\n if (prevIndex === nextIndex) {\n if (shouldTranslateYReset) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n offsetsRef.current = [];\n overlapped.value = false;\n }\n\n return;\n }\n\n offsetsRef.current[prevIndex] = lastOffsetY.value;\n\n const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;\n lastOffsetY.value = savedOffsetY;\n\n indexRef.current = nextIndex;\n\n // Determine whether to overlap every time index is changed.\n overlapped.value = savedOffsetY > 0;\n\n // If next ScrollView's offset is too short, expand app bar.\n if (translateY.value < 0 && savedOffsetY < appBarHeight) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n }\n };\n\n const scrollHandler = useAnimatedScrollHandler({\n onBeginDrag: () => {\n lastTranslateY.value = translateY.value;\n },\n onMomentumBegin: () => {\n lastTranslateY.value = translateY.value;\n },\n onScroll: (event) => {\n const offsetY = event.contentOffset.y;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n const deltaY = offsetY - prevOffsetY.value;\n vectorY.value = (vectorY.value * deltaY >= 0 && offsetY > 0) ? vectorY.value + deltaY : deltaY;\n prevOffsetY.value = offsetY;\n\n if (SUPPORTS_DRAG_DETECTION) {\n const dy = offsetY - lastOffsetY.value;\n\n translateY.value = offsetY <= 0 ? 0 : Math.min(Math.max(lastTranslateY.value - dy, maxTy), 0);\n\n overlapped.value = offsetY + translateY.value > 0;\n } else {\n if (offsetY > -maxTy) {\n if (ty === 0) {\n translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n }\n\n overlapped.value = offsetY > 0;\n\n lastOffsetY.value = offsetY;\n }\n },\n onEndDrag: (event) => {\n lastOffsetY.value = event.contentOffset.y;\n },\n onMomentumEnd: (event) => {\n const offsetY = event.contentOffset.y;\n\n lastOffsetY.value = offsetY;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n // If toolbar is already positioned on edge, do nothing.\n if (ty <= maxTy || ty >= 0) {\n return;\n }\n\n const threshold = maxTy * 0.5;\n\n const nextTranslateY = (ty > threshold || offsetY < appBarHeight) ? 0 : maxTy;\n\n overlapped.value = offsetY + nextTranslateY > 0;\n\n translateY.value = withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n });\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n { paddingTop: safeAreaInsets.top },\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n vectorY,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarMaxHeight : 0 },\n };\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,MAAhB,QAA8B,OAA9B;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AAEA,SACIC,wBADJ,EAEIC,gBAFJ,EAGIC,eAHJ,EAIIC,cAJJ,EAKIC,UALJ,QAMO,yBANP;AAOA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,SAAP,MAAsB,aAAtB;AA+BA,MAAMC,cAAiC,GAAG;EACtCC,qBAAqB,EAAE;AADe,CAA1C;AAIA,MAAMC,yBAAyB,GAAG,GAAlC;AAEA,MAAMC,uBAAuB,GAAGb,QAAQ,CAACc,EAAT,KAAgB,KAAhD;;AAGA,SAASC,6BAAT,CAAuCC,KAAvC,EAAsD;EAClD,MAAMC,kBAAkB,GAAGlB,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,CAAjC;EAEAkB,kBAAkB,CAACC,OAAnB,CAA2BC,KAA3B;EACAF,kBAAkB,CAACC,OAAnB,CAA2BE,IAA3B,CAAgCJ,KAAhC;EAEA,OAAOK,IAAI,CAACC,GAAL,CAAS,GAAGL,kBAAkB,CAACC,OAA/B,CAAP;AACH;;AAGD,eAAe,SAASK,4BAAT,GAAgG;EAAA,IAA1DC,WAA0D,uEAAnCd,cAAmC;EAC3G,MAAM;IAAEC;EAAF,IAA+C,EACjD,GAAGD,cAD8C;IAEjD,GAAGc;EAF8C,CAArD;EAKA,MAAMC,MAAM,GAAGlB,eAAe,EAA9B;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CAA7C,GAAiDqC,KAAxE;MAEA3B,UAAU,CAACrB,KAAX,GAAmB4C,OAAO,GAAGW,cAAV,GAA2B,CAA9C;MAEAtC,UAAU,CAACjB,KAAX,GAAmBX,UAAU,CAACkE,cAAD,EAAiB;QAC1ClB,QAAQ,EAAEzC;MADgC,CAAjB,CAA7B;IAGH;EApE0C,CAAD,CAA9C;EAuEA,MAAM4D,cAAc,GAAG1C,wBAAwB,GAAG,CAAlD;EAEA,MAAM2C,WAAW,GAAG,CAChBjC,aADgB,EAEhB;IAAEkC,UAAU,EAAEhD,cAAc,CAACiD;EAA7B,CAFgB,EAGhBH,cAAc,GAAG/C,MAAM,CAACmD,QAAV,GAAqBC,SAHnB,CAApB;EAMA,OAAO;IACHJ,WADG;IAEHnC,OAFG;IAGHV,cAHG;IAIHG,0BAJG;IAKH2B,QAAQ,EAAEH,aALP;IAMHL,mBANG;IAOH4B,mBAAmB,EAAE;MAAEH,GAAG,EAAEH,cAAc,GAAG3C,eAAH,GAAqB;IAA1C;EAPlB,CAAP;AASH;AAAA"}
1
+ {"version":3,"names":["useCallback","useRef","Platform","useAnimatedScrollHandler","useAnimatedStyle","useDerivedValue","useSharedValue","withTiming","useSafeAreaInsets","useAppbarStyles","useElevationStyle","useHeight","defaultOptions","shouldTranslateYReset","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useLargerValueOfLastTwoValues","value","refLatestTwoValues","current","shift","push","Math","max","useUnstableCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","appBarMaxHeight","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","translateY","lastTranslateY","lastOffsetY","prevOffsetY","overlapped","vectorY","elevationStyle","animatedStyle","transform","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","duration","savedOffsetY","scrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","deltaY","dy","min","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","floating","undefined","scrollContentInsets"],"sources":["useUnstableCollapsibleAppBar.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport {\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport useAppbarStyles from './useAppbarStyles';\nimport useElevationStyle from './useElevationStyle';\nimport useHeight from './useHeight';\n\ntype WebOnlyStyle = { boxShadow: any };\n\ntype ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | WebOnlyStyle | Falsy>;\n\ntype OnScroll = ScrollViewProps['onScroll'];\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport interface ContentInsets {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n}\n\nexport interface Options {\n shouldTranslateYReset?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n vectorY: SharedValue<number>;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n shouldTranslateYReset: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\nfunction useLargerValueOfLastTwoValues(value: number) {\n const refLatestTwoValues = useRef([0, 0]);\n\n refLatestTwoValues.current.shift();\n refLatestTwoValues.current.push(value);\n\n return Math.max(...refLatestTwoValues.current);\n}\n\nexport default function useUnstableCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { shouldTranslateYReset }: Required<Options> = {\n ...defaultOptions,\n ...userOptions,\n };\n\n const styles = useAppbarStyles();\n\n const safeAreaInsets = useSafeAreaInsets();\n\n const [appBarHeight, onAppBarLayout] = useHeight();\n const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight, [collapsibleToolbarHeight]);\n\n const translateY = useSharedValue<number>(0);\n const lastTranslateY = useSharedValue<number>(0);\n const lastOffsetY = useSharedValue<number>(0);\n const prevOffsetY = useSharedValue<number>(0);\n const overlapped = useSharedValue<boolean>(false);\n const vectorY = useSharedValue<number>(0);\n\n const elevationStyle = useElevationStyle(4);\n const animatedStyle = useAnimatedStyle(() => {\n const transform = [{ translateY: translateY.value }];\n\n if (Platform.OS === 'web') {\n return {\n transform,\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n };\n }\n if (Platform.OS === 'android') {\n return {\n transform,\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n };\n }\n if (Platform.OS === 'ios') {\n return {\n transform,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n };\n }\n return {};\n }, [\n /**\n * FIXME: Consider add `elevationStyle` to dependencies.\n */\n ]);\n\n const indexRef = useRef<number>(0);\n const offsetsRef = useRef<Array<number>>([]);\n\n const onScrollViewChanged = useCallback((nextIndex: number) => {\n const prevIndex = indexRef.current;\n if (prevIndex === nextIndex) {\n if (shouldTranslateYReset) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n offsetsRef.current = [];\n overlapped.value = false;\n }\n\n return;\n }\n\n offsetsRef.current[prevIndex] = lastOffsetY.value;\n\n const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;\n lastOffsetY.value = savedOffsetY;\n\n indexRef.current = nextIndex;\n\n // Determine whether to overlap every time index is changed.\n overlapped.value = savedOffsetY > 0;\n\n // If next ScrollView's offset is too short, expand app bar.\n if (translateY.value < 0 && savedOffsetY < appBarHeight) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n }\n }, [appBarHeight]);\n\n const scrollHandler = useAnimatedScrollHandler({\n onBeginDrag: () => {\n lastTranslateY.value = translateY.value;\n },\n onMomentumBegin: () => {\n lastTranslateY.value = translateY.value;\n },\n onScroll: (event) => {\n const offsetY = event.contentOffset.y;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n const deltaY = offsetY - prevOffsetY.value;\n vectorY.value = (vectorY.value * deltaY >= 0 && offsetY > 0) ? vectorY.value + deltaY : deltaY;\n prevOffsetY.value = offsetY;\n\n if (SUPPORTS_DRAG_DETECTION) {\n const dy = offsetY - lastOffsetY.value;\n\n translateY.value = offsetY <= 0 ? 0 : Math.min(Math.max(lastTranslateY.value - dy, maxTy), 0);\n\n overlapped.value = offsetY + translateY.value > 0;\n } else {\n if (offsetY > -maxTy) {\n if (ty === 0) {\n translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n }\n\n overlapped.value = offsetY > 0;\n\n lastOffsetY.value = offsetY;\n }\n },\n onEndDrag: (event) => {\n lastOffsetY.value = event.contentOffset.y;\n },\n onMomentumEnd: (event) => {\n const offsetY = event.contentOffset.y;\n\n lastOffsetY.value = offsetY;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n // If toolbar is already positioned on edge, do nothing.\n if (ty <= maxTy || ty >= 0) {\n return;\n }\n\n const threshold = maxTy * 0.5;\n\n const nextTranslateY = (ty > threshold || offsetY < appBarHeight) ? 0 : maxTy;\n\n overlapped.value = offsetY + nextTranslateY > 0;\n\n translateY.value = withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n }, [appBarHeight]);\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n { paddingTop: safeAreaInsets.top },\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n vectorY,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarMaxHeight : 0 },\n };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,OAApC;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AAEA,SACIC,wBADJ,EAEIC,gBAFJ,EAGIC,eAHJ,EAIIC,cAJJ,EAKIC,UALJ,QAMO,yBANP;AAOA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,SAAP,MAAsB,aAAtB;AA+BA,MAAMC,cAAiC,GAAG;EACtCC,qBAAqB,EAAE;AADe,CAA1C;AAIA,MAAMC,yBAAyB,GAAG,GAAlC;AAEA,MAAMC,uBAAuB,GAAGb,QAAQ,CAACc,EAAT,KAAgB,KAAhD;;AAEA,SAASC,6BAAT,CAAuCC,KAAvC,EAAsD;EAClD,MAAMC,kBAAkB,GAAGlB,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,CAAjC;EAEAkB,kBAAkB,CAACC,OAAnB,CAA2BC,KAA3B;EACAF,kBAAkB,CAACC,OAAnB,CAA2BE,IAA3B,CAAgCJ,KAAhC;EAEA,OAAOK,IAAI,CAACC,GAAL,CAAS,GAAGL,kBAAkB,CAACC,OAA/B,CAAP;AACH;;AAED,eAAe,SAASK,4BAAT,GAAgG;EAAA,IAA1DC,WAA0D,uEAAnCd,cAAmC;E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AEA3B,WAAW,CAACnB,KAAZ,GAAoB4C,OAApB;MAEA,MAAMG,EAAE,GAAG9B,UAAU,CAACjB,KAAtB;MACA,MAAMgD,KAAK,GAAGhC,aAAa,CAAChB,KAA5B,CANsB,CAQtB;;MACA,IAAI+C,EAAE,IAAIC,KAAN,IAAeD,EAAE,IAAI,CAAzB,EAA4B;QACxB;MACH;;MAED,MAAMO,SAAS,GAAGN,KAAK,GAAG,GAA1B;MAEA,MAAMO,cAAc,GAAIR,EAAE,GAAGO,SAAL,IAAkBV,OAAO,GAAGjC,YAA7B,GAA6C,CAA7C,GAAiDqC,KAAxE;MAEA3B,UAAU,CAACrB,KAAX,GAAmB4C,OAAO,GAAGW,cAAV,GAA2B,CAA9C;MAEAtC,UAAU,CAACjB,KAAX,GAAmBX,UAAU,CAACkE,cAAD,EAAiB;QAC1ClB,QAAQ,EAAEzC;MADgC,CAAjB,CAA7B;IAGH;EApE0C,CAAD,EAqE3C,CAACe,YAAD,CArE2C,CAA9C;EAuEA,MAAM6C,cAAc,GAAG1C,wBAAwB,GAAG,CAAlD;EAEA,MAAM2C,WAAW,GAAG,CAChBjC,aADgB,EAEhB;IAAEkC,UAAU,EAAEhD,cAAc,CAACiD;EAA7B,CAFgB,EAGhBH,cAAc,GAAG/C,MAAM,CAACmD,QAAV,GAAqBC,SAHnB,CAApB;EAMA,OAAO;IACHJ,WADG;IAEHnC,OAFG;IAGHV,cAHG;IAIHG,0BAJG;IAKH2B,QAAQ,EAAEH,aALP;IAMHL,mBANG;IAOH4B,mBAAmB,EAAE;MAAEH,GAAG,EAAEH,cAAc,GAAG3C,eAAH,GAAqB;IAA1C;EAPlB,CAAP;AASH;AAAA"}
@@ -9,10 +9,10 @@ export default function useAnimatedDisplayStyle(vectorY) {
9
9
  } else if (vy < threshold) {
10
10
  display.value = 'flex';
11
11
  }
12
- });
12
+ }, [threshold]);
13
13
  return useAnimatedStyle(() => ({
14
14
  display: display.value
15
- }));
15
+ }), []);
16
16
  }
17
17
  ;
18
18
  //# sourceMappingURL=useUnstableToggleDisplayStyle.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useAnimatedReaction","useAnimatedStyle","useSharedValue","useAnimatedDisplayStyle","vectorY","threshold","defaultDisplay","display","value","vy"],"sources":["useUnstableToggleDisplayStyle.ts"],"sourcesContent":["import type { SharedValue } from 'react-native-reanimated';\nimport { useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';\n\nexport default function useAnimatedDisplayStyle(\n vectorY: SharedValue<number>,\n threshold: number = 200,\n defaultDisplay: 'flex' | 'none' = 'flex',\n) {\n const display = useSharedValue(defaultDisplay);\n\n useAnimatedReaction(\n () => vectorY.value,\n (vy) => {\n if (vy >= threshold) {\n display.value = 'none';\n } else if (vy < threshold) {\n display.value = 'flex';\n }\n },\n );\n\n return useAnimatedStyle(() => ({\n display: display.value,\n }));\n};\n"],"mappings":"AACA,SAASA,mBAAT,EAA8BC,gBAA9B,EAAgDC,cAAhD,QAAsE,yBAAtE;AAEA,eAAe,SAASC,uBAAT,CACXC,OADW,EAIb;EAAA,IAFEC,SAEF,uEAFsB,GAEtB;EAAA,IADEC,cACF,uEADoC,MACpC;EACE,MAAMC,OAAO,GAAGL,cAAc,CAACI,cAAD,CAA9B;EAEAN,mBAAmB,CACf,MAAMI,OAAO,CAACI,KADC,EAEdC,EAAD,IAAQ;IACJ,IAAIA,EAAE,IAAIJ,SAAV,EAAqB;MACjBE,OAAO,CAACC,KAAR,GAAgB,MAAhB;IACH,CAFD,MAEO,IAAIC,EAAE,GAAGJ,SAAT,EAAoB;MACvBE,OAAO,CAACC,KAAR,GAAgB,MAAhB;IACH;EACJ,CARc,CAAnB;EAWA,OAAOP,gBAAgB,CAAC,OAAO;IAC3BM,OAAO,EAAEA,OAAO,CAACC;EADU,CAAP,CAAD,CAAvB;AAGH;AAAA"}
1
+ {"version":3,"names":["useAnimatedReaction","useAnimatedStyle","useSharedValue","useAnimatedDisplayStyle","vectorY","threshold","defaultDisplay","display","value","vy"],"sources":["useUnstableToggleDisplayStyle.ts"],"sourcesContent":["import type { SharedValue } from 'react-native-reanimated';\nimport { useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';\n\nexport default function useAnimatedDisplayStyle(\n vectorY: SharedValue<number>,\n threshold: number = 200,\n defaultDisplay: 'flex' | 'none' = 'flex',\n) {\n const display = useSharedValue(defaultDisplay);\n\n useAnimatedReaction(\n () => vectorY.value,\n (vy) => {\n if (vy >= threshold) {\n display.value = 'none';\n } else if (vy < threshold) {\n display.value = 'flex';\n }\n },\n [threshold],\n );\n\n return useAnimatedStyle(() => ({\n display: display.value,\n }), []);\n};\n"],"mappings":"AACA,SAASA,mBAAT,EAA8BC,gBAA9B,EAAgDC,cAAhD,QAAsE,yBAAtE;AAEA,eAAe,SAASC,uBAAT,CACXC,OADW,EAIb;EAAA,IAFEC,SAEF,uEAFsB,GAEtB;EAAA,IADEC,cACF,uEADoC,MACpC;EACE,MAAMC,OAAO,GAAGL,cAAc,CAACI,cAAD,CAA9B;EAEAN,mBAAmB,CACf,MAAMI,OAAO,CAACI,KADC,EAEdC,EAAD,IAAQ;IACJ,IAAIA,EAAE,IAAIJ,SAAV,EAAqB;MACjBE,OAAO,CAACC,KAAR,GAAgB,MAAhB;IACH,CAFD,MAEO,IAAIC,EAAE,GAAGJ,SAAT,EAAoB;MACvBE,OAAO,CAACC,KAAR,GAAgB,MAAhB;IACH;EACJ,CARc,EASf,CAACH,SAAD,CATe,CAAnB;EAYA,OAAOJ,gBAAgB,CAAC,OAAO;IAC3BM,OAAO,EAAEA,OAAO,CAACC;EADU,CAAP,CAAD,EAEnB,EAFmB,CAAvB;AAGH;AAAA"}
@@ -12,5 +12,7 @@ export { default as ComicViewer } from './ComicViewer';
12
12
  export * from './ComicViewer';
13
13
  export { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';
14
14
  export * from './StatusBarProvider';
15
+ export { default as ViewabilityTrackerView } from './ViewabilityTrackerView';
16
+ export * from './ViewabilityTrackerView';
15
17
  export * from './hooks';
16
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["default","BottomSheet","Carousel","DateTimePicker","FlipCard","ViewPager","ComicViewer","StatusBarProvider","useStatusBarContext"],"sources":["index.ts"],"sourcesContent":["export { default as BottomSheet } from './BottomSheet';\nexport * from './BottomSheet';\n\nexport { default as Carousel } from './Carousel';\nexport * from './Carousel';\n\nexport { default as DateTimePicker } from './DateTimePicker';\nexport * from './DateTimePicker';\n\nexport { default as FlipCard } from './FlipCard';\nexport * from './FlipCard';\n\nexport { default as ViewPager } from './ViewPager';\nexport * from './ViewPager';\n\nexport { default as ComicViewer } from './ComicViewer';\nexport * from './ComicViewer';\n\nexport { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';\nexport * from './StatusBarProvider';\n\nexport * from './hooks';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASF,OAAO,IAAIG,cAApB,QAA0C,kBAA1C;AACA,cAAc,kBAAd;AAEA,SAASH,OAAO,IAAII,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASJ,OAAO,IAAIK,SAApB,QAAqC,aAArC;AACA,cAAc,aAAd;AAEA,SAASL,OAAO,IAAIM,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASN,OAAO,IAAIO,iBAApB,EAAuCC,mBAAvC,QAAkE,qBAAlE;AACA,cAAc,qBAAd;AAEA,cAAc,SAAd"}
1
+ {"version":3,"names":["default","BottomSheet","Carousel","DateTimePicker","FlipCard","ViewPager","ComicViewer","StatusBarProvider","useStatusBarContext","ViewabilityTrackerView"],"sources":["index.ts"],"sourcesContent":["export { default as BottomSheet } from './BottomSheet';\nexport * from './BottomSheet';\n\nexport { default as Carousel } from './Carousel';\nexport * from './Carousel';\n\nexport { default as DateTimePicker } from './DateTimePicker';\nexport * from './DateTimePicker';\n\nexport { default as FlipCard } from './FlipCard';\nexport * from './FlipCard';\n\nexport { default as ViewPager } from './ViewPager';\nexport * from './ViewPager';\n\nexport { default as ComicViewer } from './ComicViewer';\nexport * from './ComicViewer';\n\nexport { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';\nexport * from './StatusBarProvider';\n\nexport { default as ViewabilityTrackerView } from './ViewabilityTrackerView';\nexport * from './ViewabilityTrackerView';\n\nexport * from './hooks';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASF,OAAO,IAAIG,cAApB,QAA0C,kBAA1C;AACA,cAAc,kBAAd;AAEA,SAASH,OAAO,IAAII,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASJ,OAAO,IAAIK,SAApB,QAAqC,aAArC;AACA,cAAc,aAAd;AAEA,SAASL,OAAO,IAAIM,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASN,OAAO,IAAIO,iBAApB,EAAuCC,mBAAvC,QAAkE,qBAAlE;AACA,cAAc,qBAAd;AAEA,SAASR,OAAO,IAAIS,sBAApB,QAAkD,0BAAlD;AACA,cAAc,0BAAd;AAEA,cAAc,SAAd"}
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import type AnimatedYProps from './AnimatedYProps';
2
3
  export default function AnimatedY(props: AnimatedYProps): JSX.Element;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import type BottomSheetProps from './BottomSheetProps';
2
3
  export default function BottomSheet(props: BottomSheetProps): JSX.Element;
@@ -10,10 +10,29 @@ export default interface BottomSheetProps extends ComponentProps<{
10
10
  * BottomSheet children, usually the included sub-components.
11
11
  */
12
12
  children?: React.ReactNode;
13
+ /**
14
+ * Enable dynamic sizing for content size.
15
+ * @default true
16
+ */
17
+ enableDynamicSizing?: boolean;
18
+ /**
19
+ * Area to be fixed on the top of the bottom sheet.
20
+ */
21
+ header?: React.ReactNode;
22
+ /**
23
+ * Top element for displaying additional information on the bottom sheet.
24
+ */
25
+ topElement?: React.ReactNode;
13
26
  /**
14
27
  * Snap index. You could also provide -1 to bottom sheet in closed state.
15
28
  */
16
29
  index: number;
30
+ /**
31
+ * Maximum height(normalized value) of dialog
32
+ * ex. 30% => 0.3 / 90% => 0.9
33
+ * @default 0.9
34
+ */
35
+ maxHeightNormalizedRatio?: number;
17
36
  /**
18
37
  * Callback fired when the index is changed.
19
38
  * Important! Use memoized value.
@@ -22,7 +41,19 @@ export default interface BottomSheetProps extends ComponentProps<{
22
41
  /**
23
42
  * Points for the bottom sheet to snap to, points should be sorted from bottom to top.
24
43
  * Important! Use memoized value.
44
+ * Only number type or string type(~% format) can be used.
45
+ * @default []
46
+ */
47
+ snapPoints?: Array<number | string>;
48
+ /**
49
+ * Disable default backgroundColor.
50
+ * @default false
51
+ */
52
+ disableDefaultBackgroundColor?: boolean;
53
+ /**
54
+ * Disable default shadow.
55
+ * @default false
25
56
  */
26
- snapPoints: Array<number>;
57
+ disableDefaultShadow?: boolean;
27
58
  }> {
28
59
  }
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import type BottomSheetProps from './BottomSheetProps';
2
3
  export default function BottomSheet(props: BottomSheetProps): JSX.Element;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import { BottomSheetBackdropProps } from '@gorhom/bottom-sheet';
2
3
  export default function TransparentBackdrop(props: BottomSheetBackdropProps): JSX.Element;
@@ -0,0 +1,12 @@
1
+ interface UseDynamicSnapPointsParams {
2
+ enableDynamicSizing: boolean;
3
+ maxHeightNormalizedRatio: number;
4
+ snapPoints: (number | string)[];
5
+ }
6
+ interface UseDynamicSnapPointsReturns {
7
+ convertedSnapPoints: number[];
8
+ handleContentSizeChange: (w: number, h: number) => void;
9
+ highestSnapPoint: number;
10
+ }
11
+ export default function useDynamicSnapPoints(params: UseDynamicSnapPointsParams): UseDynamicSnapPointsReturns;
12
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type CarouselProps from './CarouselProps';
3
+ import type { CarouselInstance } from './types';
4
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<CarouselProps<any>, "style" | "data" | "scrollEnabled" | "autoplay" | "autoplayInterval" | "createItemStyle" | "createScrollAnimation" | "disableSmartAutoplay" | "initialIndex" | "itemHeight" | "itemWidth" | "loop" | "onIndexChange" | "renderItem" | "windowSize"> & React.RefAttributes<CarouselInstance>>>;
5
+ export default _default;
@@ -1,7 +1,8 @@
1
- import React, { RefObject } from 'react';
2
- import type { ListRenderItemInfo } from 'react-native';
1
+ import type { RefObject } from 'react';
3
2
  import type { ComponentProps } from '@fountain-ui/core';
3
+ import type { CarouselInstance, CreateItemStyle, CreateScrollAnimation, ItemHeight, OnIndexChange, RenderItem } from './types';
4
4
  export default interface CarouselProps<ItemT = any> extends ComponentProps<{
5
+ ref?: RefObject<CarouselInstance>;
5
6
  /**
6
7
  * If `true`, enable autoplay.
7
8
  * @default false
@@ -13,78 +14,62 @@ export default interface CarouselProps<ItemT = any> extends ComponentProps<{
13
14
  */
14
15
  autoplayInterval?: number;
15
16
  /**
16
- * Padding for center slide. If specified, `slidesToScroll` and `slidesToShow` set to 1.
17
+ * The item style creator function.
18
+ * @default createDefaultItemStyle
17
19
  */
18
- centerSlidePadding?: number;
20
+ createItemStyle?: CreateItemStyle;
19
21
  /**
20
- * Delay in ms until navigating to the next item.
22
+ * The scroll animation creator function.
23
+ * @default createDefaultScrollAnimation
24
+ */
25
+ createScrollAnimation?: CreateScrollAnimation;
26
+ /**
27
+ * Data for render items.
21
28
  */
22
29
  data: ReadonlyArray<ItemT>;
23
30
  /**
24
- * Value of the opacity effect applied to inactive slides.
25
- * @default 0.7
31
+ * If `true`, carousel will detect its own viewability and control autoplay automatically.
32
+ * @default false
26
33
  */
27
- inactiveSlideOpacity?: number;
34
+ disableSmartAutoplay?: boolean;
28
35
  /**
29
- * Value of the 'scale' transform applied to inactive slides.
30
- * @default 0.9
36
+ * Index of initial item that should be selected.
37
+ * @default 0
31
38
  */
32
- inactiveSlideScale?: number;
39
+ initialIndex?: number;
33
40
  /**
34
- * Web only. Value of the 'scale' transform applied to a active slide.
35
- * @default 0.990
41
+ * The item height.
42
+ * For a performance reason, always consider to provide a number value.
36
43
  */
37
- activeSlideScale?: number;
44
+ itemHeight: ItemHeight;
38
45
  /**
39
- * A number representing the index of the active slide.
46
+ * The item width.
40
47
  */
41
- index: number;
48
+ itemWidth: number;
42
49
  /**
43
50
  * Enable infinite loop mode.
44
51
  * @default false
45
52
  */
46
- infinite?: boolean;
53
+ loop?: boolean;
47
54
  /**
48
55
  * Callback fired when an index is changed.
49
56
  */
50
- onChange?: (newIndex: number) => void;
57
+ onIndexChange?: OnIndexChange;
51
58
  /**
52
59
  * Takes an item from data and renders it into the list.
53
60
  */
54
- renderItem: (info: Omit<ListRenderItemInfo<ItemT>, 'separators'>) => React.ReactElement | null;
55
- /**
56
- * Web only. Number of slides to scroll at once.
57
- * @default 1
58
- */
59
- slidesToScroll?: number;
60
- /**
61
- * Web only. Number of slides to display.
62
- * @default 1
63
- */
64
- slidesToShow?: number;
61
+ renderItem: RenderItem<ItemT>;
65
62
  /**
66
- * Web only. Enable items to display at the center.
63
+ * Whether to enable scroll gesture.
67
64
  * @default true
68
65
  */
69
- centerMode?: boolean;
70
- /**
71
- * Web only. Enable arrows to display.
72
- * @default true
73
- */
74
- arrows?: boolean;
75
- /**
76
- * Web only. Style of arrows
77
- * @default true
78
- */
79
- arrowsStyle?: object;
80
- /**
81
- * Web only. Style of track
82
- * @default object
83
- */
84
- trackStyle?: object;
66
+ scrollEnabled?: boolean;
85
67
  /**
86
- * Only web. Refer slick object
68
+ * The maximum number of items that can respond to pan gesture events.
69
+ * Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)
70
+ * 0 means all items will respond to pan gesture events.
71
+ * @default 5
87
72
  */
88
- ref?: RefObject<any>;
73
+ windowSize?: number;
89
74
  }> {
90
75
  }
@@ -0,0 +1 @@
1
+ export declare const itemInterpolationInputRange: number[];
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../types").CreateItemStyle;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { Animated } from 'react-native';
2
+ export default function createDefaultScrollAnimation(animatedValue: Animated.Value, toValue: number): Animated.CompositeAnimation;
@@ -0,0 +1,4 @@
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';
@@ -0,0 +1,2 @@
1
+ import type { CreateItemStyle } from '../types';
2
+ export default function normalItemStyleFactory(): CreateItemStyle;
@@ -0,0 +1,9 @@
1
+ import type { CreateItemStyle } from '../types';
2
+ export interface ParallaxAnimationConfig {
3
+ activeItemScale?: number;
4
+ activeItemOpacity?: number;
5
+ adjacentItemScale?: number;
6
+ adjacentItemOpacity?: number;
7
+ scrollingOffset?: number;
8
+ }
9
+ export default function parallaxItemStyleFactory(config?: ParallaxAnimationConfig): CreateItemStyle;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { Animated } from 'react-native';
3
+ import type { CreateItemStyle, ItemHeight, ItemVisibilityStore } from '../types';
4
+ export interface InternalContextValue<ItemT> {
5
+ createItemStyle: CreateItemStyle;
6
+ data: ReadonlyArray<ItemT>;
7
+ globalInterpolation: Animated.AnimatedInterpolation;
8
+ itemHeight: ItemHeight;
9
+ itemWidth: number;
10
+ itemVisibilityStore: ItemVisibilityStore;
11
+ loop: boolean;
12
+ }
13
+ declare const InternalContext: import("react").Context<InternalContextValue<any>>;
14
+ export default InternalContext;
@@ -0,0 +1,9 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { ViewProps } from 'react-native';
3
+ import { Animated } from 'react-native';
4
+ export interface ItemViewProps {
5
+ children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;
6
+ index: number;
7
+ onLayout?: ViewProps['onLayout'];
8
+ }
9
+ export default function ItemView(props: ItemViewProps): JSX.Element;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import type { View, ViewProps } from 'react-native';
3
+ import type { ItemHeight, RenderItem } from '../types';
4
+ export declare type RootViewProps<ItemT> = ViewProps & {
5
+ data: ReadonlyArray<ItemT>;
6
+ itemHeight: ItemHeight;
7
+ originalData: ReadonlyArray<ItemT>;
8
+ renderItem: RenderItem<ItemT>;
9
+ };
10
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<ViewProps & {
11
+ data: readonly any[];
12
+ itemHeight: ItemHeight;
13
+ originalData: readonly any[];
14
+ renderItem: RenderItem<any>;
15
+ } & React.RefAttributes<View>>>;
16
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from 'react';
2
+ import { Animated } from 'react-native';
3
+ import type { AutoplayController, StartPagingAnimation } from '../types';
4
+ export interface ScrollViewGestureProps {
5
+ autoplayController: AutoplayController;
6
+ children: ReactNode;
7
+ gestureTranslationX: Animated.Value;
8
+ interruptAnimation: () => void;
9
+ scrollEnabled: boolean;
10
+ startPagingAnimation: StartPagingAnimation;
11
+ }
12
+ export default function ScrollViewGesture(props: ScrollViewGestureProps): JSX.Element;
@@ -0,0 +1,4 @@
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';
@@ -0,0 +1,2 @@
1
+ import { Animated } from 'react-native';
2
+ export default function useItemInterpolation(index: number): Animated.AnimatedInterpolation;
@@ -0,0 +1,5 @@
1
+ export { default as useAutoplayController } from './useAutoplayController';
2
+ export { default as useIndexController } from './useIndexController';
3
+ export { default as useLoopedData } from './useLoopedData';
4
+ export { default as usePagingAnimator } from './usePagingAnimator';
5
+ export { default as useItemVisibilityStore } from './useItemVisibilityStore';
@@ -0,0 +1,7 @@
1
+ import type { AutoplayController, StartPagingAnimation } from '../types';
2
+ export interface AutoplayConfig {
3
+ enabled: boolean;
4
+ intervalMillis: number;
5
+ startPagingAnimation: StartPagingAnimation;
6
+ }
7
+ export default function useAutoplayController(config: AutoplayConfig): AutoplayController;