@fountain-ui/lab 2.0.0-beta.4 → 2.0.0-beta.40
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 +203 -86
- package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
- package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
- package/build/commonjs/ComicViewer/EncodedTile.js +10 -0
- package/build/commonjs/ComicViewer/EncodedTile.js.map +1 -0
- package/build/commonjs/ComicViewer/ReloadButton.js +48 -0
- package/build/commonjs/ComicViewer/ReloadButton.js.map +1 -0
- package/build/commonjs/ComicViewer/ViewerItem.js +49 -58
- 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 +201 -86
- package/build/module/ComicViewer/ComicViewer.js.map +1 -1
- package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
- package/build/module/ComicViewer/EncodedTile.js +3 -0
- package/build/module/ComicViewer/EncodedTile.js.map +1 -0
- package/build/module/ComicViewer/ReloadButton.js +33 -0
- package/build/module/ComicViewer/ReloadButton.js.map +1 -0
- package/build/module/ComicViewer/ViewerItem.js +49 -59
- 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 +1 -2
- package/build/typescript/ComicViewer/ComicViewerProps.d.ts +39 -44
- package/build/typescript/ComicViewer/EncodedTile.d.ts +2 -0
- package/build/typescript/ComicViewer/ReloadButton.d.ts +6 -0
- package/build/typescript/ComicViewer/ViewerItem.d.ts +37 -7
- package/build/typescript/ComicViewer/index.d.ts +2 -2
- 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 +222 -93
- package/src/ComicViewer/ComicViewerProps.ts +42 -48
- package/src/ComicViewer/EncodedTile.ts +3 -0
- package/src/ComicViewer/ReloadButton.tsx +36 -0
- package/src/ComicViewer/ViewerItem.tsx +91 -63
- package/src/ComicViewer/index.ts +2 -2
- 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/ComicViewer/ComicViewerItemProps.js +0 -6
- package/build/commonjs/ComicViewer/ComicViewerItemProps.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/ComicViewer/ComicViewerItemProps.js +0 -2
- package/build/module/ComicViewer/ComicViewerItemProps.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/ComicViewer/ComicViewerItemProps.d.ts +0 -12
- 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/ComicViewer/ComicViewerItemProps.ts +0 -15
- 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,192 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import { useAnimatedValue } from '@fountain-ui/core';
|
|
4
|
+
|
|
5
|
+
function directionToValue(itemWidth) {
|
|
6
|
+
return function (direction) {
|
|
7
|
+
switch (direction) {
|
|
8
|
+
case 'next':
|
|
9
|
+
return -itemWidth;
|
|
10
|
+
|
|
11
|
+
case 'prev':
|
|
12
|
+
return itemWidth;
|
|
13
|
+
|
|
14
|
+
case 'stay':
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function toValueCompensator(itemWidth) {
|
|
21
|
+
return function (toValue, currentOffset) {
|
|
22
|
+
const remainder = Math.abs(currentOffset % itemWidth);
|
|
23
|
+
const halfOfItemWidth = Math.abs(itemWidth / 2);
|
|
24
|
+
const compensateVector = remainder > halfOfItemWidth ? remainder - itemWidth : remainder;
|
|
25
|
+
const direction = currentOffset > 0 ? -1 : 1;
|
|
26
|
+
return toValue + direction * compensateVector;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function usePagingAnimator(config) {
|
|
31
|
+
const {
|
|
32
|
+
createScrollAnimation,
|
|
33
|
+
itemWidth,
|
|
34
|
+
indexController,
|
|
35
|
+
initialIndex,
|
|
36
|
+
loop,
|
|
37
|
+
numberOfData
|
|
38
|
+
} = config;
|
|
39
|
+
const {
|
|
40
|
+
getCurrentIndex,
|
|
41
|
+
lastIndex,
|
|
42
|
+
notifyScrollStateHasChanged
|
|
43
|
+
} = indexController;
|
|
44
|
+
const initialOffsetX = itemWidth * initialIndex;
|
|
45
|
+
const accumulativeOffsetX = useAnimatedValue(initialOffsetX);
|
|
46
|
+
const animationOffsetX = useAnimatedValue(0);
|
|
47
|
+
const gestureTranslationX = useAnimatedValue(0);
|
|
48
|
+
const globalInterpolation = useMemo(() => {
|
|
49
|
+
return Animated.add(Animated.add(accumulativeOffsetX, animationOffsetX), gestureTranslationX);
|
|
50
|
+
}, []);
|
|
51
|
+
const toValueRef = useRef(0);
|
|
52
|
+
const currentOffsetRef = useRef(0);
|
|
53
|
+
const isAnimatingRef = useRef(false);
|
|
54
|
+
const maxWidth = Math.abs(numberOfData * itemWidth);
|
|
55
|
+
const ensureOffsetBoundary = useCallback(offset => {
|
|
56
|
+
if (loop) {
|
|
57
|
+
const isCloseToEnd = Math.abs(offset) >= maxWidth - itemWidth;
|
|
58
|
+
|
|
59
|
+
if (isCloseToEnd) {
|
|
60
|
+
const signOfOffset = offset > 0 ? 1 : -1;
|
|
61
|
+
return offset + -signOfOffset * maxWidth;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return offset % maxWidth;
|
|
66
|
+
}, [itemWidth, loop, maxWidth]);
|
|
67
|
+
const requireNewOffset = useCallback(newOffset => {
|
|
68
|
+
const nextOffset = ensureOffsetBoundary(newOffset);
|
|
69
|
+
currentOffsetRef.current = nextOffset;
|
|
70
|
+
accumulativeOffsetX.setValue(nextOffset);
|
|
71
|
+
toValueRef.current = 0;
|
|
72
|
+
animationOffsetX.setValue(0);
|
|
73
|
+
}, [ensureOffsetBoundary]);
|
|
74
|
+
const interruptAnimation = useCallback(() => {
|
|
75
|
+
if (!isAnimatingRef.current) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
animationOffsetX.stopAnimation(lastValue => {
|
|
80
|
+
isAnimatingRef.current = false;
|
|
81
|
+
const prevOffset = currentOffsetRef.current;
|
|
82
|
+
const totalOffset = prevOffset + lastValue;
|
|
83
|
+
requireNewOffset(totalOffset);
|
|
84
|
+
notifyScrollStateHasChanged({
|
|
85
|
+
offset: totalOffset,
|
|
86
|
+
state: 'interrupted'
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}, [notifyScrollStateHasChanged, requireNewOffset]);
|
|
90
|
+
const finalizeAnimation = useCallback(() => {
|
|
91
|
+
isAnimatingRef.current = false;
|
|
92
|
+
const prevOffset = currentOffsetRef.current;
|
|
93
|
+
const toValue = toValueRef.current;
|
|
94
|
+
const totalOffset = prevOffset + toValue;
|
|
95
|
+
requireNewOffset(totalOffset);
|
|
96
|
+
notifyScrollStateHasChanged({
|
|
97
|
+
offset: totalOffset,
|
|
98
|
+
state: 'idle'
|
|
99
|
+
});
|
|
100
|
+
}, [notifyScrollStateHasChanged, requireNewOffset]);
|
|
101
|
+
const startPagingAnimation = useCallback((type, config) => {
|
|
102
|
+
if (isAnimatingRef.current) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const configWithDefaults = {
|
|
107
|
+
animated: true,
|
|
108
|
+
...config
|
|
109
|
+
};
|
|
110
|
+
const currentIndex = getCurrentIndex();
|
|
111
|
+
const getValueByDirectionOnAllAdjacentItemsVisible = directionToValue(itemWidth);
|
|
112
|
+
const compensateToValue = toValueCompensator(itemWidth);
|
|
113
|
+
|
|
114
|
+
const getValueByDirectionalPagingOnLoopDisabled = _config => {
|
|
115
|
+
const {
|
|
116
|
+
direction,
|
|
117
|
+
isOriginatedFromGesture
|
|
118
|
+
} = _config;
|
|
119
|
+
|
|
120
|
+
if (currentIndex === 0 && direction === 'prev') {
|
|
121
|
+
return isOriginatedFromGesture ? getValueByDirectionOnAllAdjacentItemsVisible('stay') : -lastIndex * itemWidth; // last position
|
|
122
|
+
} else if (currentIndex === lastIndex && direction === 'next') {
|
|
123
|
+
return isOriginatedFromGesture ? getValueByDirectionOnAllAdjacentItemsVisible('stay') : lastIndex * itemWidth; // first position
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return getValueByDirectionOnAllAdjacentItemsVisible(direction);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const getValueByDirectionalPaging = _config => {
|
|
130
|
+
const _configWithDefaults = {
|
|
131
|
+
isOriginatedFromGesture: false,
|
|
132
|
+
..._config
|
|
133
|
+
};
|
|
134
|
+
return loop ? getValueByDirectionOnAllAdjacentItemsVisible(_configWithDefaults.direction) : getValueByDirectionalPagingOnLoopDisabled(_configWithDefaults);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const getValueByIndexPaging = _ref => {
|
|
138
|
+
let {
|
|
139
|
+
index
|
|
140
|
+
} = _ref;
|
|
141
|
+
|
|
142
|
+
if (index < 0 || index > lastIndex || index === currentIndex) {
|
|
143
|
+
// no animation if index is invalid or equals to current index
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const distance = Math.abs(currentIndex - index) * itemWidth;
|
|
148
|
+
const direction = index > currentIndex ? -1 : 1;
|
|
149
|
+
return distance * direction;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const wantedToValue = type === 'directional' // @ts-ignore
|
|
153
|
+
? getValueByDirectionalPaging(configWithDefaults) // @ts-ignore
|
|
154
|
+
: getValueByIndexPaging(configWithDefaults);
|
|
155
|
+
const toValue = compensateToValue(wantedToValue, currentOffsetRef.current);
|
|
156
|
+
toValueRef.current = toValue;
|
|
157
|
+
isAnimatingRef.current = true;
|
|
158
|
+
notifyScrollStateHasChanged({
|
|
159
|
+
offset: currentOffsetRef.current + toValue,
|
|
160
|
+
state: 'dragging'
|
|
161
|
+
});
|
|
162
|
+
const lastGestureTranslationX = configWithDefaults.lastGestureTranslationX ?? 0;
|
|
163
|
+
|
|
164
|
+
if (Number.isFinite(lastGestureTranslationX)) {
|
|
165
|
+
animationOffsetX.setValue(lastGestureTranslationX);
|
|
166
|
+
gestureTranslationX.setValue(0);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (configWithDefaults.animated) {
|
|
170
|
+
const animation = createScrollAnimation(animationOffsetX, toValue);
|
|
171
|
+
animation.start(_ref2 => {
|
|
172
|
+
let {
|
|
173
|
+
finished
|
|
174
|
+
} = _ref2;
|
|
175
|
+
|
|
176
|
+
if (finished) {
|
|
177
|
+
finalizeAnimation();
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
} else {
|
|
181
|
+
finalizeAnimation();
|
|
182
|
+
}
|
|
183
|
+
}, [createScrollAnimation, getCurrentIndex, finalizeAnimation, itemWidth, lastIndex, loop, notifyScrollStateHasChanged]);
|
|
184
|
+
return {
|
|
185
|
+
gestureTranslationX,
|
|
186
|
+
globalInterpolation,
|
|
187
|
+
interruptAnimation,
|
|
188
|
+
startPagingAnimation
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
;
|
|
192
|
+
//# sourceMappingURL=usePagingAnimator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useMemo","useRef","Animated","useAnimatedValue","directionToValue","itemWidth","direction","toValueCompensator","toValue","currentOffset","remainder","Math","abs","halfOfItemWidth","compensateVector","usePagingAnimator","config","createScrollAnimation","indexController","initialIndex","loop","numberOfData","getCurrentIndex","lastIndex","notifyScrollStateHasChanged","initialOffsetX","accumulativeOffsetX","animationOffsetX","gestureTranslationX","globalInterpolation","add","toValueRef","currentOffsetRef","isAnimatingRef","maxWidth","ensureOffsetBoundary","offset","isCloseToEnd","signOfOffset","requireNewOffset","newOffset","nextOffset","current","setValue","interruptAnimation","stopAnimation","lastValue","prevOffset","totalOffset","state","finalizeAnimation","startPagingAnimation","type","configWithDefaults","animated","currentIndex","getValueByDirectionOnAllAdjacentItemsVisible","compensateToValue","getValueByDirectionalPagingOnLoopDisabled","_config","isOriginatedFromGesture","getValueByDirectionalPaging","_configWithDefaults","getValueByIndexPaging","index","distance","wantedToValue","lastGestureTranslationX","Number","isFinite","animation","start","finished"],"sources":["usePagingAnimator.ts"],"sourcesContent":["import { useCallback, useMemo, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport { useAnimatedValue } from '@fountain-ui/core';\nimport type {\n CreateScrollAnimation,\n DirectionalPagingAnimationConfig,\n IndexController,\n IndexPagingAnimationConfig,\n PagingAnimationConfig,\n PagingAnimationType,\n PagingDirection,\n StartPagingAnimation,\n} from '../types';\n\nexport interface PagingAnimatorConfig {\n createScrollAnimation: CreateScrollAnimation;\n itemWidth: number;\n indexController: IndexController;\n initialIndex: number;\n loop: boolean;\n numberOfData: number;\n}\n\nexport interface PagingAnimator {\n gestureTranslationX: Animated.Value;\n globalInterpolation: Animated.AnimatedInterpolation;\n interruptAnimation: () => void;\n startPagingAnimation: StartPagingAnimation;\n}\n\nfunction directionToValue(itemWidth: number) {\n return function (direction: PagingDirection): number {\n switch (direction) {\n case 'next':\n return -itemWidth;\n case 'prev':\n return itemWidth;\n case 'stay':\n return 0;\n }\n };\n}\n\nfunction toValueCompensator(itemWidth: number) {\n return function (toValue: number, currentOffset: number): number {\n const remainder = Math.abs(currentOffset % itemWidth);\n\n const halfOfItemWidth = Math.abs(itemWidth / 2);\n const compensateVector = remainder > halfOfItemWidth\n ? remainder - itemWidth\n : remainder;\n\n const direction = currentOffset > 0 ? -1 : 1;\n\n return toValue + (direction * compensateVector);\n };\n}\n\nexport default function usePagingAnimator(config: PagingAnimatorConfig): PagingAnimator {\n const {\n createScrollAnimation,\n itemWidth,\n indexController,\n initialIndex,\n loop,\n numberOfData,\n } = config;\n\n const {\n getCurrentIndex,\n lastIndex,\n notifyScrollStateHasChanged,\n } = indexController;\n\n const initialOffsetX = itemWidth * initialIndex;\n const accumulativeOffsetX = useAnimatedValue(initialOffsetX);\n const animationOffsetX = useAnimatedValue(0);\n const gestureTranslationX = useAnimatedValue(0);\n\n const globalInterpolation = useMemo(() => {\n return Animated.add(\n Animated.add(accumulativeOffsetX, animationOffsetX),\n gestureTranslationX,\n );\n }, []);\n\n const toValueRef = useRef<number>(0);\n const currentOffsetRef = useRef<number>(0);\n\n const isAnimatingRef = useRef<boolean>(false);\n\n const maxWidth = Math.abs(numberOfData * itemWidth);\n\n const ensureOffsetBoundary: (offset: number) => number = useCallback((offset: number) => {\n if (loop) {\n const isCloseToEnd = Math.abs(offset) >= (maxWidth - itemWidth);\n if (isCloseToEnd) {\n const signOfOffset = offset > 0 ? 1 : -1;\n return offset + (-signOfOffset * maxWidth);\n }\n }\n\n return offset % maxWidth;\n }, [itemWidth, loop, maxWidth]);\n\n const requireNewOffset = useCallback((newOffset: number) => {\n const nextOffset = ensureOffsetBoundary(newOffset);\n\n currentOffsetRef.current = nextOffset;\n accumulativeOffsetX.setValue(nextOffset);\n\n toValueRef.current = 0;\n animationOffsetX.setValue(0);\n }, [\n ensureOffsetBoundary,\n ]);\n\n const interruptAnimation = useCallback(() => {\n if (!isAnimatingRef.current) {\n return;\n }\n\n animationOffsetX.stopAnimation(lastValue => {\n isAnimatingRef.current = false;\n\n const prevOffset = currentOffsetRef.current;\n const totalOffset = prevOffset + lastValue;\n\n requireNewOffset(totalOffset);\n\n notifyScrollStateHasChanged({ offset: totalOffset, state: 'interrupted' });\n });\n }, [\n notifyScrollStateHasChanged,\n requireNewOffset,\n ]);\n\n const finalizeAnimation = useCallback(() => {\n isAnimatingRef.current = false;\n\n const prevOffset = currentOffsetRef.current;\n const toValue = toValueRef.current;\n const totalOffset = prevOffset + toValue;\n\n requireNewOffset(totalOffset);\n\n notifyScrollStateHasChanged({ offset: totalOffset, state: 'idle' });\n }, [\n notifyScrollStateHasChanged,\n requireNewOffset,\n ]);\n\n const startPagingAnimation = useCallback((type: PagingAnimationType, config: PagingAnimationConfig) => {\n if (isAnimatingRef.current) {\n return;\n }\n\n const configWithDefaults: PagingAnimationConfig = {\n animated: true,\n ...config,\n };\n\n const currentIndex = getCurrentIndex();\n\n const getValueByDirectionOnAllAdjacentItemsVisible = directionToValue(itemWidth);\n const compensateToValue = toValueCompensator(itemWidth);\n\n const getValueByDirectionalPagingOnLoopDisabled = (_config: DirectionalPagingAnimationConfig): number => {\n const { direction, isOriginatedFromGesture } = _config;\n\n if (currentIndex === 0 && direction === 'prev') {\n return isOriginatedFromGesture\n ? getValueByDirectionOnAllAdjacentItemsVisible('stay')\n : -lastIndex * itemWidth; // last position\n } else if (currentIndex === lastIndex && direction === 'next') {\n return isOriginatedFromGesture\n ? getValueByDirectionOnAllAdjacentItemsVisible('stay')\n : lastIndex * itemWidth; // first position\n }\n return getValueByDirectionOnAllAdjacentItemsVisible(direction);\n };\n\n const getValueByDirectionalPaging = (_config: DirectionalPagingAnimationConfig): number => {\n const _configWithDefaults: DirectionalPagingAnimationConfig = {\n isOriginatedFromGesture: false,\n ..._config,\n };\n\n return loop\n ? getValueByDirectionOnAllAdjacentItemsVisible(_configWithDefaults.direction)\n : getValueByDirectionalPagingOnLoopDisabled(_configWithDefaults);\n };\n\n const getValueByIndexPaging = ({ index }: IndexPagingAnimationConfig): number => {\n if (index < 0 || index > lastIndex || index === currentIndex) {\n // no animation if index is invalid or equals to current index\n return 0;\n }\n\n const distance = Math.abs(currentIndex - index) * itemWidth;\n const direction = index > currentIndex ? -1 : 1;\n\n return distance * direction;\n };\n\n const wantedToValue = type === 'directional'\n // @ts-ignore\n ? getValueByDirectionalPaging(configWithDefaults)\n // @ts-ignore\n : getValueByIndexPaging(configWithDefaults);\n\n const toValue = compensateToValue(wantedToValue, currentOffsetRef.current);\n\n toValueRef.current = toValue;\n isAnimatingRef.current = true;\n\n notifyScrollStateHasChanged({\n offset: currentOffsetRef.current + toValue,\n state: 'dragging',\n });\n\n const lastGestureTranslationX: number = configWithDefaults.lastGestureTranslationX ?? 0;\n if (Number.isFinite(lastGestureTranslationX)) {\n animationOffsetX.setValue(lastGestureTranslationX);\n gestureTranslationX.setValue(0);\n }\n\n if (configWithDefaults.animated) {\n const animation = createScrollAnimation(animationOffsetX, toValue);\n\n animation.start(({ finished }) => {\n if (finished) {\n finalizeAnimation();\n }\n });\n } else {\n finalizeAnimation();\n }\n }, [\n createScrollAnimation,\n getCurrentIndex,\n finalizeAnimation,\n itemWidth,\n lastIndex,\n loop,\n notifyScrollStateHasChanged,\n ]);\n\n return {\n gestureTranslationX,\n globalInterpolation,\n interruptAnimation,\n startPagingAnimation,\n };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,OAAtB,EAA+BC,MAA/B,QAA6C,OAA7C;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,gBAAT,QAAiC,mBAAjC;;AA4BA,SAASC,gBAAT,CAA0BC,SAA1B,EAA6C;EACzC,OAAO,UAAUC,SAAV,EAA8C;IACjD,QAAQA,SAAR;MACI,KAAK,MAAL;QACI,OAAO,CAACD,SAAR;;MACJ,KAAK,MAAL;QACI,OAAOA,SAAP;;MACJ,KAAK,MAAL;QACI,OAAO,CAAP;IANR;EAQH,CATD;AAUH;;AAED,SAASE,kBAAT,CAA4BF,SAA5B,EAA+C;EAC3C,OAAO,UAAUG,OAAV,EAA2BC,aAA3B,EAA0D;IAC7D,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAL,CAASH,aAAa,GAAGJ,SAAzB,CAAlB;IAEA,MAAMQ,eAAe,GAAGF,IAAI,CA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P,CAAgBF,uBAAhB,CAAJ,EAA8C;MAC1CxC,gBAAgB,CAACgB,QAAjB,CAA0BwB,uBAA1B;MACAvC,mBAAmB,CAACe,QAApB,CAA6B,CAA7B;IACH;;IAED,IAAIU,kBAAkB,CAACC,QAAvB,EAAiC;MAC7B,MAAMgB,SAAS,GAAGrD,qBAAqB,CAACU,gBAAD,EAAmBnB,OAAnB,CAAvC;MAEA8D,SAAS,CAACC,KAAV,CAAgB,SAAkB;QAAA,IAAjB;UAAEC;QAAF,CAAiB;;QAC9B,IAAIA,QAAJ,EAAc;UACVtB,iBAAiB;QACpB;MACJ,CAJD;IAKH,CARD,MAQO;MACHA,iBAAiB;IACpB;EACJ,CAtFuC,EAsFrC,CACCjC,qBADD,EAECK,eAFD,EAGC4B,iBAHD,EAIC7C,SAJD,EAKCkB,SALD,EAMCH,IAND,EAOCI,2BAPD,CAtFqC,CAAxC;EAgGA,OAAO;IACHI,mBADG;IAEHC,mBAFG;IAGHe,kBAHG;IAIHO;EAJG,CAAP;AAMH;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["default","normalItemStyleFactory","parallaxItemStyleFactory"],"sources":["index.ts"],"sourcesContent":["export { default } from './Carousel';\nexport type { default as CarouselProps } from './CarouselProps';\nexport type { CarouselInstance } from './types';\nexport { normalItemStyleFactory, parallaxItemStyleFactory } from './animation';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,YAAxB;AAGA,SAASC,sBAAT,EAAiCC,wBAAjC,QAAiE,aAAjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["logger","enabled","__DEV__","format"],"sources":["tick.ts"],"sourcesContent":["import { logger } from '@fountain-ui/utils';\n\nexport default logger('Carousel', {\n enabled: __DEV__,\n format: 'diff',\n});\n"],"mappings":"AAAA,SAASA,MAAT,QAAuB,oBAAvB;AAEA,eAAeA,MAAM,CAAC,UAAD,EAAa;EAC9BC,OAAO,EAAEC,OADqB;EAE9BC,MAAM,EAAE;AAFsB,CAAb,CAArB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["directions","scrollStates"],"sources":["types.ts"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type { Animated, ViewProps } from 'react-native';\n\nconst directions = ['next', 'prev', 'stay'] as const;\n\nexport type PagingDirection = (typeof directions)[number];\n\nconst scrollStates = ['idle', 'dragging', 'interrupted'] as const;\n\nexport type ScrollState = (typeof scrollStates)[number];\n\nexport type ItemHeight = number | 'auto';\n\nexport interface RenderItem<T> {\n (info: { item: T, index: number, interpolation: Animated.AnimatedInterpolation }): ReactElement | null;\n}\n\nexport interface CreateScrollAnimation {\n (aValue: Animated.AnimatedValue, toValue: number): Animated.CompositeAnimation;\n}\n\nexport interface CreateItemStyle {\n (itemInterpolation: Animated.AnimatedInterpolation, itemWidth: number): Animated.AnimatedProps<ViewProps['style']>;\n}\n\nexport interface GetCurrentIndex {\n (): number;\n}\n\nexport interface OnIndexChange {\n (itemIndex: number): void;\n}\n\nexport interface OnPositionChange {\n (position: number): void;\n}\n\nexport interface ScrollStateChangeEvent {\n offset: number;\n state: ScrollState;\n}\n\nexport interface IndexController {\n getCurrentIndex: GetCurrentIndex;\n lastIndex: number;\n notifyScrollStateHasChanged: (event: ScrollStateChangeEvent) => void;\n}\n\nexport type PagingAnimationType = 'directional' | 'index';\n\nexport interface BasePagingAnimationConfig {\n animated?: boolean;\n lastGestureTranslationX?: number;\n}\n\nexport interface DirectionalPagingAnimationConfig extends BasePagingAnimationConfig {\n direction: PagingDirection;\n isOriginatedFromGesture?: boolean;\n}\n\nexport interface IndexPagingAnimationConfig extends BasePagingAnimationConfig {\n index: number;\n}\n\nexport type PagingAnimationConfig = DirectionalPagingAnimationConfig | IndexPagingAnimationConfig;\n\nexport interface StartPagingAnimation {\n (type: PagingAnimationType, config: PagingAnimationConfig): void;\n}\n\nexport type VisibleIndexRanges = Array<[number, number]>;\n\nexport interface StoreSubscription {\n (): void;\n}\n\nexport interface ItemVisibilityStore {\n dispatch: (ranges: VisibleIndexRanges) => void;\n subscribe: (listener: (ranges: VisibleIndexRanges) => void) => StoreSubscription;\n removeAllListeners: () => void;\n}\n\nexport interface AutoplayController {\n pause: () => void;\n resume: () => void;\n}\n\nexport interface ScrollToOption {\n index: number;\n animated?: boolean;\n}\n\nexport interface CarouselInstance {\n /**\n * Get current visible item index.\n */\n getCurrentIndex: GetCurrentIndex;\n\n /**\n * Scroll to next visible item.\n */\n next: () => void;\n\n /**\n * Scroll to previous visible item.\n */\n prev: () => void;\n\n /**\n * Scroll to desired indexed item.\n * Invalid index is ignored.\n */\n scrollTo: (option: ScrollToOption) => void;\n}\n"],"mappings":"AAGA,MAAMA,UAAU,GAAG,CAAC,MAAD,EAAS,MAAT,EAAiB,MAAjB,CAAnB;AAIA,MAAMC,YAAY,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,aAArB,CAArB"}
|
|
@@ -1,126 +1,240 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { FlatList } from 'react-native';
|
|
5
5
|
import * as R from 'ramda';
|
|
6
|
+
import { useDebounce } from '@fountain-ui/core';
|
|
6
7
|
import ViewerItem from './ViewerItem';
|
|
7
8
|
|
|
8
|
-
const getItemHeights = items => R.map(content => content.height)(items);
|
|
9
|
-
|
|
10
9
|
const appender = (left, right) => [left + right, left + right];
|
|
11
10
|
|
|
12
|
-
const getHeightAccum =
|
|
11
|
+
const getHeightAccum = heights => R.mapAccum(appender, 0, heights);
|
|
12
|
+
|
|
13
|
+
const keyExtractor = item => String(item.index);
|
|
14
|
+
|
|
15
|
+
const createInitialImageState = dimension => ({
|
|
16
|
+
isNewUrlIncoming: false,
|
|
17
|
+
totalErrorCount: 0,
|
|
18
|
+
dimension
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const mapImageStateToItemState = (index, imageState, autoHandleErrorCount) => {
|
|
22
|
+
var _imageState$urlState, _imageState$urlState2;
|
|
13
23
|
|
|
14
|
-
|
|
24
|
+
return {
|
|
25
|
+
index,
|
|
26
|
+
url: (_imageState$urlState = imageState.urlState) === null || _imageState$urlState === void 0 ? void 0 : _imageState$urlState.url,
|
|
27
|
+
reloadButtonVisible: ((_imageState$urlState2 = imageState.urlState) === null || _imageState$urlState2 === void 0 ? void 0 : _imageState$urlState2.validity) !== 'valid' && imageState.totalErrorCount >= autoHandleErrorCount,
|
|
28
|
+
dimension: imageState.dimension
|
|
29
|
+
};
|
|
30
|
+
};
|
|
15
31
|
|
|
32
|
+
const MAXIMUM_WIDTH = 720;
|
|
33
|
+
const NUMBER_OF_ADJACENT_ITEM = 5;
|
|
16
34
|
export default function ComicViewer(props) {
|
|
17
35
|
const {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
36
|
+
debounceMillis = 100,
|
|
37
|
+
autoHandleErrorCount = 3,
|
|
38
|
+
getUrlByIndex,
|
|
21
39
|
initialNumToRender = 1,
|
|
22
40
|
initialScrollPercentage = 0,
|
|
23
41
|
itemVisiblePercentThreshold = 0,
|
|
24
|
-
|
|
25
|
-
|
|
42
|
+
intrinsicDimensions,
|
|
43
|
+
maxContentWidth = MAXIMUM_WIDTH,
|
|
44
|
+
onItemPress,
|
|
45
|
+
viewportWidth,
|
|
26
46
|
windowSize = 3,
|
|
27
47
|
...otherProps
|
|
28
48
|
} = props;
|
|
29
49
|
const flatListRef = useRef(null);
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
50
|
+
const maybeLoadableItemsIndexRange = useRef([-1, 0]);
|
|
51
|
+
const actualImageWidth = Math.min(viewportWidth, maxContentWidth);
|
|
52
|
+
const initialImageStates = useMemo(() => R.map(createInitialImageState, intrinsicDimensions), []);
|
|
53
|
+
const imageStatesRef = useRef(initialImageStates);
|
|
54
|
+
|
|
55
|
+
const mapImageStatesToItemStates = imageStates => {
|
|
56
|
+
return imageStates.map((image, index) => mapImageStateToItemState(index, image, autoHandleErrorCount));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const [itemStates, setItemStates] = useState(() => {
|
|
60
|
+
return mapImageStatesToItemStates(imageStatesRef.current);
|
|
61
|
+
});
|
|
62
|
+
const renderedDimensions = useMemo(() => {
|
|
63
|
+
return R.map(intrinsicDimension => ({
|
|
64
|
+
width: actualImageWidth,
|
|
65
|
+
height: intrinsicDimension.height * actualImageWidth / intrinsicDimension.width
|
|
66
|
+
}), intrinsicDimensions);
|
|
67
|
+
}, [actualImageWidth]);
|
|
68
|
+
const layoutFromDimensions = useCallback(() => {
|
|
69
|
+
const itemHeights = R.map(dimension => dimension.height, renderedDimensions);
|
|
70
|
+
const [totalHeight, heightAccum] = getHeightAccum(itemHeights);
|
|
71
|
+
const itemOffsets = R.prepend(0, heightAccum);
|
|
72
|
+
|
|
73
|
+
const getItemLayout = (data, index) => ({
|
|
74
|
+
index,
|
|
75
|
+
length: itemHeights[index],
|
|
76
|
+
offset: itemOffsets[index]
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
totalHeight,
|
|
81
|
+
getItemLayout
|
|
82
|
+
};
|
|
83
|
+
}, [renderedDimensions]);
|
|
84
|
+
const {
|
|
85
|
+
totalHeight,
|
|
86
|
+
getItemLayout
|
|
87
|
+
} = layoutFromDimensions();
|
|
41
88
|
const viewabilityConfig = useMemo(() => ({
|
|
42
89
|
itemVisiblePercentThreshold
|
|
43
90
|
}), [itemVisiblePercentThreshold]);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const onViewableItemsChanged = useRef(({
|
|
53
|
-
viewableItems
|
|
54
|
-
}) => {
|
|
55
|
-
setItems(prev => {
|
|
56
|
-
const viewableItemIds = R.map(viewableItem => viewableItem.item.id)(viewableItems);
|
|
57
|
-
return R.map(prevItem => ({ ...prevItem,
|
|
58
|
-
isViewable: R.includes(prevItem.id, viewableItemIds)
|
|
59
|
-
}))([...prev]);
|
|
91
|
+
|
|
92
|
+
const updateImageState = updateFunction => {
|
|
93
|
+
const prevImageStates = imageStatesRef.current;
|
|
94
|
+
const newImageStates = prevImageStates.map(updateFunction);
|
|
95
|
+
imageStatesRef.current = newImageStates;
|
|
96
|
+
setItemStates(prevItemStates => {
|
|
97
|
+
const newItemStates = mapImageStatesToItemStates(newImageStates);
|
|
98
|
+
return R.equals(prevItemStates, newItemStates) ? prevItemStates : newItemStates;
|
|
60
99
|
});
|
|
61
|
-
}
|
|
100
|
+
};
|
|
62
101
|
|
|
63
|
-
const
|
|
64
|
-
const
|
|
102
|
+
const loadUrlByIndex = async indexes => {
|
|
103
|
+
const filteredIndexes = R.filter(index => {
|
|
104
|
+
var _state$urlState;
|
|
65
105
|
|
|
66
|
-
|
|
67
|
-
return;
|
|
106
|
+
const state = imageStatesRef.current[index];
|
|
107
|
+
return R.isNil(state.urlState) || ((_state$urlState = state.urlState) === null || _state$urlState === void 0 ? void 0 : _state$urlState.validity) === 'invalid' && !state.isNewUrlIncoming;
|
|
108
|
+
}, indexes);
|
|
109
|
+
updateImageState((imageState, i) => {
|
|
110
|
+
return R.includes(i, filteredIndexes) ? { ...imageState,
|
|
111
|
+
isNewUrlIncoming: true
|
|
112
|
+
} : imageState;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const urls = await getUrlByIndex(filteredIndexes);
|
|
117
|
+
updateImageState((imageState, i) => {
|
|
118
|
+
const newUrl = urls === null || urls === void 0 ? void 0 : urls.get(i);
|
|
119
|
+
const urlState = imageState.urlState;
|
|
120
|
+
|
|
121
|
+
if (newUrl !== undefined && (urlState === null || urlState === void 0 ? void 0 : urlState.validity) !== 'valid') {
|
|
122
|
+
return { ...imageState,
|
|
123
|
+
urlState: {
|
|
124
|
+
url: newUrl,
|
|
125
|
+
validity: 'unknown'
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return imageState;
|
|
131
|
+
});
|
|
132
|
+
} finally {
|
|
133
|
+
updateImageState((imageState, i) => {
|
|
134
|
+
return R.includes(i, filteredIndexes) ? { ...imageState,
|
|
135
|
+
isNewUrlIncoming: false
|
|
136
|
+
} : imageState;
|
|
137
|
+
});
|
|
68
138
|
}
|
|
139
|
+
};
|
|
69
140
|
|
|
70
|
-
|
|
141
|
+
const loadMaybeLoadableItems = async () => {
|
|
142
|
+
const [startIndex, endIndex] = maybeLoadableItemsIndexRange.current;
|
|
143
|
+
const affectedIndexes = R.range(startIndex, endIndex);
|
|
144
|
+
await loadUrlByIndex(affectedIndexes);
|
|
71
145
|
};
|
|
72
146
|
|
|
73
|
-
const
|
|
74
|
-
|
|
147
|
+
const loadItemsDebounce = useDebounce(loadMaybeLoadableItems, debounceMillis);
|
|
148
|
+
const onViewableItemsChanged = useRef(_ref => {
|
|
149
|
+
var _R$head, _R$last;
|
|
75
150
|
|
|
76
|
-
|
|
77
|
-
|
|
151
|
+
let {
|
|
152
|
+
viewableItems
|
|
153
|
+
} = _ref;
|
|
154
|
+
const orderedViewableItems = R.sort((a, b) => (a.index || 0) - (b.index || 0), viewableItems);
|
|
155
|
+
const firstViewableIndex = (_R$head = R.head(orderedViewableItems)) === null || _R$head === void 0 ? void 0 : _R$head.index;
|
|
156
|
+
const lastViewableItemIndex = (_R$last = R.last(orderedViewableItems)) === null || _R$last === void 0 ? void 0 : _R$last.index;
|
|
157
|
+
|
|
158
|
+
if (R.isNil(firstViewableIndex) || R.isNil(lastViewableItemIndex)) {
|
|
159
|
+
return;
|
|
78
160
|
}
|
|
79
161
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
162
|
+
const startIndex = R.max(firstViewableIndex - NUMBER_OF_ADJACENT_ITEM, 0);
|
|
163
|
+
const endIndex = R.min(lastViewableItemIndex + NUMBER_OF_ADJACENT_ITEM, itemStates.length - 1);
|
|
164
|
+
maybeLoadableItemsIndexRange.current = [startIndex, endIndex + 1];
|
|
165
|
+
loadItemsDebounce();
|
|
166
|
+
});
|
|
167
|
+
const renderItem = useCallback(_ref2 => {
|
|
168
|
+
var _renderedDimensions$i, _renderedDimensions$i2;
|
|
169
|
+
|
|
170
|
+
let {
|
|
171
|
+
item,
|
|
172
|
+
index
|
|
173
|
+
} = _ref2;
|
|
174
|
+
|
|
175
|
+
const onError = () => {
|
|
176
|
+
updateImageState((imageState, i) => {
|
|
177
|
+
const urlState = imageState.urlState;
|
|
178
|
+
|
|
179
|
+
if (i === index && urlState !== undefined) {
|
|
180
|
+
return { ...imageState,
|
|
181
|
+
totalErrorCount: imageState.totalErrorCount + 1,
|
|
182
|
+
urlState: { ...urlState,
|
|
183
|
+
validity: 'invalid'
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return imageState;
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
if (item.reloadButtonVisible) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const [startIndex, endIndex] = maybeLoadableItemsIndexRange.current;
|
|
196
|
+
|
|
197
|
+
if (index >= startIndex || index < endIndex) {
|
|
198
|
+
loadItemsDebounce();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const onReloadPress = () => {
|
|
203
|
+
const [startIndex, endIndex] = maybeLoadableItemsIndexRange.current;
|
|
204
|
+
|
|
205
|
+
if (index >= startIndex || index < endIndex) {
|
|
206
|
+
loadUrlByIndex([index]);
|
|
207
|
+
}
|
|
95
208
|
};
|
|
96
|
-
return /*#__PURE__*/React.createElement(ViewerItem, {
|
|
97
|
-
props: props
|
|
98
|
-
});
|
|
99
|
-
}, []);
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
setItems(prev => {
|
|
102
|
-
return R.map(prevItem => {
|
|
103
|
-
const currentData = R.find(currentItemData => prevItem.id === currentItemData.id)(data);
|
|
104
209
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
210
|
+
const onLoad = () => {
|
|
211
|
+
updateImageState((imageState, i) => {
|
|
212
|
+
const urlState = imageState.urlState;
|
|
213
|
+
|
|
214
|
+
if (i === index && urlState !== undefined) {
|
|
215
|
+
return { ...imageState,
|
|
216
|
+
urlState: { ...urlState,
|
|
217
|
+
validity: 'valid'
|
|
218
|
+
}
|
|
108
219
|
};
|
|
109
220
|
}
|
|
110
221
|
|
|
111
|
-
return
|
|
112
|
-
})
|
|
222
|
+
return imageState;
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
return /*#__PURE__*/React.createElement(ViewerItem, {
|
|
227
|
+
onError: onError,
|
|
228
|
+
onLoad: onLoad,
|
|
229
|
+
onPress: onItemPress,
|
|
230
|
+
onReloadPress: onReloadPress,
|
|
231
|
+
url: item.url,
|
|
232
|
+
width: ((_renderedDimensions$i = renderedDimensions[index]) === null || _renderedDimensions$i === void 0 ? void 0 : _renderedDimensions$i.width) ?? 0,
|
|
233
|
+
height: ((_renderedDimensions$i2 = renderedDimensions[index]) === null || _renderedDimensions$i2 === void 0 ? void 0 : _renderedDimensions$i2.height) ?? 0,
|
|
234
|
+
reloadButtonVisible: item.reloadButtonVisible
|
|
113
235
|
});
|
|
114
|
-
}, [
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
const newItems = R.map(item => ({ ...item,
|
|
117
|
-
width: viewerWidth,
|
|
118
|
-
height: item.height * viewerWidth / item.width
|
|
119
|
-
}))(items);
|
|
120
|
-
setItems(newItems);
|
|
121
|
-
}, [viewerWidth]);
|
|
236
|
+
}, [onItemPress, renderedDimensions]);
|
|
122
237
|
useEffect(() => {
|
|
123
|
-
const totalHeight = itemHeightAccum[0];
|
|
124
238
|
const offset = Math.floor(initialScrollPercentage / 100 * totalHeight);
|
|
125
239
|
|
|
126
240
|
if (flatListRef.current) {
|
|
@@ -129,14 +243,15 @@ export default function ComicViewer(props) {
|
|
|
129
243
|
animated: false
|
|
130
244
|
});
|
|
131
245
|
}
|
|
132
|
-
}, [
|
|
246
|
+
}, []);
|
|
133
247
|
return /*#__PURE__*/React.createElement(FlatList, _extends({
|
|
134
|
-
data:
|
|
248
|
+
data: itemStates,
|
|
135
249
|
getItemLayout: getItemLayout,
|
|
136
250
|
initialNumToRender: initialNumToRender,
|
|
137
251
|
keyExtractor: keyExtractor,
|
|
138
252
|
onViewableItemsChanged: onViewableItemsChanged.current,
|
|
139
253
|
ref: flatListRef,
|
|
254
|
+
removeClippedSubviews: false,
|
|
140
255
|
renderItem: renderItem,
|
|
141
256
|
viewabilityConfig: viewabilityConfig,
|
|
142
257
|
windowSize: windowSize
|