@fountain-ui/lab 2.0.0-beta.10 → 2.0.0-beta.13

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 (266) hide show
  1. package/build/commonjs/Carousel/Carousel.js +142 -0
  2. package/build/commonjs/Carousel/Carousel.js.map +1 -0
  3. package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
  4. package/build/commonjs/Carousel/animation/animationUtils.js +9 -0
  5. package/build/commonjs/Carousel/animation/animationUtils.js.map +1 -0
  6. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js +15 -0
  7. package/build/commonjs/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  8. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +20 -0
  9. package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  10. package/build/commonjs/Carousel/animation/index.js +40 -0
  11. package/build/commonjs/Carousel/animation/index.js.map +1 -0
  12. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js +27 -0
  13. package/build/commonjs/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  14. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +65 -0
  15. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  16. package/build/commonjs/Carousel/components/InternalContext.js +29 -0
  17. package/build/commonjs/Carousel/components/InternalContext.js.map +1 -0
  18. package/build/commonjs/Carousel/components/ItemView.js +66 -0
  19. package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
  20. package/build/commonjs/Carousel/components/RootView.js +86 -0
  21. package/build/commonjs/Carousel/components/RootView.js.map +1 -0
  22. package/build/commonjs/Carousel/components/ScrollViewGesture.js +81 -0
  23. package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -0
  24. package/build/commonjs/Carousel/components/index.js +40 -0
  25. package/build/commonjs/Carousel/components/index.js.map +1 -0
  26. package/build/commonjs/Carousel/hooks/index.js +64 -0
  27. package/build/commonjs/Carousel/hooks/index.js.map +1 -0
  28. package/build/commonjs/Carousel/hooks/useAutoplayController.js +58 -0
  29. package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
  30. package/build/commonjs/Carousel/hooks/useDimensionChangeReaction.js +23 -0
  31. package/build/commonjs/Carousel/hooks/useDimensionChangeReaction.js.map +1 -0
  32. package/build/commonjs/Carousel/hooks/useIndexController.js +70 -0
  33. package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
  34. package/build/commonjs/Carousel/hooks/useItemInterpolation.js +63 -0
  35. package/build/commonjs/Carousel/hooks/useItemInterpolation.js.map +1 -0
  36. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +95 -0
  37. package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  38. package/build/commonjs/Carousel/hooks/useLoopedData.js +33 -0
  39. package/build/commonjs/Carousel/hooks/useLoopedData.js.map +1 -0
  40. package/build/commonjs/Carousel/hooks/usePagingAnimation.js +162 -0
  41. package/build/commonjs/Carousel/hooks/usePagingAnimation.js.map +1 -0
  42. package/build/commonjs/Carousel/index.js +16 -2
  43. package/build/commonjs/Carousel/index.js.map +1 -1
  44. package/build/commonjs/Carousel/types.js +7 -0
  45. package/build/commonjs/Carousel/types.js.map +1 -0
  46. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +86 -21
  47. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +1 -1
  48. package/build/commonjs/ViewPager/PageStateContext.js +22 -0
  49. package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
  50. package/build/commonjs/ViewPager/ViewPagerNative.js +82 -34
  51. package/build/commonjs/ViewPager/ViewPagerNative.js.map +1 -1
  52. package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
  53. package/build/commonjs/ViewPager/ViewPagerWeb.js +35 -26
  54. package/build/commonjs/ViewPager/ViewPagerWeb.js.map +1 -1
  55. package/build/commonjs/ViewPager/index.js +8 -0
  56. package/build/commonjs/ViewPager/index.js.map +1 -1
  57. package/build/commonjs/ViewPager/index.native.js +8 -0
  58. package/build/commonjs/ViewPager/index.native.js.map +1 -1
  59. package/build/commonjs/ViewPager/utils.js +5 -41
  60. package/build/commonjs/ViewPager/utils.js.map +1 -1
  61. package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
  62. package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
  63. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
  64. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  65. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  66. package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  67. package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
  68. package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
  69. package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
  70. package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
  71. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
  72. package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  73. package/build/commonjs/hooks/index.js +16 -0
  74. package/build/commonjs/hooks/index.js.map +1 -1
  75. package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
  76. package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
  77. package/build/commonjs/hooks/useIsMounted.js +22 -0
  78. package/build/commonjs/hooks/useIsMounted.js.map +1 -0
  79. package/build/commonjs/index.js +22 -1
  80. package/build/commonjs/index.js.map +1 -1
  81. package/build/module/Carousel/Carousel.js +120 -0
  82. package/build/module/Carousel/Carousel.js.map +1 -0
  83. package/build/module/Carousel/CarouselProps.js.map +1 -1
  84. package/build/module/Carousel/animation/animationUtils.js +2 -0
  85. package/build/module/Carousel/animation/animationUtils.js.map +1 -0
  86. package/build/module/Carousel/animation/createDefaultItemStyle.js +3 -0
  87. package/build/module/Carousel/animation/createDefaultItemStyle.js.map +1 -0
  88. package/build/module/Carousel/animation/createDefaultScrollAnimation.js +11 -0
  89. package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
  90. package/build/module/Carousel/animation/index.js +5 -0
  91. package/build/module/Carousel/animation/index.js.map +1 -0
  92. package/build/module/Carousel/animation/normalItemStyleFactory.js +18 -0
  93. package/build/module/Carousel/animation/normalItemStyleFactory.js.map +1 -0
  94. package/build/module/Carousel/animation/parallaxItemStyleFactory.js +55 -0
  95. package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
  96. package/build/module/Carousel/components/InternalContext.js +19 -0
  97. package/build/module/Carousel/components/InternalContext.js.map +1 -0
  98. package/build/module/Carousel/components/ItemView.js +46 -0
  99. package/build/module/Carousel/components/ItemView.js.map +1 -0
  100. package/build/module/Carousel/components/RootView.js +65 -0
  101. package/build/module/Carousel/components/RootView.js.map +1 -0
  102. package/build/module/Carousel/components/ScrollViewGesture.js +67 -0
  103. package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -0
  104. package/build/module/Carousel/components/index.js +5 -0
  105. package/build/module/Carousel/components/index.js.map +1 -0
  106. package/build/module/Carousel/hooks/index.js +8 -0
  107. package/build/module/Carousel/hooks/index.js.map +1 -0
  108. package/build/module/Carousel/hooks/useAutoplayController.js +48 -0
  109. package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
  110. package/build/module/Carousel/hooks/useDimensionChangeReaction.js +14 -0
  111. package/build/module/Carousel/hooks/useDimensionChangeReaction.js.map +1 -0
  112. package/build/module/Carousel/hooks/useIndexController.js +54 -0
  113. package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
  114. package/build/module/Carousel/hooks/useItemInterpolation.js +51 -0
  115. package/build/module/Carousel/hooks/useItemInterpolation.js.map +1 -0
  116. package/build/module/Carousel/hooks/useItemVisibilityStore.js +87 -0
  117. package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
  118. package/build/module/Carousel/hooks/useLoopedData.js +24 -0
  119. package/build/module/Carousel/hooks/useLoopedData.js.map +1 -0
  120. package/build/module/Carousel/hooks/usePagingAnimation.js +153 -0
  121. package/build/module/Carousel/hooks/usePagingAnimation.js.map +1 -0
  122. package/build/module/Carousel/index.js +2 -1
  123. package/build/module/Carousel/index.js.map +1 -1
  124. package/build/module/Carousel/types.js +3 -0
  125. package/build/module/Carousel/types.js.map +1 -0
  126. package/build/module/ViewPager/ChildrenMemoizedPage.js +80 -23
  127. package/build/module/ViewPager/ChildrenMemoizedPage.js.map +1 -1
  128. package/build/module/ViewPager/PageStateContext.js +10 -0
  129. package/build/module/ViewPager/PageStateContext.js.map +1 -0
  130. package/build/module/ViewPager/ViewPagerNative.js +81 -34
  131. package/build/module/ViewPager/ViewPagerNative.js.map +1 -1
  132. package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
  133. package/build/module/ViewPager/ViewPagerWeb.js +29 -24
  134. package/build/module/ViewPager/ViewPagerWeb.js.map +1 -1
  135. package/build/module/ViewPager/index.js +1 -0
  136. package/build/module/ViewPager/index.js.map +1 -1
  137. package/build/module/ViewPager/index.native.js +1 -0
  138. package/build/module/ViewPager/index.native.js.map +1 -1
  139. package/build/module/ViewPager/utils.js +2 -32
  140. package/build/module/ViewPager/utils.js.map +1 -1
  141. package/build/module/ViewabilityTrackerView/Viewability.js +2 -0
  142. package/build/module/ViewabilityTrackerView/Viewability.js.map +1 -0
  143. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js +28 -0
  144. package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
  145. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
  146. package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
  147. package/build/module/ViewabilityTrackerView/index.js +2 -0
  148. package/build/module/ViewabilityTrackerView/index.js.map +1 -0
  149. package/build/module/ViewabilityTrackerView/measureViewability.js +34 -0
  150. package/build/module/ViewabilityTrackerView/measureViewability.js.map +1 -0
  151. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js +73 -0
  152. package/build/module/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
  153. package/build/module/hooks/index.js +2 -0
  154. package/build/module/hooks/index.js.map +1 -1
  155. package/build/module/hooks/useDeferredExecutor.js +33 -0
  156. package/build/module/hooks/useDeferredExecutor.js.map +1 -0
  157. package/build/module/hooks/useIsMounted.js +13 -0
  158. package/build/module/hooks/useIsMounted.js.map +1 -0
  159. package/build/module/index.js +2 -0
  160. package/build/module/index.js.map +1 -1
  161. package/build/typescript/Carousel/Carousel.d.ts +5 -0
  162. package/build/typescript/Carousel/CarouselProps.d.ts +33 -48
  163. package/build/typescript/Carousel/animation/animationUtils.d.ts +1 -0
  164. package/build/typescript/Carousel/animation/createDefaultItemStyle.d.ts +2 -0
  165. package/build/typescript/Carousel/animation/createDefaultScrollAnimation.d.ts +2 -0
  166. package/build/typescript/Carousel/animation/index.d.ts +4 -0
  167. package/build/typescript/Carousel/animation/normalItemStyleFactory.d.ts +2 -0
  168. package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +9 -0
  169. package/build/typescript/Carousel/components/InternalContext.d.ts +14 -0
  170. package/build/typescript/Carousel/components/ItemView.d.ts +9 -0
  171. package/build/typescript/Carousel/components/RootView.d.ts +16 -0
  172. package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +12 -0
  173. package/build/typescript/Carousel/components/index.d.ts +4 -0
  174. package/build/typescript/Carousel/hooks/index.d.ts +7 -0
  175. package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
  176. package/build/typescript/Carousel/hooks/useDimensionChangeReaction.d.ts +7 -0
  177. package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
  178. package/build/typescript/Carousel/hooks/useItemInterpolation.d.ts +2 -0
  179. package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +7 -0
  180. package/build/typescript/Carousel/hooks/useLoopedData.d.ts +1 -0
  181. package/build/typescript/Carousel/hooks/usePagingAnimation.d.ts +18 -0
  182. package/build/typescript/Carousel/index.d.ts +3 -1
  183. package/build/typescript/Carousel/types.d.ts +79 -0
  184. package/build/typescript/ViewPager/ChildrenMemoizedPage.d.ts +2 -1
  185. package/build/typescript/ViewPager/PageStateContext.d.ts +7 -0
  186. package/build/typescript/ViewPager/ViewPagerNative.d.ts +4 -1
  187. package/build/typescript/ViewPager/ViewPagerProps.d.ts +31 -19
  188. package/build/typescript/ViewPager/ViewPagerWeb.d.ts +4 -1
  189. package/build/typescript/ViewPager/index.d.ts +2 -1
  190. package/build/typescript/ViewPager/index.native.d.ts +1 -0
  191. package/build/typescript/ViewPager/utils.d.ts +3 -19
  192. package/build/typescript/ViewabilityTrackerView/Viewability.d.ts +3 -0
  193. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +2 -0
  194. package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerViewProps.d.ts +22 -0
  195. package/build/typescript/ViewabilityTrackerView/index.d.ts +2 -0
  196. package/build/typescript/ViewabilityTrackerView/measureViewability.d.ts +11 -0
  197. package/build/typescript/ViewabilityTrackerView/useViewabilityTracker.d.ts +11 -0
  198. package/build/typescript/hooks/index.d.ts +2 -0
  199. package/build/typescript/hooks/useDeferredExecutor.d.ts +11 -0
  200. package/build/typescript/hooks/useIsMounted.d.ts +4 -0
  201. package/build/typescript/index.d.ts +2 -0
  202. package/package.json +4 -19
  203. package/src/Carousel/Carousel.tsx +152 -0
  204. package/src/Carousel/CarouselProps.ts +35 -53
  205. package/src/Carousel/animation/animationUtils.ts +1 -0
  206. package/src/Carousel/animation/createDefaultItemStyle.ts +3 -0
  207. package/src/Carousel/animation/createDefaultScrollAnimation.ts +13 -0
  208. package/src/Carousel/animation/index.ts +4 -0
  209. package/src/Carousel/animation/normalItemStyleFactory.ts +19 -0
  210. package/src/Carousel/animation/parallaxItemStyleFactory.ts +79 -0
  211. package/src/Carousel/components/InternalContext.ts +33 -0
  212. package/src/Carousel/components/ItemView.tsx +66 -0
  213. package/src/Carousel/components/RootView.tsx +79 -0
  214. package/src/Carousel/components/ScrollViewGesture.tsx +87 -0
  215. package/src/Carousel/components/index.ts +4 -0
  216. package/src/Carousel/hooks/index.ts +7 -0
  217. package/src/Carousel/hooks/useAutoplayController.ts +57 -0
  218. package/src/Carousel/hooks/useDimensionChangeReaction.ts +25 -0
  219. package/src/Carousel/hooks/useIndexController.tsx +76 -0
  220. package/src/Carousel/hooks/useItemInterpolation.ts +107 -0
  221. package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
  222. package/src/Carousel/hooks/useLoopedData.ts +26 -0
  223. package/src/Carousel/hooks/usePagingAnimation.ts +195 -0
  224. package/src/Carousel/index.ts +4 -2
  225. package/src/Carousel/types.ts +97 -0
  226. package/src/ViewPager/ChildrenMemoizedPage.tsx +97 -23
  227. package/src/ViewPager/PageStateContext.ts +15 -0
  228. package/src/ViewPager/ViewPagerNative.tsx +101 -39
  229. package/src/ViewPager/ViewPagerProps.ts +33 -19
  230. package/src/ViewPager/ViewPagerWeb.tsx +38 -29
  231. package/src/ViewPager/index.native.ts +1 -0
  232. package/src/ViewPager/index.ts +2 -1
  233. package/src/ViewPager/utils.tsx +4 -56
  234. package/src/ViewabilityTrackerView/Viewability.ts +3 -0
  235. package/src/ViewabilityTrackerView/ViewabilityTrackerView.tsx +33 -0
  236. package/src/ViewabilityTrackerView/ViewabilityTrackerViewProps.ts +25 -0
  237. package/src/ViewabilityTrackerView/index.ts +2 -0
  238. package/src/ViewabilityTrackerView/measureViewability.ts +56 -0
  239. package/src/ViewabilityTrackerView/useViewabilityTracker.ts +85 -0
  240. package/src/hooks/index.ts +2 -0
  241. package/src/hooks/useDeferredExecutor.ts +46 -0
  242. package/src/hooks/useIsMounted.ts +19 -0
  243. package/src/index.ts +3 -0
  244. package/build/commonjs/Carousel/CarouselNative.js +0 -72
  245. package/build/commonjs/Carousel/CarouselNative.js.map +0 -1
  246. package/build/commonjs/Carousel/CarouselWeb.js +0 -237
  247. package/build/commonjs/Carousel/CarouselWeb.js.map +0 -1
  248. package/build/commonjs/Carousel/index.native.js.map +0 -1
  249. package/build/commonjs/Carousel/utils.js +0 -19
  250. package/build/commonjs/Carousel/utils.js.map +0 -1
  251. package/build/module/Carousel/CarouselNative.js +0 -54
  252. package/build/module/Carousel/CarouselNative.js.map +0 -1
  253. package/build/module/Carousel/CarouselWeb.js +0 -215
  254. package/build/module/Carousel/CarouselWeb.js.map +0 -1
  255. package/build/module/Carousel/index.native.js +0 -2
  256. package/build/module/Carousel/index.native.js.map +0 -1
  257. package/build/module/Carousel/utils.js +0 -7
  258. package/build/module/Carousel/utils.js.map +0 -1
  259. package/build/typescript/Carousel/CarouselNative.d.ts +0 -2
  260. package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
  261. package/build/typescript/Carousel/index.native.d.ts +0 -1
  262. package/build/typescript/Carousel/utils.d.ts +0 -6
  263. package/src/Carousel/CarouselNative.tsx +0 -67
  264. package/src/Carousel/CarouselWeb.tsx +0 -222
  265. package/src/Carousel/index.native.ts +0 -1
  266. package/src/Carousel/utils.ts +0 -11
