@fountain-ui/lab 2.0.0-beta.3 → 2.0.0-beta.30
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.
- package/build/commonjs/AnimatedY/AnimatedY.js +10 -14
- package/build/commonjs/AnimatedY/AnimatedY.js.map +1 -1
- package/build/commonjs/AnimatedY/AnimatedYProps.js.map +1 -1
- package/build/commonjs/AnimatedY/index.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheet.js +177 -0
- package/build/commonjs/BottomSheet/BottomSheet.js.map +1 -0
- package/build/commonjs/BottomSheet/BottomSheetNative.js +5 -3
- package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetWeb.js +19 -7
- package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
- package/build/commonjs/BottomSheet/TransparentBackdrop.js +1 -1
- package/build/commonjs/BottomSheet/TransparentBackdrop.js.map +1 -1
- package/build/commonjs/BottomSheet/index.js.map +1 -1
- package/build/commonjs/BottomSheet/index.native.js.map +1 -1
- package/build/commonjs/BottomSheet/useDynamicSnapPoints.js +49 -0
- package/build/commonjs/BottomSheet/useDynamicSnapPoints.js.map +1 -0
- package/build/commonjs/Carousel/Carousel.js +130 -0
- package/build/commonjs/Carousel/Carousel.js.map +1 -0
- package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
- package/build/commonjs/Carousel/animation/animationUtils.js +9 -0
- package/build/commonjs/Carousel/animation/animationUtils.js.map +1 -0
- package/build/commonjs/Carousel/animation/createDefaultItemStyle.js +15 -0
- package/build/commonjs/Carousel/animation/createDefaultItemStyle.js.map +1 -0
- package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +20 -0
- package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
- package/build/commonjs/Carousel/animation/index.js +40 -0
- package/build/commonjs/Carousel/animation/index.js.map +1 -0
- package/build/commonjs/Carousel/animation/normalItemStyleFactory.js +27 -0
- package/build/commonjs/Carousel/animation/normalItemStyleFactory.js.map +1 -0
- package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +65 -0
- package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
- package/build/commonjs/Carousel/components/InternalContext.js +29 -0
- package/build/commonjs/Carousel/components/InternalContext.js.map +1 -0
- package/build/commonjs/Carousel/components/ItemView.js +66 -0
- package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
- package/build/commonjs/Carousel/components/RootView.js +86 -0
- package/build/commonjs/Carousel/components/RootView.js.map +1 -0
- package/build/commonjs/Carousel/components/ScrollViewGesture.js +82 -0
- package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -0
- package/build/commonjs/Carousel/components/index.js +40 -0
- package/build/commonjs/Carousel/components/index.js.map +1 -0
- package/build/commonjs/Carousel/components/useItemInterpolation.js +65 -0
- package/build/commonjs/Carousel/components/useItemInterpolation.js.map +1 -0
- package/build/commonjs/Carousel/hooks/index.js +48 -0
- package/build/commonjs/Carousel/hooks/index.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useAutoplayController.js +58 -0
- package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useIndexController.js +55 -0
- package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +95 -0
- package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useLoopedData.js +33 -0
- package/build/commonjs/Carousel/hooks/useLoopedData.js.map +1 -0
- package/build/commonjs/Carousel/hooks/usePagingAnimator.js +202 -0
- package/build/commonjs/Carousel/hooks/usePagingAnimator.js.map +1 -0
- package/build/commonjs/Carousel/index.js +16 -2
- package/build/commonjs/Carousel/index.js.map +1 -1
- package/build/commonjs/Carousel/tick.js +16 -0
- package/build/commonjs/Carousel/tick.js.map +1 -0
- package/build/commonjs/Carousel/types.js +8 -0
- package/build/commonjs/Carousel/types.js.map +1 -0
- package/build/commonjs/ComicViewer/ComicViewer.js +71 -37
- package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
- package/build/commonjs/ComicViewer/ComicViewerItemProps.js.map +1 -1
- package/build/commonjs/ComicViewer/ComicViewerProps.js +12 -0
- package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
- package/build/commonjs/ComicViewer/ViewerItem.js +98 -26
- package/build/commonjs/ComicViewer/ViewerItem.js.map +1 -1
- package/build/commonjs/ComicViewer/index.js.map +1 -1
- package/build/commonjs/DateTimePicker/DateTimePicker.js +2 -2
- package/build/commonjs/DateTimePicker/DateTimePicker.js.map +1 -1
- package/build/commonjs/DateTimePicker/DateTimePickerProps.js.map +1 -1
- package/build/commonjs/DateTimePicker/DateTimePickerProvider.js.map +1 -1
- package/build/commonjs/DateTimePicker/YearPicker.js +21 -17
- package/build/commonjs/DateTimePicker/YearPicker.js.map +1 -1
- package/build/commonjs/DateTimePicker/index.js +4 -4
- package/build/commonjs/DateTimePicker/index.js.map +1 -1
- package/build/commonjs/DateTimePicker/utils.js +2 -1
- package/build/commonjs/DateTimePicker/utils.js.map +1 -1
- package/build/commonjs/FlipCard/FlipCard.js +7 -13
- package/build/commonjs/FlipCard/FlipCard.js.map +1 -1
- package/build/commonjs/FlipCard/FlipCardProps.js.map +1 -1
- package/build/commonjs/FlipCard/index.js.map +1 -1
- package/build/commonjs/StatusBarProvider/Provider.js +1 -1
- package/build/commonjs/StatusBarProvider/Provider.js.map +1 -1
- package/build/commonjs/StatusBarProvider/StatusBarProvider.js.map +1 -1
- package/build/commonjs/StatusBarProvider/StatusBarProviderProps.js.map +1 -1
- package/build/commonjs/StatusBarProvider/index.js.map +1 -1
- package/build/commonjs/ViewPager/FluxContext.js +13 -0
- package/build/commonjs/ViewPager/FluxContext.js.map +1 -0
- package/build/commonjs/ViewPager/InternalContext.js +17 -0
- package/build/commonjs/ViewPager/InternalContext.js.map +1 -0
- package/build/commonjs/ViewPager/PageStateContext.js +16 -0
- package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
- package/build/commonjs/ViewPager/ViewPager.js +81 -0
- package/build/commonjs/ViewPager/ViewPager.js.map +1 -0
- package/build/commonjs/ViewPager/ViewPager.native.js +150 -0
- package/build/commonjs/ViewPager/ViewPager.native.js.map +1 -0
- package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
- package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js +122 -0
- package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
- package/build/commonjs/ViewPager/components/FluxStoreProvider.js +37 -0
- package/build/commonjs/ViewPager/components/FluxStoreProvider.js.map +1 -0
- package/build/commonjs/ViewPager/components/index.js +24 -0
- package/build/commonjs/ViewPager/components/index.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/index.js +64 -0
- package/build/commonjs/ViewPager/hooks/index.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useDispatch.js +22 -0
- package/build/commonjs/ViewPager/hooks/useDispatch.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useEagerState.js +24 -0
- package/build/commonjs/ViewPager/hooks/useEagerState.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useForceRender.js +16 -0
- package/build/commonjs/ViewPager/hooks/useForceRender.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useLazyState.js +45 -0
- package/build/commonjs/ViewPager/hooks/useLazyState.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/usePageStore.js +35 -0
- package/build/commonjs/ViewPager/hooks/usePageStore.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useStore.js +26 -0
- package/build/commonjs/ViewPager/hooks/useStore.js.map +1 -0
- package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js +19 -0
- package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
- package/build/commonjs/ViewPager/index.js +42 -2
- package/build/commonjs/ViewPager/index.js.map +1 -1
- package/build/commonjs/ViewPager/types.js +2 -0
- package/build/commonjs/ViewPager/types.js.map +1 -0
- package/build/commonjs/ViewPager/utils.js +12 -43
- package/build/commonjs/ViewPager/utils.js.map +1 -1
- package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
- package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
- package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
- package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
- package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
- package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
- package/build/commonjs/hooks/index.js +16 -0
- package/build/commonjs/hooks/index.js.map +1 -1
- package/build/commonjs/hooks/useAppbarStyles.js.map +1 -1
- package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
- package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
- package/build/commonjs/hooks/useElevationStyle.js.map +1 -1
- package/build/commonjs/hooks/useHeight.js +5 -4
- package/build/commonjs/hooks/useHeight.js.map +1 -1
- package/build/commonjs/hooks/useIsMounted.js +22 -0
- package/build/commonjs/hooks/useIsMounted.js.map +1 -0
- package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +58 -61
- package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
- package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js +9 -11
- package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
- package/build/commonjs/index.js +28 -7
- package/build/commonjs/index.js.map +1 -1
- package/build/module/AnimatedY/AnimatedY.js +11 -10
- package/build/module/AnimatedY/AnimatedY.js.map +1 -1
- package/build/module/AnimatedY/AnimatedYProps.js.map +1 -1
- package/build/module/AnimatedY/index.js.map +1 -1
- package/build/module/BottomSheet/BottomSheet.js +161 -0
- package/build/module/BottomSheet/BottomSheet.js.map +1 -0
- package/build/module/BottomSheet/BottomSheetNative.js +5 -3
- package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetWeb.js +18 -7
- package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
- package/build/module/BottomSheet/TransparentBackdrop.js +1 -1
- package/build/module/BottomSheet/TransparentBackdrop.js.map +1 -1
- package/build/module/BottomSheet/index.js.map +1 -1
- package/build/module/BottomSheet/index.native.js.map +1 -1
- package/build/module/BottomSheet/useDynamicSnapPoints.js +41 -0
- package/build/module/BottomSheet/useDynamicSnapPoints.js.map +1 -0
- package/build/module/Carousel/Carousel.js +109 -0
- package/build/module/Carousel/Carousel.js.map +1 -0
- package/build/module/Carousel/CarouselProps.js.map +1 -1
- package/build/module/Carousel/animation/animationUtils.js +2 -0
- package/build/module/Carousel/animation/animationUtils.js.map +1 -0
- package/build/module/Carousel/animation/createDefaultItemStyle.js +3 -0
- package/build/module/Carousel/animation/createDefaultItemStyle.js.map +1 -0
- package/build/module/Carousel/animation/createDefaultScrollAnimation.js +11 -0
- package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
- package/build/module/Carousel/animation/index.js +5 -0
- package/build/module/Carousel/animation/index.js.map +1 -0
- package/build/module/Carousel/animation/normalItemStyleFactory.js +18 -0
- package/build/module/Carousel/animation/normalItemStyleFactory.js.map +1 -0
- package/build/module/Carousel/animation/parallaxItemStyleFactory.js +55 -0
- package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
- package/build/module/Carousel/components/InternalContext.js +19 -0
- package/build/module/Carousel/components/InternalContext.js.map +1 -0
- package/build/module/Carousel/components/ItemView.js +46 -0
- package/build/module/Carousel/components/ItemView.js.map +1 -0
- package/build/module/Carousel/components/RootView.js +65 -0
- package/build/module/Carousel/components/RootView.js.map +1 -0
- package/build/module/Carousel/components/ScrollViewGesture.js +68 -0
- package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -0
- package/build/module/Carousel/components/index.js +5 -0
- package/build/module/Carousel/components/index.js.map +1 -0
- package/build/module/Carousel/components/useItemInterpolation.js +51 -0
- package/build/module/Carousel/components/useItemInterpolation.js.map +1 -0
- package/build/module/Carousel/hooks/index.js +6 -0
- package/build/module/Carousel/hooks/index.js.map +1 -0
- package/build/module/Carousel/hooks/useAutoplayController.js +48 -0
- package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
- package/build/module/Carousel/hooks/useIndexController.js +44 -0
- package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
- package/build/module/Carousel/hooks/useItemVisibilityStore.js +86 -0
- package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
- package/build/module/Carousel/hooks/useLoopedData.js +24 -0
- package/build/module/Carousel/hooks/useLoopedData.js.map +1 -0
- package/build/module/Carousel/hooks/usePagingAnimator.js +192 -0
- package/build/module/Carousel/hooks/usePagingAnimator.js.map +1 -0
- package/build/module/Carousel/index.js +2 -1
- package/build/module/Carousel/index.js.map +1 -1
- package/build/module/Carousel/tick.js +6 -0
- package/build/module/Carousel/tick.js.map +1 -0
- package/build/module/Carousel/types.js +4 -0
- package/build/module/Carousel/types.js.map +1 -0
- package/build/module/ComicViewer/ComicViewer.js +70 -37
- package/build/module/ComicViewer/ComicViewer.js.map +1 -1
- package/build/module/ComicViewer/ComicViewerItemProps.js.map +1 -1
- package/build/module/ComicViewer/ComicViewerProps.js +6 -1
- package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
- package/build/module/ComicViewer/ViewerItem.js +99 -28
- package/build/module/ComicViewer/ViewerItem.js.map +1 -1
- package/build/module/ComicViewer/index.js.map +1 -1
- package/build/module/DateTimePicker/DateTimePicker.js +2 -2
- package/build/module/DateTimePicker/DateTimePicker.js.map +1 -1
- package/build/module/DateTimePicker/DateTimePickerProps.js.map +1 -1
- package/build/module/DateTimePicker/DateTimePickerProvider.js.map +1 -1
- package/build/module/DateTimePicker/YearPicker.js +21 -17
- package/build/module/DateTimePicker/YearPicker.js.map +1 -1
- package/build/module/DateTimePicker/index.js.map +1 -1
- package/build/module/DateTimePicker/utils.js +2 -1
- package/build/module/DateTimePicker/utils.js.map +1 -1
- package/build/module/FlipCard/FlipCard.js +7 -7
- package/build/module/FlipCard/FlipCard.js.map +1 -1
- package/build/module/FlipCard/FlipCardProps.js.map +1 -1
- package/build/module/FlipCard/index.js.map +1 -1
- package/build/module/StatusBarProvider/Provider.js.map +1 -1
- package/build/module/StatusBarProvider/StatusBarProvider.js.map +1 -1
- package/build/module/StatusBarProvider/StatusBarProviderProps.js.map +1 -1
- package/build/module/StatusBarProvider/index.js.map +1 -1
- package/build/module/ViewPager/FluxContext.js +4 -0
- package/build/module/ViewPager/FluxContext.js.map +1 -0
- package/build/module/ViewPager/InternalContext.js +7 -0
- package/build/module/ViewPager/InternalContext.js.map +1 -0
- package/build/module/ViewPager/PageStateContext.js +7 -0
- package/build/module/ViewPager/PageStateContext.js.map +1 -0
- package/build/module/ViewPager/ViewPager.js +57 -0
- package/build/module/ViewPager/ViewPager.js.map +1 -0
- package/build/module/ViewPager/ViewPager.native.js +127 -0
- package/build/module/ViewPager/ViewPager.native.js.map +1 -0
- package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
- package/build/module/ViewPager/components/ChildrenMemoizedPage.js +101 -0
- package/build/module/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
- package/build/module/ViewPager/components/FluxStoreProvider.js +20 -0
- package/build/module/ViewPager/components/FluxStoreProvider.js.map +1 -0
- package/build/module/ViewPager/components/index.js +3 -0
- package/build/module/ViewPager/components/index.js.map +1 -0
- package/build/module/ViewPager/hooks/index.js +8 -0
- package/build/module/ViewPager/hooks/index.js.map +1 -0
- package/build/module/ViewPager/hooks/useDispatch.js +10 -0
- package/build/module/ViewPager/hooks/useDispatch.js.map +1 -0
- package/build/module/ViewPager/hooks/useEagerState.js +12 -0
- package/build/module/ViewPager/hooks/useEagerState.js.map +1 -0
- package/build/module/ViewPager/hooks/useForceRender.js +7 -0
- package/build/module/ViewPager/hooks/useForceRender.js.map +1 -0
- package/build/module/ViewPager/hooks/useLazyState.js +30 -0
- package/build/module/ViewPager/hooks/useLazyState.js.map +1 -0
- package/build/module/ViewPager/hooks/usePageStore.js +25 -0
- package/build/module/ViewPager/hooks/usePageStore.js.map +1 -0
- package/build/module/ViewPager/hooks/useStore.js +14 -0
- package/build/module/ViewPager/hooks/useStore.js.map +1 -0
- package/build/module/ViewPager/hooks/useViewPagerPageState.js +7 -0
- package/build/module/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
- package/build/module/ViewPager/index.js +3 -1
- package/build/module/ViewPager/index.js.map +1 -1
- package/build/module/ViewPager/types.js +2 -0
- package/build/module/ViewPager/types.js.map +1 -0
- package/build/module/ViewPager/utils.js +6 -33
- package/build/module/ViewPager/utils.js.map +1 -1
- package/build/module/ViewabilityTrackerView/Viewability.js +2 -0
- package/build/module/ViewabilityTrackerView/Viewability.js.map +1 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js +28 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
- package/build/module/ViewabilityTrackerView/index.js +2 -0
- package/build/module/ViewabilityTrackerView/index.js.map +1 -0
- package/build/module/ViewabilityTrackerView/measureViewability.js +34 -0
- package/build/module/ViewabilityTrackerView/measureViewability.js.map +1 -0
- package/build/module/ViewabilityTrackerView/useViewabilityTracker.js +73 -0
- package/build/module/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
- package/build/module/hooks/index.js +2 -0
- package/build/module/hooks/index.js.map +1 -1
- package/build/module/hooks/useAppbarStyles.js.map +1 -1
- package/build/module/hooks/useDeferredExecutor.js +33 -0
- package/build/module/hooks/useDeferredExecutor.js.map +1 -0
- package/build/module/hooks/useElevationStyle.js.map +1 -1
- package/build/module/hooks/useHeight.js +4 -3
- package/build/module/hooks/useHeight.js.map +1 -1
- package/build/module/hooks/useIsMounted.js +13 -0
- package/build/module/hooks/useIsMounted.js.map +1 -0
- package/build/module/hooks/useUnstableCollapsibleAppBar.js +58 -45
- package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
- package/build/module/hooks/useUnstableToggleDisplayStyle.js +9 -7
- package/build/module/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
- package/build/module/index.js +2 -0
- package/build/module/index.js.map +1 -1
- package/build/typescript/AnimatedY/AnimatedY.d.ts +0 -1
- package/build/typescript/BottomSheet/BottomSheet.d.ts +2 -0
- package/build/typescript/BottomSheet/BottomSheetNative.d.ts +0 -1
- package/build/typescript/BottomSheet/BottomSheetProps.d.ts +6 -1
- package/build/typescript/BottomSheet/BottomSheetWeb.d.ts +0 -1
- package/build/typescript/BottomSheet/TransparentBackdrop.d.ts +0 -1
- package/build/typescript/BottomSheet/useDynamicSnapPoints.d.ts +11 -0
- package/build/typescript/Carousel/Carousel.d.ts +5 -0
- package/build/typescript/Carousel/CarouselProps.d.ts +33 -48
- package/build/typescript/Carousel/animation/animationUtils.d.ts +1 -0
- package/build/typescript/Carousel/animation/createDefaultItemStyle.d.ts +2 -0
- package/build/typescript/Carousel/animation/createDefaultScrollAnimation.d.ts +2 -0
- package/build/typescript/Carousel/animation/index.d.ts +4 -0
- package/build/typescript/Carousel/animation/normalItemStyleFactory.d.ts +2 -0
- package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +9 -0
- package/build/typescript/Carousel/components/InternalContext.d.ts +14 -0
- package/build/typescript/Carousel/components/ItemView.d.ts +9 -0
- package/build/typescript/Carousel/components/RootView.d.ts +16 -0
- package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +12 -0
- package/build/typescript/Carousel/components/index.d.ts +4 -0
- package/build/typescript/Carousel/components/useItemInterpolation.d.ts +2 -0
- package/build/typescript/Carousel/hooks/index.d.ts +5 -0
- package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
- package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useLoopedData.d.ts +1 -0
- package/build/typescript/Carousel/hooks/usePagingAnimator.d.ts +17 -0
- package/build/typescript/Carousel/index.d.ts +3 -1
- package/build/typescript/Carousel/tick.d.ts +2 -0
- package/build/typescript/Carousel/types.d.ts +91 -0
- package/build/typescript/ComicViewer/ComicViewer.d.ts +0 -1
- package/build/typescript/ComicViewer/ComicViewerItemProps.d.ts +12 -1
- package/build/typescript/ComicViewer/ComicViewerProps.d.ts +61 -12
- package/build/typescript/DateTimePicker/DateTimePicker.d.ts +0 -1
- package/build/typescript/DateTimePicker/YearPicker.d.ts +0 -1
- package/build/typescript/FlipCard/FlipCard.d.ts +0 -1
- package/build/typescript/StatusBarProvider/StatusBarProvider.d.ts +0 -1
- package/build/typescript/ViewPager/FluxContext.d.ts +5 -0
- package/build/typescript/ViewPager/InternalContext.d.ts +7 -0
- package/build/typescript/ViewPager/PageStateContext.d.ts +6 -0
- package/build/typescript/ViewPager/ViewPager.d.ts +5 -0
- package/build/typescript/ViewPager/ViewPager.native.d.ts +5 -0
- package/build/typescript/ViewPager/ViewPagerProps.d.ts +18 -29
- package/build/typescript/ViewPager/components/ChildrenMemoizedPage.d.ts +14 -0
- package/build/typescript/ViewPager/components/FluxStoreProvider.d.ts +6 -0
- package/build/typescript/ViewPager/components/index.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/index.d.ts +7 -0
- package/build/typescript/ViewPager/hooks/useDispatch.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/useEagerState.d.ts +1 -0
- package/build/typescript/ViewPager/hooks/useForceRender.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/useLazyState.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/usePageStore.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/useStore.d.ts +2 -0
- package/build/typescript/ViewPager/hooks/useViewPagerPageState.d.ts +1 -0
- package/build/typescript/ViewPager/index.d.ts +4 -1
- package/build/typescript/ViewPager/types.d.ts +12 -0
- package/build/typescript/ViewPager/utils.d.ts +5 -20
- package/build/typescript/ViewabilityTrackerView/Viewability.d.ts +3 -0
- package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +2 -0
- package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerViewProps.d.ts +22 -0
- package/build/typescript/ViewabilityTrackerView/index.d.ts +2 -0
- package/build/typescript/ViewabilityTrackerView/measureViewability.d.ts +11 -0
- package/build/typescript/ViewabilityTrackerView/useViewabilityTracker.d.ts +11 -0
- package/build/typescript/hooks/index.d.ts +2 -0
- package/build/typescript/hooks/useDeferredExecutor.d.ts +11 -0
- package/build/typescript/hooks/useIsMounted.d.ts +4 -0
- package/build/typescript/hooks/useUnstableCollapsibleAppBar.d.ts +2 -3
- package/build/typescript/hooks/useUnstableToggleDisplayStyle.d.ts +2 -2
- package/build/typescript/index.d.ts +2 -0
- package/package.json +11 -25
- package/src/AnimatedY/AnimatedY.tsx +13 -10
- package/src/BottomSheet/BottomSheet.tsx +184 -0
- package/src/BottomSheet/BottomSheetNative.tsx +2 -0
- package/src/BottomSheet/BottomSheetProps.ts +7 -1
- package/src/BottomSheet/BottomSheetWeb.tsx +18 -5
- package/src/BottomSheet/useDynamicSnapPoints.ts +52 -0
- package/src/Carousel/Carousel.tsx +135 -0
- package/src/Carousel/CarouselProps.ts +42 -53
- package/src/Carousel/animation/animationUtils.ts +1 -0
- package/src/Carousel/animation/createDefaultItemStyle.ts +3 -0
- package/src/Carousel/animation/createDefaultScrollAnimation.ts +13 -0
- package/src/Carousel/animation/index.ts +4 -0
- package/src/Carousel/animation/normalItemStyleFactory.ts +19 -0
- package/src/Carousel/animation/parallaxItemStyleFactory.ts +79 -0
- package/src/Carousel/components/InternalContext.ts +33 -0
- package/src/Carousel/components/ItemView.tsx +66 -0
- package/src/Carousel/components/RootView.tsx +79 -0
- package/src/Carousel/components/ScrollViewGesture.tsx +92 -0
- package/src/Carousel/components/index.ts +4 -0
- package/src/Carousel/components/useItemInterpolation.ts +107 -0
- package/src/Carousel/hooks/index.ts +5 -0
- package/src/Carousel/hooks/useAutoplayController.ts +57 -0
- package/src/Carousel/hooks/useIndexController.tsx +57 -0
- package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
- package/src/Carousel/hooks/useLoopedData.ts +26 -0
- package/src/Carousel/hooks/usePagingAnimator.ts +255 -0
- package/src/Carousel/index.ts +4 -2
- package/src/Carousel/tick.ts +6 -0
- package/src/Carousel/types.ts +114 -0
- package/src/ComicViewer/ComicViewer.tsx +70 -30
- package/src/ComicViewer/ComicViewerItemProps.ts +16 -1
- package/src/ComicViewer/ComicViewerProps.ts +70 -10
- package/src/ComicViewer/ViewerItem.tsx +107 -27
- package/src/DateTimePicker/DateTimePicker.tsx +2 -2
- package/src/FlipCard/FlipCard.tsx +8 -8
- package/src/ViewPager/FluxContext.ts +8 -0
- package/src/ViewPager/InternalContext.ts +13 -0
- package/src/ViewPager/PageStateContext.ts +11 -0
- package/src/ViewPager/ViewPager.native.tsx +150 -0
- package/src/ViewPager/ViewPager.tsx +69 -0
- package/src/ViewPager/ViewPagerProps.ts +20 -35
- package/src/ViewPager/components/ChildrenMemoizedPage.tsx +124 -0
- package/src/ViewPager/components/FluxStoreProvider.tsx +27 -0
- package/src/ViewPager/components/index.ts +2 -0
- package/src/ViewPager/hooks/index.ts +7 -0
- package/src/ViewPager/hooks/useDispatch.ts +11 -0
- package/src/ViewPager/hooks/useEagerState.ts +14 -0
- package/src/ViewPager/hooks/useForceRender.ts +7 -0
- package/src/ViewPager/hooks/useLazyState.ts +32 -0
- package/src/ViewPager/hooks/usePageStore.ts +30 -0
- package/src/ViewPager/hooks/useStore.ts +15 -0
- package/src/ViewPager/hooks/useViewPagerPageState.ts +6 -0
- package/src/ViewPager/index.ts +11 -2
- package/src/ViewPager/types.ts +15 -0
- package/src/ViewPager/utils.tsx +9 -56
- package/src/ViewabilityTrackerView/Viewability.ts +3 -0
- package/src/ViewabilityTrackerView/ViewabilityTrackerView.tsx +33 -0
- package/src/ViewabilityTrackerView/ViewabilityTrackerViewProps.ts +25 -0
- package/src/ViewabilityTrackerView/index.ts +2 -0
- package/src/ViewabilityTrackerView/measureViewability.ts +54 -0
- package/src/ViewabilityTrackerView/useViewabilityTracker.ts +85 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useDeferredExecutor.ts +46 -0
- package/src/hooks/useHeight.ts +2 -2
- package/src/hooks/useIsMounted.ts +19 -0
- package/src/hooks/useUnstableCollapsibleAppBar.ts +62 -45
- package/src/hooks/useUnstableToggleDisplayStyle.ts +8 -6
- package/src/index.ts +3 -0
- package/build/commonjs/Carousel/CarouselNative.js +0 -72
- package/build/commonjs/Carousel/CarouselNative.js.map +0 -1
- package/build/commonjs/Carousel/CarouselWeb.js +0 -237
- package/build/commonjs/Carousel/CarouselWeb.js.map +0 -1
- package/build/commonjs/Carousel/index.native.js.map +0 -1
- package/build/commonjs/Carousel/utils.js +0 -19
- package/build/commonjs/Carousel/utils.js.map +0 -1
- package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +0 -49
- package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +0 -1
- package/build/commonjs/ViewPager/ViewPagerNative.js +0 -72
- package/build/commonjs/ViewPager/ViewPagerNative.js.map +0 -1
- package/build/commonjs/ViewPager/ViewPagerWeb.js +0 -55
- package/build/commonjs/ViewPager/ViewPagerWeb.js.map +0 -1
- package/build/commonjs/ViewPager/index.native.js +0 -16
- package/build/commonjs/ViewPager/index.native.js.map +0 -1
- package/build/commonjs/hooks/useWidth.js +0 -29
- package/build/commonjs/hooks/useWidth.js.map +0 -1
- package/build/module/Carousel/CarouselNative.js +0 -54
- package/build/module/Carousel/CarouselNative.js.map +0 -1
- package/build/module/Carousel/CarouselWeb.js +0 -215
- package/build/module/Carousel/CarouselWeb.js.map +0 -1
- package/build/module/Carousel/index.native.js +0 -2
- package/build/module/Carousel/index.native.js.map +0 -1
- package/build/module/Carousel/utils.js +0 -7
- package/build/module/Carousel/utils.js.map +0 -1
- package/build/module/ViewPager/ChildrenMemoizedPage.js +0 -37
- package/build/module/ViewPager/ChildrenMemoizedPage.js.map +0 -1
- package/build/module/ViewPager/ViewPagerNative.js +0 -53
- package/build/module/ViewPager/ViewPagerNative.js.map +0 -1
- package/build/module/ViewPager/ViewPagerWeb.js +0 -41
- package/build/module/ViewPager/ViewPagerWeb.js.map +0 -1
- package/build/module/ViewPager/index.native.js +0 -2
- package/build/module/ViewPager/index.native.js.map +0 -1
- package/build/module/hooks/useWidth.js +0 -15
- package/build/module/hooks/useWidth.js.map +0 -1
- package/build/typescript/Carousel/CarouselNative.d.ts +0 -3
- package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
- package/build/typescript/Carousel/index.native.d.ts +0 -1
- package/build/typescript/Carousel/utils.d.ts +0 -6
- package/build/typescript/ViewPager/ChildrenMemoizedPage.d.ts +0 -4
- package/build/typescript/ViewPager/ViewPagerNative.d.ts +0 -3
- package/build/typescript/ViewPager/ViewPagerWeb.d.ts +0 -3
- package/build/typescript/ViewPager/index.native.d.ts +0 -1
- package/build/typescript/hooks/useWidth.d.ts +0 -2
- package/src/Carousel/CarouselNative.tsx +0 -67
- package/src/Carousel/CarouselWeb.tsx +0 -222
- package/src/Carousel/index.native.ts +0 -1
- package/src/Carousel/utils.ts +0 -11
- package/src/ViewPager/ChildrenMemoizedPage.tsx +0 -36
- package/src/ViewPager/ViewPagerNative.tsx +0 -66
- package/src/ViewPager/ViewPagerWeb.tsx +0 -52
- package/src/ViewPager/index.native.ts +0 -1
- package/src/hooks/useWidth.ts +0 -17
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import { useAnimatedValue } from '@fountain-ui/core';
|
|
4
|
+
import type {
|
|
5
|
+
CreateScrollAnimation,
|
|
6
|
+
DirectionalPagingAnimationConfig,
|
|
7
|
+
IndexController,
|
|
8
|
+
IndexPagingAnimationConfig,
|
|
9
|
+
PagingAnimationConfig,
|
|
10
|
+
PagingAnimationType,
|
|
11
|
+
PagingDirection,
|
|
12
|
+
StartPagingAnimation,
|
|
13
|
+
} from '../types';
|
|
14
|
+
|
|
15
|
+
export interface PagingAnimatorConfig {
|
|
16
|
+
createScrollAnimation: CreateScrollAnimation;
|
|
17
|
+
itemWidth: number;
|
|
18
|
+
indexController: IndexController;
|
|
19
|
+
initialIndex: number;
|
|
20
|
+
loop: boolean;
|
|
21
|
+
numberOfData: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface PagingAnimator {
|
|
25
|
+
gestureTranslationX: Animated.Value;
|
|
26
|
+
globalInterpolation: Animated.AnimatedInterpolation;
|
|
27
|
+
interruptAnimation: () => void;
|
|
28
|
+
startPagingAnimation: StartPagingAnimation;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function directionToValue(itemWidth: number) {
|
|
32
|
+
return function (direction: PagingDirection): number {
|
|
33
|
+
switch (direction) {
|
|
34
|
+
case 'next':
|
|
35
|
+
return -itemWidth;
|
|
36
|
+
case 'prev':
|
|
37
|
+
return itemWidth;
|
|
38
|
+
case 'stay':
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function toValueCompensator(itemWidth: number) {
|
|
45
|
+
return function (toValue: number, currentOffset: number): number {
|
|
46
|
+
const remainder = Math.abs(currentOffset % itemWidth);
|
|
47
|
+
|
|
48
|
+
const halfOfItemWidth = Math.abs(itemWidth / 2);
|
|
49
|
+
const compensateVector = remainder > halfOfItemWidth
|
|
50
|
+
? remainder - itemWidth
|
|
51
|
+
: remainder;
|
|
52
|
+
|
|
53
|
+
const direction = currentOffset > 0 ? -1 : 1;
|
|
54
|
+
|
|
55
|
+
return toValue + (direction * compensateVector);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default function usePagingAnimator(config: PagingAnimatorConfig): PagingAnimator {
|
|
60
|
+
const {
|
|
61
|
+
createScrollAnimation,
|
|
62
|
+
itemWidth,
|
|
63
|
+
indexController,
|
|
64
|
+
initialIndex,
|
|
65
|
+
loop,
|
|
66
|
+
numberOfData,
|
|
67
|
+
} = config;
|
|
68
|
+
|
|
69
|
+
const {
|
|
70
|
+
getCurrentIndex,
|
|
71
|
+
lastIndex,
|
|
72
|
+
notifyScrollStateHasChanged,
|
|
73
|
+
} = indexController;
|
|
74
|
+
|
|
75
|
+
const initialOffsetX = itemWidth * initialIndex;
|
|
76
|
+
const accumulativeOffsetX = useAnimatedValue(initialOffsetX);
|
|
77
|
+
const animationOffsetX = useAnimatedValue(0);
|
|
78
|
+
const gestureTranslationX = useAnimatedValue(0);
|
|
79
|
+
|
|
80
|
+
const globalInterpolation = useMemo(() => {
|
|
81
|
+
return Animated.add(
|
|
82
|
+
Animated.add(accumulativeOffsetX, animationOffsetX),
|
|
83
|
+
gestureTranslationX,
|
|
84
|
+
);
|
|
85
|
+
}, []);
|
|
86
|
+
|
|
87
|
+
const toValueRef = useRef<number>(0);
|
|
88
|
+
const currentOffsetRef = useRef<number>(0);
|
|
89
|
+
|
|
90
|
+
const isAnimatingRef = useRef<boolean>(false);
|
|
91
|
+
|
|
92
|
+
const maxWidth = Math.abs(numberOfData * itemWidth);
|
|
93
|
+
|
|
94
|
+
const ensureOffsetBoundary: (offset: number) => number = useCallback((offset: number) => {
|
|
95
|
+
if (loop) {
|
|
96
|
+
const isCloseToEnd = Math.abs(offset) >= (maxWidth - itemWidth);
|
|
97
|
+
if (isCloseToEnd) {
|
|
98
|
+
const signOfOffset = offset > 0 ? 1 : -1;
|
|
99
|
+
return offset + (-signOfOffset * maxWidth);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return offset % maxWidth;
|
|
104
|
+
}, [itemWidth, loop, maxWidth]);
|
|
105
|
+
|
|
106
|
+
const requireNewOffset = useCallback((newOffset: number) => {
|
|
107
|
+
const nextOffset = ensureOffsetBoundary(newOffset);
|
|
108
|
+
|
|
109
|
+
currentOffsetRef.current = nextOffset;
|
|
110
|
+
accumulativeOffsetX.setValue(nextOffset);
|
|
111
|
+
|
|
112
|
+
toValueRef.current = 0;
|
|
113
|
+
animationOffsetX.setValue(0);
|
|
114
|
+
}, [
|
|
115
|
+
ensureOffsetBoundary,
|
|
116
|
+
]);
|
|
117
|
+
|
|
118
|
+
const interruptAnimation = useCallback(() => {
|
|
119
|
+
if (!isAnimatingRef.current) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
animationOffsetX.stopAnimation(lastValue => {
|
|
124
|
+
isAnimatingRef.current = false;
|
|
125
|
+
|
|
126
|
+
const prevOffset = currentOffsetRef.current;
|
|
127
|
+
const totalOffset = prevOffset + lastValue;
|
|
128
|
+
|
|
129
|
+
requireNewOffset(totalOffset);
|
|
130
|
+
|
|
131
|
+
notifyScrollStateHasChanged({ offset: totalOffset, state: 'interrupted' });
|
|
132
|
+
});
|
|
133
|
+
}, [
|
|
134
|
+
notifyScrollStateHasChanged,
|
|
135
|
+
requireNewOffset,
|
|
136
|
+
]);
|
|
137
|
+
|
|
138
|
+
const finalizeAnimation = useCallback(() => {
|
|
139
|
+
isAnimatingRef.current = false;
|
|
140
|
+
|
|
141
|
+
const prevOffset = currentOffsetRef.current;
|
|
142
|
+
const toValue = toValueRef.current;
|
|
143
|
+
const totalOffset = prevOffset + toValue;
|
|
144
|
+
|
|
145
|
+
requireNewOffset(totalOffset);
|
|
146
|
+
|
|
147
|
+
notifyScrollStateHasChanged({ offset: totalOffset, state: 'idle' });
|
|
148
|
+
}, [
|
|
149
|
+
notifyScrollStateHasChanged,
|
|
150
|
+
requireNewOffset,
|
|
151
|
+
]);
|
|
152
|
+
|
|
153
|
+
const startPagingAnimation = useCallback((type: PagingAnimationType, config: PagingAnimationConfig) => {
|
|
154
|
+
if (isAnimatingRef.current) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const configWithDefaults: PagingAnimationConfig = {
|
|
159
|
+
animated: true,
|
|
160
|
+
...config,
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const currentIndex = getCurrentIndex();
|
|
164
|
+
|
|
165
|
+
const getValueByDirectionOnAllAdjacentItemsVisible = directionToValue(itemWidth);
|
|
166
|
+
const compensateToValue = toValueCompensator(itemWidth);
|
|
167
|
+
|
|
168
|
+
const getValueByDirectionalPagingOnLoopDisabled = (_config: DirectionalPagingAnimationConfig): number => {
|
|
169
|
+
const { direction, isOriginatedFromGesture } = _config;
|
|
170
|
+
|
|
171
|
+
if (currentIndex === 0 && direction === 'prev') {
|
|
172
|
+
return isOriginatedFromGesture
|
|
173
|
+
? getValueByDirectionOnAllAdjacentItemsVisible('stay')
|
|
174
|
+
: -lastIndex * itemWidth; // last position
|
|
175
|
+
} else if (currentIndex === lastIndex && direction === 'next') {
|
|
176
|
+
return isOriginatedFromGesture
|
|
177
|
+
? getValueByDirectionOnAllAdjacentItemsVisible('stay')
|
|
178
|
+
: lastIndex * itemWidth; // first position
|
|
179
|
+
}
|
|
180
|
+
return getValueByDirectionOnAllAdjacentItemsVisible(direction);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const getValueByDirectionalPaging = (_config: DirectionalPagingAnimationConfig): number => {
|
|
184
|
+
const _configWithDefaults: DirectionalPagingAnimationConfig = {
|
|
185
|
+
isOriginatedFromGesture: false,
|
|
186
|
+
..._config,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
return loop
|
|
190
|
+
? getValueByDirectionOnAllAdjacentItemsVisible(_configWithDefaults.direction)
|
|
191
|
+
: getValueByDirectionalPagingOnLoopDisabled(_configWithDefaults);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const getValueByIndexPaging = ({ index }: IndexPagingAnimationConfig): number => {
|
|
195
|
+
if (index < 0 || index > lastIndex || index === currentIndex) {
|
|
196
|
+
// no animation if index is invalid or equals to current index
|
|
197
|
+
return 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const distance = Math.abs(currentIndex - index) * itemWidth;
|
|
201
|
+
const direction = index > currentIndex ? -1 : 1;
|
|
202
|
+
|
|
203
|
+
return distance * direction;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const wantedToValue = type === 'directional'
|
|
207
|
+
// @ts-ignore
|
|
208
|
+
? getValueByDirectionalPaging(configWithDefaults)
|
|
209
|
+
// @ts-ignore
|
|
210
|
+
: getValueByIndexPaging(configWithDefaults);
|
|
211
|
+
|
|
212
|
+
const toValue = compensateToValue(wantedToValue, currentOffsetRef.current);
|
|
213
|
+
|
|
214
|
+
toValueRef.current = toValue;
|
|
215
|
+
isAnimatingRef.current = true;
|
|
216
|
+
|
|
217
|
+
notifyScrollStateHasChanged({
|
|
218
|
+
offset: currentOffsetRef.current + toValue,
|
|
219
|
+
state: 'dragging',
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
const lastGestureTranslationX: number = configWithDefaults.lastGestureTranslationX ?? 0;
|
|
223
|
+
if (Number.isFinite(lastGestureTranslationX)) {
|
|
224
|
+
animationOffsetX.setValue(lastGestureTranslationX);
|
|
225
|
+
gestureTranslationX.setValue(0);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (configWithDefaults.animated) {
|
|
229
|
+
const animation = createScrollAnimation(animationOffsetX, toValue);
|
|
230
|
+
|
|
231
|
+
animation.start(({ finished }) => {
|
|
232
|
+
if (finished) {
|
|
233
|
+
finalizeAnimation();
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
} else {
|
|
237
|
+
finalizeAnimation();
|
|
238
|
+
}
|
|
239
|
+
}, [
|
|
240
|
+
createScrollAnimation,
|
|
241
|
+
getCurrentIndex,
|
|
242
|
+
finalizeAnimation,
|
|
243
|
+
itemWidth,
|
|
244
|
+
lastIndex,
|
|
245
|
+
loop,
|
|
246
|
+
notifyScrollStateHasChanged,
|
|
247
|
+
]);
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
gestureTranslationX,
|
|
251
|
+
globalInterpolation,
|
|
252
|
+
interruptAnimation,
|
|
253
|
+
startPagingAnimation,
|
|
254
|
+
};
|
|
255
|
+
};
|
package/src/Carousel/index.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { default } from './
|
|
2
|
-
export type { default as CarouselProps } from './CarouselProps';
|
|
1
|
+
export { default } from './Carousel';
|
|
2
|
+
export type { default as CarouselProps } from './CarouselProps';
|
|
3
|
+
export type { CarouselInstance } from './types';
|
|
4
|
+
export { normalItemStyleFactory, parallaxItemStyleFactory } from './animation';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { Animated, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const directions = ['next', 'prev', 'stay'] as const;
|
|
5
|
+
|
|
6
|
+
export type PagingDirection = (typeof directions)[number];
|
|
7
|
+
|
|
8
|
+
const scrollStates = ['idle', 'dragging', 'interrupted'] as const;
|
|
9
|
+
|
|
10
|
+
export type ScrollState = (typeof scrollStates)[number];
|
|
11
|
+
|
|
12
|
+
export type ItemHeight = number | 'auto';
|
|
13
|
+
|
|
14
|
+
export interface RenderItem<T> {
|
|
15
|
+
(info: { item: T, index: number, interpolation: Animated.AnimatedInterpolation }): ReactElement | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CreateScrollAnimation {
|
|
19
|
+
(aValue: Animated.AnimatedValue, toValue: number): Animated.CompositeAnimation;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CreateItemStyle {
|
|
23
|
+
(itemInterpolation: Animated.AnimatedInterpolation, itemWidth: number): Animated.AnimatedProps<ViewProps['style']>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface GetCurrentIndex {
|
|
27
|
+
(): number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface OnIndexChange {
|
|
31
|
+
(itemIndex: number): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface OnPositionChange {
|
|
35
|
+
(position: number): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ScrollStateChangeEvent {
|
|
39
|
+
offset: number;
|
|
40
|
+
state: ScrollState;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface IndexController {
|
|
44
|
+
getCurrentIndex: GetCurrentIndex;
|
|
45
|
+
lastIndex: number;
|
|
46
|
+
notifyScrollStateHasChanged: (event: ScrollStateChangeEvent) => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type PagingAnimationType = 'directional' | 'index';
|
|
50
|
+
|
|
51
|
+
export interface BasePagingAnimationConfig {
|
|
52
|
+
animated?: boolean;
|
|
53
|
+
lastGestureTranslationX?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface DirectionalPagingAnimationConfig extends BasePagingAnimationConfig {
|
|
57
|
+
direction: PagingDirection;
|
|
58
|
+
isOriginatedFromGesture?: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface IndexPagingAnimationConfig extends BasePagingAnimationConfig {
|
|
62
|
+
index: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type PagingAnimationConfig = DirectionalPagingAnimationConfig | IndexPagingAnimationConfig;
|
|
66
|
+
|
|
67
|
+
export interface StartPagingAnimation {
|
|
68
|
+
(type: PagingAnimationType, config: PagingAnimationConfig): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type VisibleIndexRanges = Array<[number, number]>;
|
|
72
|
+
|
|
73
|
+
export interface StoreSubscription {
|
|
74
|
+
(): void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ItemVisibilityStore {
|
|
78
|
+
dispatch: (ranges: VisibleIndexRanges) => void;
|
|
79
|
+
subscribe: (listener: (ranges: VisibleIndexRanges) => void) => StoreSubscription;
|
|
80
|
+
removeAllListeners: () => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface AutoplayController {
|
|
84
|
+
pause: () => void;
|
|
85
|
+
resume: () => void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ScrollToOption {
|
|
89
|
+
index: number;
|
|
90
|
+
animated?: boolean;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface CarouselInstance {
|
|
94
|
+
/**
|
|
95
|
+
* Get current visible item index.
|
|
96
|
+
*/
|
|
97
|
+
getCurrentIndex: GetCurrentIndex;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Scroll to next visible item.
|
|
101
|
+
*/
|
|
102
|
+
next: () => void;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Scroll to previous visible item.
|
|
106
|
+
*/
|
|
107
|
+
prev: () => void;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Scroll to desired indexed item.
|
|
111
|
+
* Invalid index is ignored.
|
|
112
|
+
*/
|
|
113
|
+
scrollTo: (option: ScrollToOption) => void;
|
|
114
|
+
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { FlatList, ListRenderItem, ViewToken } from 'react-native';
|
|
3
3
|
import * as R from 'ramda';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ComicViewerItemData,
|
|
6
|
+
ComicViewerItemState,
|
|
7
|
+
default as ComicViewerProps,
|
|
8
|
+
ErrorInfo,
|
|
9
|
+
STATE,
|
|
10
|
+
} from './ComicViewerProps';
|
|
5
11
|
import type ComicViewerItemProps from './ComicViewerItemProps';
|
|
6
12
|
import ViewerItem from './ViewerItem';
|
|
7
13
|
|
|
@@ -9,7 +15,7 @@ const getItemHeights = <T, >(items: ComicViewerItemProps<T>[]): number[] => R.ma
|
|
|
9
15
|
const appender = (left: number, right: number): [number, number] => [left + right, left + right];
|
|
10
16
|
const getHeightAccum = (itemHeights: number[]): [number, number[]] => R.mapAccum(appender, 0, itemHeights);
|
|
11
17
|
|
|
12
|
-
const keyExtractor = <T, >(item: ComicViewerItemProps<T>) => item.
|
|
18
|
+
const keyExtractor = <T, >(item: ComicViewerItemProps<T>) => `${item.sortKey}`;
|
|
13
19
|
|
|
14
20
|
export default function ComicViewer<T>(props: ComicViewerProps<T>) {
|
|
15
21
|
const {
|
|
@@ -20,17 +26,22 @@ export default function ComicViewer<T>(props: ComicViewerProps<T>) {
|
|
|
20
26
|
initialScrollPercentage = 0,
|
|
21
27
|
itemVisiblePercentThreshold = 0,
|
|
22
28
|
onError,
|
|
29
|
+
onScroll,
|
|
30
|
+
getNextPage,
|
|
23
31
|
viewerWidth,
|
|
24
32
|
windowSize = 3,
|
|
33
|
+
pageUnit,
|
|
34
|
+
ListFooterComponent,
|
|
25
35
|
...otherProps
|
|
26
36
|
} = props;
|
|
27
37
|
|
|
28
38
|
const flatListRef = useRef<FlatList>(null);
|
|
29
39
|
|
|
30
|
-
const errors = useRef<Map<
|
|
40
|
+
const errors = useRef<Map<number, ErrorInfo>>(new Map());
|
|
41
|
+
|
|
31
42
|
const debounceTimeOut = useRef<NodeJS.Timeout | null>(null);
|
|
32
43
|
|
|
33
|
-
const resourceString = R.toString(R.map((itemData: ComicViewerItemData) => itemData.
|
|
44
|
+
const resourceString = R.toString(R.map((itemData: ComicViewerItemData) => itemData.url)(data));
|
|
34
45
|
|
|
35
46
|
const initialItems = R.map((itemData: ComicViewerItemData<T>) => ({
|
|
36
47
|
...itemData,
|
|
@@ -41,7 +52,13 @@ export default function ComicViewer<T>(props: ComicViewerProps<T>) {
|
|
|
41
52
|
|
|
42
53
|
const [items, setItems] = useState<ComicViewerItemProps<T>[]>(initialItems);
|
|
43
54
|
|
|
44
|
-
const
|
|
55
|
+
const initialItemState: ComicViewerItemState[] = R.map(() => ({
|
|
56
|
+
state: STATE.UNLOAD,
|
|
57
|
+
}))(data);
|
|
58
|
+
|
|
59
|
+
const itemStates = useRef<Array<ComicViewerItemState>>(initialItemState);
|
|
60
|
+
|
|
61
|
+
const itemHeights = [...getItemHeights(items)];
|
|
45
62
|
const itemHeightAccum = getHeightAccum(itemHeights);
|
|
46
63
|
|
|
47
64
|
const viewabilityConfig = useMemo(() => ({
|
|
@@ -62,67 +79,88 @@ export default function ComicViewer<T>(props: ComicViewerProps<T>) {
|
|
|
62
79
|
viewableItems: Array<ViewToken>,
|
|
63
80
|
}) => {
|
|
64
81
|
setItems((prev: ComicViewerItemProps<T>[]) => {
|
|
65
|
-
const
|
|
82
|
+
const viewableItemSortKeys = R.map((viewableItem: ViewToken) => viewableItem.item.sortKey)(viewableItems);
|
|
66
83
|
|
|
67
|
-
|
|
84
|
+
const newItems = R.map((prevItem: ComicViewerItemProps<T>) => ({
|
|
68
85
|
...prevItem,
|
|
69
|
-
isViewable: R.includes(prevItem.
|
|
86
|
+
isViewable: R.includes(prevItem.sortKey, viewableItemSortKeys),
|
|
70
87
|
}))([...prev]);
|
|
88
|
+
|
|
89
|
+
return newItems;
|
|
71
90
|
});
|
|
72
91
|
});
|
|
73
92
|
|
|
74
|
-
const
|
|
75
|
-
const
|
|
93
|
+
const itemLoadedHandler = useCallback((sortKey: number) => {
|
|
94
|
+
const itemState = itemStates.current[sortKey - 1];
|
|
95
|
+
itemState.state = STATE.LOADED;
|
|
96
|
+
itemState.error = undefined;
|
|
97
|
+
}, [itemStates]);
|
|
76
98
|
|
|
77
|
-
|
|
99
|
+
const itemErrorHandler = useCallback((errorInfo: ErrorInfo) => {
|
|
100
|
+
const { sortKey, count } = errorInfo;
|
|
101
|
+
|
|
102
|
+
if (count >= errorRetryCount) {
|
|
78
103
|
return;
|
|
79
104
|
}
|
|
80
105
|
|
|
81
|
-
|
|
82
|
-
};
|
|
106
|
+
errors.current.set(sortKey, errorInfo);
|
|
83
107
|
|
|
84
|
-
|
|
85
|
-
|
|
108
|
+
const itemState = itemStates.current[sortKey - 1];
|
|
109
|
+
itemState.state = STATE.FAIL;
|
|
110
|
+
itemState.error = errorInfo;
|
|
111
|
+
|
|
112
|
+
const handleError = () => {
|
|
113
|
+
const errorsArray = Array.from(errors.current.entries());
|
|
114
|
+
const errorsInfo = R.map(([key, value]: [number, ErrorInfo]) => value)(errorsArray);
|
|
115
|
+
|
|
116
|
+
onError && onError([...errorsInfo]);
|
|
117
|
+
errors.current.clear();
|
|
118
|
+
};
|
|
86
119
|
|
|
87
120
|
if (debounceTimeOut.current) {
|
|
88
121
|
clearTimeout(debounceTimeOut.current);
|
|
89
122
|
}
|
|
90
123
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
onErrorHandler([...errorsInfo]);
|
|
99
|
-
errors.current.clear();
|
|
100
|
-
}, errorDebounceMillis);
|
|
101
|
-
}, [errorDebounceMillis, errors.current]);
|
|
124
|
+
if (errors.current.size === pageUnit) {
|
|
125
|
+
handleError();
|
|
126
|
+
} else {
|
|
127
|
+
debounceTimeOut.current = setTimeout(handleError, errorDebounceMillis);
|
|
128
|
+
}
|
|
129
|
+
}, [errors.current, itemStates]);
|
|
102
130
|
|
|
103
131
|
const renderItem: ListRenderItem<ComicViewerItemProps<T>> = useCallback(({ item }) => {
|
|
132
|
+
const itemState = itemStates.current[item.sortKey - 1];
|
|
133
|
+
|
|
104
134
|
const props = {
|
|
105
135
|
...item,
|
|
136
|
+
itemState,
|
|
137
|
+
errorRetryCount,
|
|
106
138
|
onError: itemErrorHandler,
|
|
139
|
+
onLoaded: itemLoadedHandler,
|
|
140
|
+
getNextPage,
|
|
107
141
|
};
|
|
108
142
|
|
|
109
143
|
return <ViewerItem props={props}/>;
|
|
110
|
-
}, []);
|
|
144
|
+
}, [resourceString, itemStates, itemErrorHandler, itemLoadedHandler]);
|
|
111
145
|
|
|
112
146
|
useEffect(() => {
|
|
113
147
|
setItems((prev: ComicViewerItemProps<T>[]) => {
|
|
114
148
|
return R.map((prevItem: ComicViewerItemProps<T>) => {
|
|
115
|
-
const currentData = R.find((currentItemData: ComicViewerItemData<T>) => prevItem.
|
|
149
|
+
const currentData = R.find((currentItemData: ComicViewerItemData<T>) => prevItem.sortKey === currentItemData.sortKey)(data);
|
|
116
150
|
|
|
117
|
-
if (currentData
|
|
151
|
+
if (currentData
|
|
152
|
+
&& itemStates.current[currentData.sortKey - 1].state !== STATE.LOADED
|
|
153
|
+
&& (currentData.url !== prevItem.url)) {
|
|
118
154
|
return {
|
|
119
155
|
...prevItem,
|
|
120
|
-
|
|
156
|
+
url: currentData.url,
|
|
157
|
+
expiresAt: currentData.expiresAt,
|
|
121
158
|
};
|
|
122
159
|
}
|
|
123
160
|
|
|
124
161
|
return prevItem;
|
|
125
162
|
})([...prev]);
|
|
163
|
+
;
|
|
126
164
|
});
|
|
127
165
|
}, [resourceString]);
|
|
128
166
|
|
|
@@ -152,10 +190,12 @@ export default function ComicViewer<T>(props: ComicViewerProps<T>) {
|
|
|
152
190
|
initialNumToRender={initialNumToRender}
|
|
153
191
|
keyExtractor={keyExtractor}
|
|
154
192
|
onViewableItemsChanged={onViewableItemsChanged.current}
|
|
193
|
+
onScroll={onScroll}
|
|
155
194
|
ref={flatListRef}
|
|
156
195
|
renderItem={renderItem}
|
|
157
196
|
viewabilityConfig={viewabilityConfig}
|
|
158
197
|
windowSize={windowSize}
|
|
198
|
+
ListFooterComponent={ListFooterComponent}
|
|
159
199
|
{...otherProps}
|
|
160
200
|
/>
|
|
161
201
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComicViewerItemData, ErrorInfo } from './ComicViewerProps';
|
|
1
|
+
import { ComicViewerItemData, ErrorInfo, ComicViewerItemState } from './ComicViewerProps';
|
|
2
2
|
|
|
3
3
|
type ComicViewerItemProps<T> = ComicViewerItemData<T> & {
|
|
4
4
|
/**
|
|
@@ -6,10 +6,25 @@ type ComicViewerItemProps<T> = ComicViewerItemData<T> & {
|
|
|
6
6
|
*/
|
|
7
7
|
isViewable: boolean;
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* How many times retry onError when same item error occur
|
|
11
|
+
* @default 3
|
|
12
|
+
*/
|
|
13
|
+
errorRetryCount?: number;
|
|
14
|
+
|
|
9
15
|
/**
|
|
10
16
|
* Error handler
|
|
11
17
|
*/
|
|
12
18
|
onError?: (errorInfo: ErrorInfo) => void;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Load handler
|
|
22
|
+
*/
|
|
23
|
+
onLoaded?: (sortKey: number) => void;
|
|
24
|
+
|
|
25
|
+
getNextPage?: (sortKey: number) => void;
|
|
26
|
+
|
|
27
|
+
itemState?: ComicViewerItemState;
|
|
13
28
|
}
|
|
14
29
|
|
|
15
30
|
export default ComicViewerItemProps;
|