@@ -1 +1 @@
1
- {"version":3,"names":[],"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;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"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;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,120 @@
1
+ import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
2
+ import { Animated } from 'react-native';
3
+ import ViewabilityTrackerView from '../ViewabilityTrackerView';
4
+ import { useAutoplayController, useDimensionChangeReaction, useIndexController, useItemVisibilityStore, useLoopedData, usePagingAnimation } from './hooks';
5
+ import { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';
6
+ import { InternalContext, RootView, ScrollViewGesture } from './components';
7
+ const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
8
+ const {
9
+ autoplay = false,
10
+ autoplayInterval = 3000,
11
+ createItemStyle = createDefaultItemStyle,
12
+ createScrollAnimation = createDefaultScrollAnimation,
13
+ data: originalData,
14
+ disableSmartAutoplay = false,
15
+ initialIndex = 0,
16
+ itemHeight,
17
+ itemWidth,
18
+ loop = false,
19
+ onIndexChange,
20
+ renderItem,
21
+ scrollEnabled = true,
22
+ style,
23
+ windowSize = 5
24
+ } = props;
25
+ const data = useLoopedData(originalData, loop);
26
+ const initialTx = itemWidth * initialIndex;
27
+ const controlledTx = useRef(new Animated.Value(initialTx)).current;
28
+ const offsetTx = useRef(new Animated.Value(0)).current;
29
+ const {
30
+ currentIndex,
31
+ getCurrentIndex,
32
+ lastIndex,
33
+ monitorElement
34
+ } = useIndexController({
35
+ controlledTx,
36
+ initialIndex,
37
+ itemWidth,
38
+ numberOfOriginalData: originalData.length,
39
+ onIndexChange
40
+ });
41
+ const itemVisibilityStore = useItemVisibilityStore({
42
+ currentIndex,
43
+ numberOfData: data.length,
44
+ windowSize
45
+ });
46
+ const {
47
+ finalizeAnimation,
48
+ globalInterpolation,
49
+ startPagingAnimation
50
+ } = usePagingAnimation({
51
+ controlledTx,
52
+ createScrollAnimation,
53
+ getCurrentIndex,
54
+ itemWidth,
55
+ lastIndex,
56
+ loop,
57
+ numberOfData: data.length,
58
+ offsetTx
59
+ });
60
+ const autoplayController = useAutoplayController({
61
+ enabled: autoplay,
62
+ intervalMillis: autoplayInterval,
63
+ startPagingAnimation
64
+ });
65
+ useDimensionChangeReaction({
66
+ controlledTx,
67
+ currentIndex,
68
+ itemWidth
69
+ });
70
+ useImperativeHandle(ref, () => ({
71
+ getCurrentIndex,
72
+ next: () => startPagingAnimation('directional', {
73
+ direction: 'next'
74
+ }),
75
+ prev: () => startPagingAnimation('directional', {
76
+ direction: 'prev'
77
+ }),
78
+ scrollTo: option => startPagingAnimation('index', option)
79
+ }), [startPagingAnimation, getCurrentIndex]);
80
+ const contextValue = useMemo(() => ({
81
+ createItemStyle,
82
+ data,
83
+ globalInterpolation,
84
+ itemHeight,
85
+ itemWidth,
86
+ itemVisibilityStore,
87
+ loop
88
+ }), [createItemStyle, data, globalInterpolation, itemHeight, itemWidth, itemVisibilityStore, loop]);
89
+ return /*#__PURE__*/React.createElement(InternalContext.Provider, {
90
+ value: contextValue
91
+ }, monitorElement, /*#__PURE__*/React.createElement(ViewabilityTrackerView, {
92
+ enabled: autoplay && !disableSmartAutoplay,
93
+ measurementIntervalMillis: Math.max(3000, autoplayInterval),
94
+ onViewabilityChange: _ref => {
95
+ let {
96
+ visible
97
+ } = _ref;
98
+
99
+ if (visible) {
100
+ autoplayController.resume();
101
+ } else {
102
+ autoplayController.pause();
103
+ }
104
+ }
105
+ }, /*#__PURE__*/React.createElement(ScrollViewGesture, {
106
+ autoplayController: autoplayController,
107
+ finalizeAnimation: finalizeAnimation,
108
+ offsetTx: offsetTx,
109
+ scrollEnabled: scrollEnabled,
110
+ startPagingAnimation: startPagingAnimation
111
+ }, /*#__PURE__*/React.createElement(RootView, {
112
+ data: data,
113
+ itemHeight: itemHeight,
114
+ originalData: originalData,
115
+ renderItem: renderItem,
116
+ style: style
117
+ }))));
118
+ });
119
+ export default /*#__PURE__*/memo(Carousel);
120
+ //# sourceMappingURL=Carousel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","memo","useImperativeHandle","useMemo","useRef","Animated","ViewabilityTrackerView","useAutoplayController","useDimensionChangeReaction","useIndexController","useItemVisibilityStore","useLoopedData","usePagingAnimation","createDefaultItemStyle","createDefaultScrollAnimation","InternalContext","RootView","ScrollViewGesture","Carousel","props","ref","autoplay","autoplayInterval","createItemStyle","createScrollAnimation","data","originalData","disableSmartAutoplay","initialIndex","itemHeight","itemWidth","loop","onIndexChange","renderItem","scrollEnabled","style","windowSize","initialTx","controlledTx","Value","current","offsetTx","currentIndex","getCurrentIndex","lastIndex","monitorElement","numberOfOriginalData","length","itemVisibilityStore","numberOfData","finalizeAnimation","globalInterpolation","startPagingAnimation","autoplayController","enabled","intervalMillis","next","direction","prev","scrollTo","option","contextValue","Math","max","visible","resume","pause"],"sources":["Carousel.tsx"],"sourcesContent":["import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport ViewabilityTrackerView from '../ViewabilityTrackerView';\nimport type CarouselProps from './CarouselProps';\nimport type { CarouselInstance } from './types';\nimport {\n useAutoplayController,\n useDimensionChangeReaction,\n useIndexController,\n useItemVisibilityStore,\n useLoopedData,\n usePagingAnimation,\n} from './hooks';\nimport { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';\nimport { InternalContext, RootView, ScrollViewGesture } from './components';\n\nconst Carousel = forwardRef<CarouselInstance, CarouselProps>(function Carousel(props, ref) {\n const {\n autoplay = false,\n autoplayInterval = 3000,\n createItemStyle = createDefaultItemStyle,\n createScrollAnimation = createDefaultScrollAnimation,\n data: originalData,\n disableSmartAutoplay = false,\n initialIndex = 0,\n itemHeight,\n itemWidth,\n loop = false,\n onIndexChange,\n renderItem,\n scrollEnabled = true,\n style,\n windowSize = 5,\n } = props;\n\n const data = useLoopedData(originalData, loop);\n\n const initialTx = itemWidth * initialIndex;\n const controlledTx = useRef(new Animated.Value(initialTx)).current;\n const offsetTx = useRef(new Animated.Value(0)).current;\n\n const {\n currentIndex,\n getCurrentIndex,\n lastIndex,\n monitorElement,\n } = useIndexController({\n controlledTx,\n initialIndex,\n itemWidth,\n numberOfOriginalData: originalData.length,\n onIndexChange,\n });\n\n const itemVisibilityStore = useItemVisibilityStore({\n currentIndex,\n numberOfData: data.length,\n windowSize,\n });\n\n const {\n finalizeAnimation,\n globalInterpolation,\n startPagingAnimation,\n } = usePagingAnimation({\n controlledTx,\n createScrollAnimation,\n getCurrentIndex,\n itemWidth,\n lastIndex,\n loop,\n numberOfData: data.length,\n offsetTx,\n });\n\n const autoplayController = useAutoplayController({\n enabled: autoplay,\n intervalMillis: autoplayInterval,\n startPagingAnimation,\n });\n\n useDimensionChangeReaction({\n controlledTx,\n currentIndex,\n itemWidth,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n getCurrentIndex,\n next: () => startPagingAnimation('directional', { direction: 'next' }),\n prev: () => startPagingAnimation('directional', { direction: 'prev' }),\n scrollTo: (option) => startPagingAnimation('index', option),\n }),\n [startPagingAnimation, getCurrentIndex],\n );\n\n const contextValue = useMemo(() => ({\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n }), [\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n ]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n {monitorElement}\n\n <ViewabilityTrackerView\n enabled={autoplay && !disableSmartAutoplay}\n measurementIntervalMillis={Math.max(3000, autoplayInterval)}\n onViewabilityChange={({ visible }) => {\n if (visible) {\n autoplayController.resume();\n } else {\n autoplayController.pause();\n }\n }}\n >\n <ScrollViewGesture\n autoplayController={autoplayController}\n finalizeAnimation={finalizeAnimation}\n offsetTx={offsetTx}\n scrollEnabled={scrollEnabled}\n startPagingAnimation={startPagingAnimation}\n >\n <RootView\n data={data}\n itemHeight={itemHeight}\n originalData={originalData}\n renderItem={renderItem}\n style={style}\n />\n </ScrollViewGesture>\n </ViewabilityTrackerView>\n </InternalContext.Provider>\n );\n});\n\nexport default memo(Carousel);\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,IAA5B,EAAkCC,mBAAlC,EAAuDC,OAAvD,EAAgEC,MAAhE,QAA8E,OAA9E;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAGA,SACIC,qBADJ,EAEIC,0BAFJ,EAGIC,kBAHJ,EAIIC,sBAJJ,EAKIC,aALJ,EAMIC,kBANJ,QAOO,SAPP;AAQA,SAASC,sBAAT,EAAiCC,4BAAjC,QAAqE,aAArE;AACA,SAASC,eAAT,EAA0BC,QAA1B,EAAoCC,iBAApC,QAA6D,cAA7D;AAEA,MAAMC,QAAQ,gBAAGlB,UAAU,CAAkC,SAASkB,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EACvF,MAAM;IACFC,QAAQ,GAAG,KADT;IAEFC,gBAAgB,GAAG,IAFjB;IAGFC,eAAe,GAAGV,sBAHhB;IAIFW,qBAAqB,GAAGV,4BAJtB;IAKFW,IAAI,EAAEC,YALJ;IAMFC,oBAAoB,GAAG,KANrB;IAOFC,YAAY,GAAG,CAPb;IAQFC,UARE;IAS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IAKI,oBAAoB,EAAEkB;EAL1B,gBAOI,oBAAC,QAAD;IACI,IAAI,EAAE3B,IADV;IAEI,UAAU,EAAEI,UAFhB;IAGI,YAAY,EAAEH,YAHlB;IAII,UAAU,EAAEO,UAJhB;IAKI,KAAK,EAAEE;EALX,EAPJ,CAXJ,CAHJ,CADJ;AAiCH,CArI0B,CAA3B;AAuIA,4BAAelC,IAAI,CAACiB,QAAD,CAAnB"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import React, { RefObject } from 'react';\nimport type { ListRenderItemInfo } from 'react-native';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * Padding for center slide. If specified, `slidesToScroll` and `slidesToShow` set to 1.\n */\n centerSlidePadding?: number;\n\n /**\n * Delay in ms until navigating to the next item.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * Value of the opacity effect applied to inactive slides.\n * @default 0.7\n */\n inactiveSlideOpacity?: number;\n\n /**\n * Value of the 'scale' transform applied to inactive slides.\n * @default 0.9\n */\n inactiveSlideScale?: number;\n\n /**\n * Web only. Value of the 'scale' transform applied to a active slide.\n * @default 0.990\n */\n activeSlideScale?: number;\n\n /**\n * A number representing the index of the active slide.\n */\n index: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n infinite?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: (info: Omit<ListRenderItemInfo<ItemT>, 'separators'>) => React.ReactElement | null;\n\n /**\n * Web only. Number of slides to scroll at once.\n * @default 1\n */\n slidesToScroll?: number;\n\n /**\n * Web only. Number of slides to display.\n * @default 1\n */\n slidesToShow?: number;\n\n /**\n * Web only. Enable items to display at the center.\n * @default true\n */\n centerMode?: boolean;\n\n /**\n * Web only. Enable arrows to display.\n * @default true\n */\n arrows?: boolean;\n\n /**\n * Web only. Style of arrows\n * @default true\n */\n arrowsStyle?: object;\n\n /**\n * Web only. Style of track\n * @default object\n */\n trackStyle?: object;\n\n /**\n * Only web. Refer slick object\n */\n ref?: RefObject<any>;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type { CarouselInstance, CreateItemStyle, CreateScrollAnimation, ItemHeight, RenderItem } from './types';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n ref?: RefObject<CarouselInstance>;\n\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * The item style creator function.\n * @default createDefaultItemStyle\n */\n createItemStyle?: CreateItemStyle;\n\n /**\n * The scroll animation creator function.\n * @default createDefaultScrollAnimation\n */\n createScrollAnimation?: CreateScrollAnimation;\n\n /**\n * Data for render items.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * If `true`, carousel will detect its own viewability and control autoplay automatically.\n * @default false\n */\n disableSmartAutoplay?: boolean;\n\n /**\n * Index of initial item that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * The item height.\n * For a performance reason, always consider to provide a number value.\n */\n itemHeight: ItemHeight;\n\n /**\n * The item width.\n */\n itemWidth: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n loop?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onIndexChange?: (newIndex: number) => void;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: RenderItem<ItemT>;\n\n /**\n * Whether to enable scroll gesture.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * The maximum number of items that can respond to pan gesture events.\n * Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)\n * 0 means all items will respond to pan gesture events.\n * @default 5\n */\n windowSize?: number;\n}> {}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export const itemInterpolationInputRange = [-1, 0, 1];
2
+ //# sourceMappingURL=animationUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["itemInterpolationInputRange"],"sources":["animationUtils.ts"],"sourcesContent":["export const itemInterpolationInputRange = [-1, 0, 1];\n"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,GAAG,CAAC,CAAC,CAAF,EAAK,CAAL,EAAQ,CAAR,CAApC"}
@@ -0,0 +1,3 @@
1
+ import normalItemStyleFactory from './normalItemStyleFactory';
2
+ export default normalItemStyleFactory();
3
+ //# sourceMappingURL=createDefaultItemStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalItemStyleFactory"],"sources":["createDefaultItemStyle.ts"],"sourcesContent":["import normalItemStyleFactory from './normalItemStyleFactory';\n\nexport default normalItemStyleFactory();\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,0BAAnC;AAEA,eAAeA,sBAAsB,EAArC"}
@@ -0,0 +1,11 @@
1
+ import { Animated, Easing } from 'react-native';
2
+ export default function createDefaultScrollAnimation(animatedValue, toValue) {
3
+ return Animated.timing(animatedValue, {
4
+ toValue: toValue,
5
+ duration: 350,
6
+ easing: Easing.bezier(0.25, 1, 0.5, 1),
7
+ useNativeDriver: true
8
+ });
9
+ }
10
+ ;
11
+ //# sourceMappingURL=createDefaultScrollAnimation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Animated","Easing","createDefaultScrollAnimation","animatedValue","toValue","timing","duration","easing","bezier","useNativeDriver"],"sources":["createDefaultScrollAnimation.ts"],"sourcesContent":["import { Animated, Easing } from 'react-native';\n\nexport default function createDefaultScrollAnimation(\n animatedValue: Animated.Value,\n toValue: number,\n): Animated.CompositeAnimation {\n return Animated.timing(animatedValue, {\n toValue: toValue,\n duration: 350,\n easing: Easing.bezier(0.25, 1, 0.5, 1),\n useNativeDriver: true,\n });\n};\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,MAAnB,QAAiC,cAAjC;AAEA,eAAe,SAASC,4BAAT,CACXC,aADW,EAEXC,OAFW,EAGgB;EAC3B,OAAOJ,QAAQ,CAACK,MAAT,CAAgBF,aAAhB,EAA+B;IAClCC,OAAO,EAAEA,OADyB;IAElCE,QAAQ,EAAE,GAFwB;IAGlCC,MAAM,EAAEN,MAAM,CAACO,MAAP,CAAc,IAAd,EAAoB,CAApB,EAAuB,GAAvB,EAA4B,CAA5B,CAH0B;IAIlCC,eAAe,EAAE;EAJiB,CAA/B,CAAP;AAMH;AAAA"}
@@ -0,0 +1,5 @@
1
+ export { default as createDefaultItemStyle } from './createDefaultItemStyle';
2
+ export { default as createDefaultScrollAnimation } from './createDefaultScrollAnimation';
3
+ export { default as normalItemStyleFactory } from './normalItemStyleFactory';
4
+ export { default as parallaxItemStyleFactory } from './parallaxItemStyleFactory';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","createDefaultItemStyle","createDefaultScrollAnimation","normalItemStyleFactory","parallaxItemStyleFactory"],"sources":["index.ts"],"sourcesContent":["export { default as createDefaultItemStyle } from './createDefaultItemStyle';\nexport { default as createDefaultScrollAnimation } from './createDefaultScrollAnimation';\nexport { default as normalItemStyleFactory } from './normalItemStyleFactory';\nexport { default as parallaxItemStyleFactory } from './parallaxItemStyleFactory';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,sBAApB,QAAkD,0BAAlD;AACA,SAASD,OAAO,IAAIE,4BAApB,QAAwD,gCAAxD;AACA,SAASF,OAAO,IAAIG,sBAApB,QAAkD,0BAAlD;AACA,SAASH,OAAO,IAAII,wBAApB,QAAoD,4BAApD"}
@@ -0,0 +1,18 @@
1
+ import { itemInterpolationInputRange } from './animationUtils';
2
+ export default function normalItemStyleFactory() {
3
+ const createItemStyle = (itemInterpolation, itemWidth) => {
4
+ const translate = itemInterpolation.interpolate({
5
+ inputRange: itemInterpolationInputRange,
6
+ outputRange: [-itemWidth, 0, itemWidth]
7
+ });
8
+ return {
9
+ transform: [{
10
+ translateX: translate
11
+ }]
12
+ };
13
+ };
14
+
15
+ return createItemStyle;
16
+ }
17
+ ;
18
+ //# sourceMappingURL=normalItemStyleFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["itemInterpolationInputRange","normalItemStyleFactory","createItemStyle","itemInterpolation","itemWidth","translate","interpolate","inputRange","outputRange","transform","translateX"],"sources":["normalItemStyleFactory.ts"],"sourcesContent":["import type { CreateItemStyle } from '../types';\nimport { itemInterpolationInputRange } from './animationUtils';\n\nexport default function normalItemStyleFactory() {\n const createItemStyle: CreateItemStyle = (itemInterpolation, itemWidth) => {\n const translate = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n -itemWidth,\n 0,\n itemWidth,\n ],\n });\n\n return { transform: [{ translateX: translate }] };\n };\n\n return createItemStyle;\n};\n"],"mappings":"AACA,SAASA,2BAAT,QAA4C,kBAA5C;AAEA,eAAe,SAASC,sBAAT,GAAkC;EAC7C,MAAMC,eAAgC,GAAG,CAACC,iBAAD,EAAoBC,SAApB,KAAkC;IACvE,MAAMC,SAAS,GAAGF,iBAAiB,CAACG,WAAlB,CAA8B;MAC5CC,UAAU,EAAEP,2BADgC;MAE5CQ,WAAW,EAAE,CACT,CAACJ,SADQ,EAET,CAFS,EAGTA,SAHS;IAF+B,CAA9B,CAAlB;IASA,OAAO;MAAEK,SAAS,EAAE,CAAC;QAAEC,UAAU,EAAEL;MAAd,CAAD;IAAb,CAAP;EACH,CAXD;;EAaA,OAAOH,eAAP;AACH;AAAA"}
@@ -0,0 +1,55 @@
1
+ import { itemInterpolationInputRange } from './animationUtils';
2
+ const defaultParallaxAnimationConfig = {
3
+ activeItemScale: 0.9,
4
+ activeItemOpacity: 1,
5
+ adjacentItemScale: Math.pow(0.9, 2),
6
+ adjacentItemOpacity: 0.5,
7
+ scrollingOffset: 50
8
+ };
9
+ export default function parallaxItemStyleFactory() {
10
+ let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultParallaxAnimationConfig;
11
+ const {
12
+ activeItemOpacity,
13
+ activeItemScale,
14
+ adjacentItemOpacity,
15
+ adjacentItemScale,
16
+ scrollingOffset
17
+ } = { ...config,
18
+ ...defaultParallaxAnimationConfig
19
+ };
20
+
21
+ const createItemStyle = (itemInterpolation, itemWidth) => {
22
+ const translate = itemInterpolation.interpolate({
23
+ inputRange: itemInterpolationInputRange,
24
+ outputRange: [-itemWidth + scrollingOffset, 0, itemWidth - scrollingOffset]
25
+ });
26
+ const zIndex = itemInterpolation.interpolate({
27
+ inputRange: itemInterpolationInputRange,
28
+ outputRange: [0, itemWidth, 0],
29
+ extrapolate: 'clamp'
30
+ });
31
+ const scale = itemInterpolation.interpolate({
32
+ inputRange: itemInterpolationInputRange,
33
+ outputRange: [adjacentItemScale, activeItemScale, adjacentItemScale],
34
+ extrapolate: 'clamp'
35
+ });
36
+ const opacity = itemInterpolation.interpolate({
37
+ inputRange: itemInterpolationInputRange,
38
+ outputRange: [adjacentItemOpacity, activeItemOpacity, adjacentItemOpacity],
39
+ extrapolate: 'clamp'
40
+ });
41
+ return {
42
+ transform: [{
43
+ translateX: translate
44
+ }, {
45
+ scale
46
+ }],
47
+ zIndex,
48
+ opacity
49
+ };
50
+ };
51
+
52
+ return createItemStyle;
53
+ }
54
+ ;
55
+ //# sourceMappingURL=parallaxItemStyleFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["itemInterpolationInputRange","defaultParallaxAnimationConfig","activeItemScale","activeItemOpacity","adjacentItemScale","Math","pow","adjacentItemOpacity","scrollingOffset","parallaxItemStyleFactory","config","createItemStyle","itemInterpolation","itemWidth","translate","interpolate","inputRange","outputRange","zIndex","extrapolate","scale","opacity","transform","translateX"],"sources":["parallaxItemStyleFactory.ts"],"sourcesContent":["import type { CreateItemStyle } from '../types';\nimport { itemInterpolationInputRange } from './animationUtils';\n\nexport interface ParallaxAnimationConfig {\n activeItemScale?: number;\n activeItemOpacity?: number;\n adjacentItemScale?: number;\n adjacentItemOpacity?: number;\n scrollingOffset?: number;\n}\n\nconst defaultParallaxAnimationConfig: Required<Readonly<ParallaxAnimationConfig>> = {\n activeItemScale: 0.9,\n activeItemOpacity: 1,\n adjacentItemScale: Math.pow(0.9, 2),\n adjacentItemOpacity: 0.5,\n scrollingOffset: 50,\n};\n\nexport default function parallaxItemStyleFactory(config: ParallaxAnimationConfig = defaultParallaxAnimationConfig) {\n const {\n activeItemOpacity,\n activeItemScale,\n adjacentItemOpacity,\n adjacentItemScale,\n scrollingOffset,\n }: Required<ParallaxAnimationConfig> = {\n ...config,\n ...defaultParallaxAnimationConfig,\n };\n\n const createItemStyle: CreateItemStyle = (itemInterpolation, itemWidth) => {\n const translate = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n -itemWidth + scrollingOffset,\n 0,\n itemWidth - scrollingOffset,\n ],\n });\n\n const zIndex = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [0, itemWidth, 0],\n extrapolate: 'clamp',\n });\n\n const scale = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n adjacentItemScale,\n activeItemScale,\n adjacentItemScale,\n ],\n extrapolate: 'clamp',\n });\n\n const opacity = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n adjacentItemOpacity,\n activeItemOpacity,\n adjacentItemOpacity,\n ],\n extrapolate: 'clamp',\n });\n\n return {\n transform: [\n { translateX: translate },\n { scale },\n ],\n zIndex,\n opacity,\n };\n };\n\n return createItemStyle;\n};\n"],"mappings":"AACA,SAASA,2BAAT,QAA4C,kBAA5C;AAUA,MAAMC,8BAA2E,GAAG;EAChFC,eAAe,EAAE,GAD+D;EAEhFC,iBAAiB,EAAE,CAF6D;EAGhFC,iB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AAd,CADO,EAEP;QAAEM;MAAF,CAFO,CADR;MAKHF,MALG;MAMHG;IANG,CAAP;EAQH,CA5CD;;EA8CA,OAAOV,eAAP;AACH;AAAA"}
@@ -0,0 +1,19 @@
1
+ import { createContext } from 'react';
2
+ import { Animated } from 'react-native';
3
+ const mockItemVisibilityStore = {
4
+ dispatch: () => void 0,
5
+ subscribe: () => () => void 0,
6
+ removeAllListeners: () => void 0
7
+ };
8
+ const initialValue = {
9
+ createItemStyle: () => ({}),
10
+ data: [],
11
+ globalInterpolation: Animated.add(new Animated.Value(0), 0),
12
+ itemHeight: 0,
13
+ itemWidth: 0,
14
+ itemVisibilityStore: mockItemVisibilityStore,
15
+ loop: false
16
+ };
17
+ const InternalContext = /*#__PURE__*/createContext(initialValue);
18
+ export default InternalContext;
19
+ //# sourceMappingURL=InternalContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","Animated","mockItemVisibilityStore","dispatch","subscribe","removeAllListeners","initialValue","createItemStyle","data","globalInterpolation","add","Value","itemHeight","itemWidth","itemVisibilityStore","loop","InternalContext"],"sources":["InternalContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\nimport type { CreateItemStyle, ItemHeight, ItemVisibilityStore } from '../types';\n\nexport interface InternalContextValue<ItemT> {\n createItemStyle: CreateItemStyle;\n data: ReadonlyArray<ItemT>;\n globalInterpolation: Animated.AnimatedInterpolation;\n itemHeight: ItemHeight;\n itemWidth: number;\n itemVisibilityStore: ItemVisibilityStore;\n loop: boolean;\n}\n\nconst mockItemVisibilityStore: ItemVisibilityStore = {\n dispatch: () => void 0,\n subscribe: () => () => void 0,\n removeAllListeners: () => void 0,\n};\n\nconst initialValue: Readonly<InternalContextValue<any>> = {\n createItemStyle: () => ({}),\n data: [],\n globalInterpolation: Animated.add(new Animated.Value(0), 0),\n itemHeight: 0,\n itemWidth: 0,\n itemVisibilityStore: mockItemVisibilityStore,\n loop: false,\n};\n\nconst InternalContext = createContext<InternalContextValue<any>>(initialValue);\n\nexport default InternalContext;\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAaA,MAAMC,uBAA4C,GAAG;EACjDC,QAAQ,EAAE,MAAM,KAAK,CAD4B;EAEjDC,SAAS,EAAE,MAAM,MAAM,KAAK,CAFqB;EAGjDC,kBAAkB,EAAE,MAAM,KAAK;AAHkB,CAArD;AAMA,MAAMC,YAAiD,GAAG;EACtDC,eAAe,EAAE,OAAO,EAAP,CADqC;EAEtDC,IAAI,EAAE,EAFgD;EAGtDC,mBAAmB,EAAER,QAAQ,CAACS,GAAT,CAAa,IAAIT,QAAQ,CAACU,KAAb,CAAmB,CAAnB,CAAb,EAAoC,CAApC,CAHiC;EAItDC,UAAU,EAAE,CAJ0C;EAKtDC,SAAS,EAAE,CAL2C;EAMtDC,mBAAmB,EAAEZ,uBANiC;EAOtDa,IAAI,EAAE;AAPgD,CAA1D;AAUA,MAAMC,eAAe,gBAAGhB,aAAa,CAA4BM,YAA5B,CAArC;AAEA,eAAeU,eAAf"}
@@ -0,0 +1,46 @@
1
+ import React, { useContext, useEffect, useMemo, useState } from 'react';
2
+ import { Animated } from 'react-native';
3
+ import { StyleSheet } from '@fountain-ui/core';
4
+ import { useItemInterpolation } from '../hooks';
5
+ import InternalContext from './InternalContext';
6
+ export default function ItemView(props) {
7
+ const {
8
+ children,
9
+ index,
10
+ onLayout
11
+ } = props;
12
+ const {
13
+ createItemStyle,
14
+ itemHeight,
15
+ itemWidth,
16
+ itemVisibilityStore
17
+ } = useContext(InternalContext);
18
+ const [visible, setVisible] = useState(false);
19
+ const interpolation = useItemInterpolation(index);
20
+ const itemStyle = useMemo(() => createItemStyle(interpolation, itemWidth), [createItemStyle, interpolation]);
21
+ useEffect(() => {
22
+ return itemVisibilityStore.subscribe(ranges => {
23
+ const nextVisible = ranges.some(_ref => {
24
+ let [from, to] = _ref;
25
+ return index >= from && index <= to;
26
+ });
27
+ setVisible(nextVisible);
28
+ });
29
+ }, [itemVisibilityStore]);
30
+ return /*#__PURE__*/React.createElement(Animated.View, {
31
+ children: visible ? children(interpolation) : null,
32
+ onLayout: onLayout,
33
+ style: [{
34
+ width: itemWidth,
35
+ height: itemHeight !== 'auto' ? itemHeight : undefined
36
+ }, styles.absolute, // @ts-ignore
37
+ itemStyle]
38
+ });
39
+ }
40
+ ;
41
+ const styles = StyleSheet.create({
42
+ absolute: {
43
+ position: 'absolute'
44
+ }
45
+ });
46
+ //# sourceMappingURL=ItemView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useContext","useEffect","useMemo","useState","Animated","StyleSheet","useItemInterpolation","InternalContext","ItemView","props","children","index","onLayout","createItemStyle","itemHeight","itemWidth","itemVisibilityStore","visible","setVisible","interpolation","itemStyle","subscribe","ranges","nextVisible","some","from","to","width","height","undefined","styles","absolute","create","position"],"sources":["ItemView.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport { useItemInterpolation } from '../hooks';\nimport InternalContext from './InternalContext';\n\nexport interface ItemViewProps {\n children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;\n index: number;\n onLayout?: ViewProps['onLayout'];\n}\n\nexport default function ItemView(props: ItemViewProps) {\n const {\n children,\n index,\n onLayout,\n } = props;\n\n const {\n createItemStyle,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n } = useContext(InternalContext);\n\n const [visible, setVisible] = useState(false);\n\n const interpolation = useItemInterpolation(index);\n\n const itemStyle = useMemo(\n () => createItemStyle(interpolation, itemWidth),\n [createItemStyle, interpolation],\n );\n\n useEffect(() => {\n return itemVisibilityStore.subscribe(ranges => {\n const nextVisible = ranges.some(([from, to]) => index >= from && index <= to);\n setVisible(nextVisible);\n });\n }, [itemVisibilityStore]);\n\n return (\n <Animated.View\n children={visible ? children(interpolation) : null}\n onLayout={onLayout}\n style={[\n {\n width: itemWidth,\n height: itemHeight !== 'auto' ? itemHeight : undefined,\n },\n styles.absolute,\n // @ts-ignore\n itemStyle,\n ]}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: 'absolute',\n },\n});\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,SAA5B,EAAuCC,OAAvC,EAAgDC,QAAhD,QAAgE,OAAhE;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,SAASC,oBAAT,QAAqC,UAArC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAQA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;EACnD,MAAM;IACFC,QADE;IAEFC,KAFE;IAGFC;EAHE,IAIFH,KAJJ;EAMA,MAAM;IACFI,eADE;IAEFC,UAFE;IAGFC,SAHE;IAIFC;EAJE,IAKFhB,UAAU,CAACO,eAAD,CALd;EAOA,MAAM,CAACU,OAAD,EAAUC,UAAV,IAAwBf,QAAQ,CAAC,KAAD,CAAtC;EAEA,MAAMgB,aAAa,GAAGb,oBAAoB,CAACK,KAAD,CAA1C;EAEA,MAAMS,SAAS,GAAGlB,OAAO,CACrB,MAAMW,eAAe,CAACM,aAAD,EAAgBJ,SAAhB,CADA,EAErB,CAACF,eAAD,EAAkBM,aAAlB,CAFqB,CAAzB;EAKAlB,SAAS,CAAC,MAAM;IACZ,OAAOe,mBAAmB,CAACK,SAApB,CAA8BC,MAAM,IAAI;MAC3C,MAAMC,WAAW,GAAGD,MAAM,CAACE,IAAP,CAAY;QAAA,IAAC,CAACC,IAAD,EAAOC,EAAP,CAAD;QAAA,OAAgBf,KAAK,IAAIc,IAAT,IAAiBd,KAAK,IAAIe,EAA1C;MAAA,CAAZ,CAApB;MACAR,UAAU,CAACK,WAAD,CAAV;IACH,CAHM,CAAP;EAIH,CALQ,EAKN,CAACP,mBAAD,CALM,CAAT;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,QAAQ,EAAEC,OAAO,GAAGP,QAAQ,CAACS,aAAD,CAAX,GAA6B,IADlD;IAEI,QAAQ,EAAEP,QAFd;IAGI,KAAK,EAAE,CACH;MACIe,KAAK,EAAEZ,SADX;MAEIa,MAAM,EAAEd,UAAU,KAAK,MAAf,GAAwBA,UAAxB,GAAqCe;IAFjD,CADG,EAKHC,MAAM,CAACC,QALJ,EAMH;IACAX,SAPG;EAHX,EADJ;AAeH;AAAA;AAED,MAAMU,MAAM,GAAGzB,UAAU,CAAC2B,MAAX,CAAkB;EAC7BD,QAAQ,EAAE;IACNE,QAAQ,EAAE;EADJ;AADmB,CAAlB,CAAf"}
@@ -0,0 +1,65 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React, { forwardRef, memo, useState } from 'react';
4
+ import { Animated } from 'react-native';
5
+ import { StyleSheet } from '@fountain-ui/core';
6
+ import ItemView from './ItemView';
7
+ const styles = StyleSheet.create({
8
+ root: {
9
+ width: '100%',
10
+ justifyContent: 'center'
11
+ },
12
+ horizontal: {
13
+ flexDirection: 'row',
14
+ overflowX: 'hidden',
15
+ overflowY: 'visible'
16
+ }
17
+ });
18
+ const RootView = /*#__PURE__*/forwardRef(function RootView(props, ref) {
19
+ const {
20
+ data,
21
+ itemHeight,
22
+ originalData,
23
+ renderItem,
24
+ style,
25
+ ...otherProps
26
+ } = props;
27
+ const [maxHeightOfRenderedItems, setMaxHeightOfRenderedItems] = useState(0);
28
+
29
+ const handleItemLayout = e => {
30
+ const {
31
+ nativeEvent: {
32
+ layout: {
33
+ height
34
+ }
35
+ }
36
+ } = e;
37
+ const heightInt = Math.round(height);
38
+
39
+ if (heightInt > maxHeightOfRenderedItems) {
40
+ setMaxHeightOfRenderedItems(heightInt);
41
+ }
42
+ };
43
+
44
+ const renderItemView = (item, index) => /*#__PURE__*/React.createElement(ItemView, {
45
+ key: index,
46
+ index: index,
47
+ onLayout: itemHeight === 'auto' ? handleItemLayout : undefined
48
+ }, interpolation => renderItem({
49
+ item,
50
+ index: index % originalData.length,
51
+ interpolation
52
+ }));
53
+
54
+ const viewStyles = [styles.root, styles.horizontal, {
55
+ height: itemHeight === 'auto' ? maxHeightOfRenderedItems : itemHeight
56
+ }, style];
57
+ return /*#__PURE__*/React.createElement(Animated.View, _extends({
58
+ ref: ref
59
+ }, otherProps, {
60
+ children: data.map(renderItemView),
61
+ style: viewStyles
62
+ }));
63
+ });
64
+ export default /*#__PURE__*/memo(RootView);
65
+ //# sourceMappingURL=RootView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","memo","useState","Animated","StyleSheet","ItemView","styles","create","root","width","justifyContent","horizontal","flexDirection","overflowX","overflowY","RootView","props","ref","data","itemHeight","originalData","renderItem","style","otherProps","maxHeightOfRenderedItems","setMaxHeightOfRenderedItems","handleItemLayout","e","nativeEvent","layout","height","heightInt","Math","round","renderItemView","item","index","undefined","interpolation","length","viewStyles","map"],"sources":["RootView.tsx"],"sourcesContent":["import React, { forwardRef, memo, ReactElement, useState } from 'react';\nimport type { View, ViewProps, LayoutChangeEvent } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type { ItemHeight, RenderItem } from '../types';\nimport ItemView from './ItemView';\n\nconst styles = StyleSheet.create({\n root: {\n width: '100%',\n justifyContent: 'center',\n },\n horizontal: {\n flexDirection: 'row',\n overflowX: 'hidden',\n overflowY: 'visible',\n },\n});\n\nexport type RootViewProps<ItemT> = ViewProps & {\n data: ReadonlyArray<ItemT>;\n itemHeight: ItemHeight;\n originalData: ReadonlyArray<ItemT>;\n renderItem: RenderItem<ItemT>;\n};\n\nconst RootView = forwardRef<View, RootViewProps<any>>(function RootView(props, ref) {\n const {\n data,\n itemHeight,\n originalData,\n renderItem,\n style,\n ...otherProps\n } = props;\n\n const [maxHeightOfRenderedItems, setMaxHeightOfRenderedItems] = useState(0);\n\n const handleItemLayout = (e: LayoutChangeEvent) => {\n const { nativeEvent: { layout: { height } } } = e;\n\n const heightInt = Math.round(height);\n if (heightInt > maxHeightOfRenderedItems) {\n setMaxHeightOfRenderedItems(heightInt);\n }\n };\n\n const renderItemView = (item: any, index: number): ReactElement => (\n <ItemView\n key={index}\n index={index}\n onLayout={itemHeight === 'auto' ? handleItemLayout : undefined}\n >\n {(interpolation) => renderItem({\n item,\n index: index % originalData.length,\n interpolation,\n })}\n </ItemView>\n );\n\n const viewStyles = [\n styles.root,\n styles.horizontal,\n { height: itemHeight === 'auto' ? maxHeightOfRenderedItems : itemHeight },\n style,\n ];\n\n return (\n <Animated.View\n ref={ref}\n {...otherProps}\n children={data.map(renderItemView)}\n style={viewStyles}\n />\n );\n});\n\nexport default memo(RootView);\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,IAA5B,EAAgDC,QAAhD,QAAgE,OAAhE;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA,OAAOC,QAAP,MAAqB,YAArB;AAEA,MAAMC,MAAM,GAAGF,UAAU,CAACG,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,KAAK,EAAE,MADL;IAEFC,cAAc,EAAE;EAFd,CADuB;EAK7BC,UAAU,EAAE;IACRC,aAAa,EAAE,KADP;IAERC,SAAS,EAAE,QAFH;IAGRC,SAAS,EAAE;EAHH;AALiB,CAAlB,CAAf;AAmBA,MAAMC,QAAQ,gBAAGf,UAAU,CAA2B,SAASe,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EAChF,MAAM;IACFC,IADE;IAEFC,UAFE;IAGFC,YAHE;IAIFC,UAJE;IAKFC,KALE;IAMF,GAAGC;EAND,IAOFP,KAPJ;EASA,MAAM,CAACQ,wBAAD,EAA2BC,2BAA3B,IAA0DvB,QAAQ,CAAC,CAAD,CAAxE;;EAEA,MAAMwB,gBAAgB,GAAIC,CAAD,IAA0B;IAC/C,MAAM;MAAEC,WAAW,EAAE;QAAEC,MAAM,EAAE;UAAEC;QAAF;MAAV;IAAf,IAA0CH,CAAhD;IAEA,MAAMI,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,MAAX,CAAlB;;IACA,IAAIC,SAAS,GAAGP,wBAAhB,EAA0C;MACtCC,2BAA2B,CAACM,SAAD,CAA3B;IACH;EACJ,CAPD;;EASA,MAAMG,cAAc,GAAG,CAACC,IAAD,EAAYC,KAAZ,kBACnB,oBAAC,QAAD;IACI,GAAG,EAAEA,KADT;IAEI,KAAK,EAAEA,KAFX;IAGI,QAAQ,EAAEjB,UAAU,KAAK,MAAf,GAAwBO,gBAAxB,GAA2CW;EAHzD,GAKMC,aAAD,IAAmBjB,UAAU,CAAC;IAC3Bc,IAD2B;IAE3BC,KAAK,EAAEA,KAAK,GAAGhB,YAAY,CAACmB,MAFD;IAG3BD;EAH2B,CAAD,CALlC,CADJ;;EAcA,MAAME,UAAU,GAAG,CACflC,MAAM,CAACE,IADQ,EAEfF,MAAM,CAACK,UAFQ,EAGf;IAAEmB,MAAM,EAAEX,UAAU,KAAK,MAAf,GAAwBK,wBAAxB,GAAmDL;EAA7D,CAHe,EAIfG,KAJe,CAAnB;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,GAAG,EAAEL;EADT,GAEQM,UAFR;IAGI,QAAQ,EAAEL,IAAI,CAACuB,GAAL,CAASP,cAAT,CAHd;IAII,KAAK,EAAEM;EAJX,GADJ;AAQH,CAlD0B,CAA3B;AAoDA,4BAAevC,IAAI,CAACc,QAAD,CAAnB"}
@@ -0,0 +1,67 @@
1
+ import React, { useCallback } from 'react';
2
+ import { Animated } from 'react-native';
3
+ import { PanGestureHandler, State as GestureHandlerState } from 'react-native-gesture-handler';
4
+ const SCROLL_TO_ADJACENT_TX_THRESHOLD = 80;
5
+ const SCROLL_TO_ADJACENT_VX_THRESHOLD = 1000;
6
+ const ACTIVE_OFFSET_ABS_X = 5;
7
+ const activeOffsetX = [-ACTIVE_OFFSET_ABS_X, ACTIVE_OFFSET_ABS_X];
8
+ const endAnimationStates = [GestureHandlerState.CANCELLED, GestureHandlerState.END];
9
+
10
+ function shouldScrollToAdjacent(translationX, velocityX) {
11
+ const isSameDirection = translationX * velocityX > 0;
12
+ const isEnoughMovement = Math.abs(translationX) >= SCROLL_TO_ADJACENT_TX_THRESHOLD || Math.abs(velocityX) >= SCROLL_TO_ADJACENT_VX_THRESHOLD;
13
+ return isSameDirection && isEnoughMovement;
14
+ }
15
+
16
+ export default function ScrollViewGesture(props) {
17
+ const {
18
+ autoplayController,
19
+ children,
20
+ finalizeAnimation,
21
+ offsetTx,
22
+ scrollEnabled,
23
+ startPagingAnimation
24
+ } = props;
25
+ const {
26
+ pause: pauseAutoplay,
27
+ resume: resumeAutoplay
28
+ } = autoplayController;
29
+ const handleGestureBegin = useCallback(() => {
30
+ pauseAutoplay();
31
+ finalizeAnimation();
32
+ }, [finalizeAnimation, pauseAutoplay]);
33
+ const handleGestureEvent = useCallback(Animated.event([{
34
+ nativeEvent: {
35
+ translationX: offsetTx
36
+ }
37
+ }], {
38
+ useNativeDriver: true
39
+ }), []);
40
+ const handleHandlerStateChange = useCallback(event => {
41
+ const {
42
+ nativeEvent: {
43
+ translationX,
44
+ velocityX,
45
+ state
46
+ }
47
+ } = event;
48
+
49
+ if (endAnimationStates.includes(state)) {
50
+ const direction = shouldScrollToAdjacent(translationX, velocityX) ? translationX < 0 ? 'next' : 'prev' : 'stay';
51
+ startPagingAnimation('directional', {
52
+ direction: direction,
53
+ isOriginatedFromGesture: true
54
+ });
55
+ resumeAutoplay();
56
+ }
57
+ }, [startPagingAnimation, resumeAutoplay]);
58
+ return /*#__PURE__*/React.createElement(PanGestureHandler, {
59
+ activeOffsetX: activeOffsetX,
60
+ children: children,
61
+ enabled: scrollEnabled,
62
+ onBegan: handleGestureBegin,
63
+ onGestureEvent: handleGestureEvent,
64
+ onHandlerStateChange: handleHandlerStateChange
65
+ });
66
+ }
67
+ //# sourceMappingURL=ScrollViewGesture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","Animated","PanGestureHandler","State","GestureHandlerState","SCROLL_TO_ADJACENT_TX_THRESHOLD","SCROLL_TO_ADJACENT_VX_THRESHOLD","ACTIVE_OFFSET_ABS_X","activeOffsetX","endAnimationStates","CANCELLED","END","shouldScrollToAdjacent","translationX","velocityX","isSameDirection","isEnoughMovement","Math","abs","ScrollViewGesture","props","autoplayController","children","finalizeAnimation","offsetTx","scrollEnabled","startPagingAnimation","pause","pauseAutoplay","resume","resumeAutoplay","handleGestureBegin","handleGestureEvent","event","nativeEvent","useNativeDriver","handleHandlerStateChange","state","includes","direction","isOriginatedFromGesture"],"sources":["ScrollViewGesture.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport React, { useCallback } from 'react';\nimport { Animated } from 'react-native';\nimport type { PanGestureHandlerStateChangeEvent } from 'react-native-gesture-handler';\nimport { PanGestureHandler, State as GestureHandlerState } from 'react-native-gesture-handler';\nimport type { AutoplayController, PagingDirection, StartPagingAnimation } from '../types';\n\nexport interface ScrollViewGestureProps {\n autoplayController: AutoplayController;\n children: ReactNode;\n finalizeAnimation: () => void;\n offsetTx: Animated.Value,\n scrollEnabled: boolean;\n startPagingAnimation: StartPagingAnimation;\n}\n\nconst SCROLL_TO_ADJACENT_TX_THRESHOLD = 80;\nconst SCROLL_TO_ADJACENT_VX_THRESHOLD = 1000;\n\nconst ACTIVE_OFFSET_ABS_X = 5;\nconst activeOffsetX: number[] = [-ACTIVE_OFFSET_ABS_X, ACTIVE_OFFSET_ABS_X];\n\nconst endAnimationStates: Readonly<GestureHandlerState[]> = [\n GestureHandlerState.CANCELLED,\n GestureHandlerState.END,\n];\n\nfunction shouldScrollToAdjacent(translationX: number, velocityX: number): boolean {\n const isSameDirection = translationX * velocityX > 0;\n const isEnoughMovement =\n Math.abs(translationX) >= SCROLL_TO_ADJACENT_TX_THRESHOLD\n || Math.abs(velocityX) >= SCROLL_TO_ADJACENT_VX_THRESHOLD;\n\n return isSameDirection && isEnoughMovement;\n}\n\nexport default function ScrollViewGesture(props: ScrollViewGestureProps) {\n const {\n autoplayController,\n children,\n finalizeAnimation,\n offsetTx,\n scrollEnabled,\n startPagingAnimation,\n } = props;\n\n const { pause: pauseAutoplay, resume: resumeAutoplay } = autoplayController;\n\n const handleGestureBegin = useCallback(() => {\n pauseAutoplay();\n\n finalizeAnimation();\n }, [finalizeAnimation, pauseAutoplay]);\n\n const handleGestureEvent = useCallback(Animated.event(\n [{ nativeEvent: { translationX: offsetTx } }],\n { useNativeDriver: true },\n ), []);\n\n const handleHandlerStateChange = useCallback((event: PanGestureHandlerStateChangeEvent) => {\n const { nativeEvent: { translationX, velocityX, state } } = event;\n\n if (endAnimationStates.includes(state)) {\n const direction: PagingDirection = shouldScrollToAdjacent(translationX, velocityX)\n ? (translationX < 0 ? 'next' : 'prev')\n : 'stay';\n\n startPagingAnimation(\n 'directional',\n { direction: direction, isOriginatedFromGesture: true },\n );\n\n resumeAutoplay();\n }\n }, [startPagingAnimation, resumeAutoplay]);\n\n return (\n <PanGestureHandler\n activeOffsetX={activeOffsetX}\n children={children}\n enabled={scrollEnabled}\n onBegan={handleGestureBegin}\n onGestureEvent={handleGestureEvent}\n onHandlerStateChange={handleHandlerStateChange}\n />\n );\n}\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA,SAASC,iBAAT,EAA4BC,KAAK,IAAIC,mBAArC,QAAgE,8BAAhE;AAYA,MAAMC,+BAA+B,GAAG,EAAxC;AACA,MAAMC,+BAA+B,GAAG,IAAxC;AAEA,MAAMC,mBAAmB,GAAG,CAA5B;AACA,MAAMC,aA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,EAAwC;MACpC,MAAME,SAA0B,GAAG3B,sBAAsB,CAACC,YAAD,EAAeC,SAAf,CAAtB,GAC5BD,YAAY,GAAG,CAAf,GAAmB,MAAnB,GAA4B,MADA,GAE7B,MAFN;MAIAa,oBAAoB,CAChB,aADgB,EAEhB;QAAEa,SAAS,EAAEA,SAAb;QAAwBC,uBAAuB,EAAE;MAAjD,CAFgB,CAApB;MAKAV,cAAc;IACjB;EACJ,CAf2C,EAezC,CAACJ,oBAAD,EAAuBI,cAAvB,CAfyC,CAA5C;EAiBA,oBACI,oBAAC,iBAAD;IACI,aAAa,EAAEtB,aADnB;IAEI,QAAQ,EAAEc,QAFd;IAGI,OAAO,EAAEG,aAHb;IAII,OAAO,EAAEM,kBAJb;IAKI,cAAc,EAAEC,kBALpB;IAMI,oBAAoB,EAAEI;EAN1B,EADJ;AAUH"}
@@ -0,0 +1,5 @@
1
+ export { default as InternalContext } from './InternalContext';
2
+ export { default as ItemView } from './ItemView';
3
+ export { default as RootView } from './RootView';
4
+ export { default as ScrollViewGesture } from './ScrollViewGesture';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","InternalContext","ItemView","RootView","ScrollViewGesture"],"sources":["index.ts"],"sourcesContent":["export { default as InternalContext } from './InternalContext';\nexport { default as ItemView } from './ItemView';\nexport { default as RootView } from './RootView';\nexport { default as ScrollViewGesture } from './ScrollViewGesture';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,eAApB,QAA2C,mBAA3C;AACA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,SAASF,OAAO,IAAIG,QAApB,QAAoC,YAApC;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,qBAA7C"}
@@ -0,0 +1,8 @@
1
+ export { default as useAutoplayController } from './useAutoplayController';
2
+ export { default as useDimensionChangeReaction } from './useDimensionChangeReaction';
3
+ export { default as useIndexController } from './useIndexController';
4
+ export { default as useItemInterpolation } from './useItemInterpolation';
5
+ export { default as useLoopedData } from './useLoopedData';
6
+ export { default as usePagingAnimation } from './usePagingAnimation';
7
+ export { default as useItemVisibilityStore } from './useItemVisibilityStore';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","useAutoplayController","useDimensionChangeReaction","useIndexController","useItemInterpolation","useLoopedData","usePagingAnimation","useItemVisibilityStore"],"sources":["index.ts"],"sourcesContent":["export { default as useAutoplayController } from './useAutoplayController';\nexport { default as useDimensionChangeReaction } from './useDimensionChangeReaction';\nexport { default as useIndexController } from './useIndexController';\nexport { default as useItemInterpolation } from './useItemInterpolation';\nexport { default as useLoopedData } from './useLoopedData';\nexport { default as usePagingAnimation } from './usePagingAnimation';\nexport { default as useItemVisibilityStore } from './useItemVisibilityStore';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,qBAApB,QAAiD,yBAAjD;AACA,SAASD,OAAO,IAAIE,0BAApB,QAAsD,8BAAtD;AACA,SAASF,OAAO,IAAIG,kBAApB,QAA8C,sBAA9C;AACA,SAASH,OAAO,IAAII,oBAApB,QAAgD,wBAAhD;AACA,SAASJ,OAAO,IAAIK,aAApB,QAAyC,iBAAzC;AACA,SAASL,OAAO,IAAIM,kBAApB,QAA8C,sBAA9C;AACA,SAASN,OAAO,IAAIO,sBAApB,QAAkD,0BAAlD"}
@@ -0,0 +1,48 @@
1
+ import { useCallback, useEffect, useRef } from 'react';
2
+ import { useDeferredExecutor } from '../../hooks';
3
+ export default function useAutoplayController(config) {
4
+ const {
5
+ enabled,
6
+ intervalMillis,
7
+ startPagingAnimation
8
+ } = config;
9
+ const paused = useRef(false);
10
+ const executor = useDeferredExecutor();
11
+ const play = useCallback(() => {
12
+ if (paused.current) {
13
+ return;
14
+ }
15
+
16
+ executor.execute(() => {
17
+ startPagingAnimation('directional', {
18
+ direction: 'next',
19
+ isOriginatedFromGesture: false
20
+ });
21
+ play();
22
+ }, intervalMillis);
23
+ }, [intervalMillis, startPagingAnimation]);
24
+ const pause = useCallback(() => {
25
+ executor.cancel();
26
+ paused.current = true;
27
+ }, []);
28
+ const resume = useCallback(() => {
29
+ paused.current = false;
30
+
31
+ if (enabled) {
32
+ play();
33
+ }
34
+ }, [play, enabled]);
35
+ useEffect(() => {
36
+ if (enabled) {
37
+ resume();
38
+ } else {
39
+ pause();
40
+ }
41
+ }, [enabled]);
42
+ return {
43
+ pause,
44
+ resume
45
+ };
46
+ }
47
+ ;
48
+ //# sourceMappingURL=useAutoplayController.js.map