@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
package/src/ViewPager/index.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
export { default } from './
|
|
2
|
-
export type { default as ViewPagerProps } from './ViewPagerProps';
|
|
1
|
+
export { default } from './ViewPager';
|
|
2
|
+
export type { default as ViewPagerProps } from './ViewPagerProps';
|
|
3
|
+
export type { ViewPagerInstance } from './types';
|
|
4
|
+
export {
|
|
5
|
+
useDispatch as useFluxDispatch,
|
|
6
|
+
useEagerState,
|
|
7
|
+
useStore as useFluxStore,
|
|
8
|
+
useLazyState,
|
|
9
|
+
useViewPagerPageState,
|
|
10
|
+
} from './hooks';
|
|
11
|
+
export { FluxStoreProvider } from './components';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type KeyboardDismissMode = 'none' | 'on-drag';
|
|
2
|
+
|
|
3
|
+
export type Loading = 'lazy' | 'eager';
|
|
4
|
+
|
|
5
|
+
export interface EqualityFunction<State> {
|
|
6
|
+
(a: State, b: State): boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ViewPagerInstance {
|
|
10
|
+
/**
|
|
11
|
+
* Function to scroll to a specific page in the ViewPager. Invalid index is ignored.
|
|
12
|
+
* @param index
|
|
13
|
+
*/
|
|
14
|
+
setPage: (index: number) => void;
|
|
15
|
+
}
|
package/src/ViewPager/utils.tsx
CHANGED
|
@@ -1,62 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import ViewPagerProps, { Loading, PageComponent } from './ViewPagerProps';
|
|
3
|
-
import ChildrenMemoizedPage from './ChildrenMemoizedPage';
|
|
1
|
+
import type { EqualityFunction, Loading } from './types';
|
|
4
2
|
|
|
5
|
-
export
|
|
6
|
-
visited?: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface PageRenderOption {
|
|
10
|
-
enableVisibleHint: boolean;
|
|
11
|
-
enableNeighborPageRerender: boolean;
|
|
12
|
-
index: number;
|
|
13
|
-
loading: Loading;
|
|
14
|
-
pageComponent: PageComponent;
|
|
15
|
-
pageForceRerenderKey?: any;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface PageRenderer {
|
|
19
|
-
(children: ViewPagerProps['children']): React.ReactNode;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const defaultEnableVisibleHint: boolean = false;
|
|
23
|
-
|
|
24
|
-
export const defaultEnableNeighborPageRerender: boolean = false;
|
|
3
|
+
export const defaultInitialPage: number = 0;
|
|
25
4
|
|
|
26
5
|
export const defaultLoading: Loading = 'lazy';
|
|
27
6
|
|
|
28
|
-
export const
|
|
29
|
-
|
|
30
|
-
export const usePageRenderer = ({
|
|
31
|
-
enableVisibleHint,
|
|
32
|
-
index: currentIndex,
|
|
33
|
-
loading,
|
|
34
|
-
pageComponent: PageComponent,
|
|
35
|
-
pageForceRerenderKey,
|
|
36
|
-
enableNeighborPageRerender,
|
|
37
|
-
}: PageRenderOption): PageRenderer => {
|
|
38
|
-
const pagesStateRef = React.useRef<Array<PageState>>([]);
|
|
39
|
-
|
|
40
|
-
pagesStateRef.current[currentIndex] = {
|
|
41
|
-
...pagesStateRef.current[currentIndex],
|
|
42
|
-
visited: true,
|
|
43
|
-
};
|
|
7
|
+
export const defaultOffscreenPageRerenderLimit: number = 0;
|
|
44
8
|
|
|
45
|
-
|
|
46
|
-
const visited = pagesStateRef.current[index]?.visited ?? false;
|
|
47
|
-
const content = (loading === 'eager' || visited) ? child : null;
|
|
9
|
+
export const refEqual: EqualityFunction<any> = (a: any, b: any) => a === b;
|
|
48
10
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
key={index}
|
|
55
|
-
children={content}
|
|
56
|
-
isNeighbor={enableNeighborPageRerender && isNeighborIndex}
|
|
57
|
-
isVisible={isVisible}
|
|
58
|
-
rerenderKey={pageForceRerenderKey}
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
61
|
-
}));
|
|
62
|
-
};
|
|
11
|
+
export function isValidPage(maybePage: number, numberOfPages: number) {
|
|
12
|
+
return Number.isInteger(maybePage)
|
|
13
|
+
&& maybePage >= 0
|
|
14
|
+
&& maybePage < numberOfPages;
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import useViewabilityTracker from './useViewabilityTracker';
|
|
4
|
+
import type ViewabilityTrackerViewProps from './ViewabilityTrackerViewProps';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default function ViewabilityTrackerView(props: ViewabilityTrackerViewProps) {
|
|
8
|
+
const {
|
|
9
|
+
enabled = true,
|
|
10
|
+
measurementIntervalMillis = 1000,
|
|
11
|
+
onViewabilityChange,
|
|
12
|
+
visiblePercentThreshold = 50,
|
|
13
|
+
...otherProps
|
|
14
|
+
} = props;
|
|
15
|
+
|
|
16
|
+
const viewRef = useRef<View>(null);
|
|
17
|
+
|
|
18
|
+
useViewabilityTracker({
|
|
19
|
+
enabled,
|
|
20
|
+
measurementIntervalMillis,
|
|
21
|
+
onViewabilityChange,
|
|
22
|
+
viewRef,
|
|
23
|
+
visiblePercentThreshold,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<View
|
|
28
|
+
{...otherProps}
|
|
29
|
+
ref={viewRef}
|
|
30
|
+
collapsable={false}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type { OverridableComponentProps } from '@fountain-ui/core';
|
|
3
|
+
import type Viewability from './Viewability';
|
|
4
|
+
|
|
5
|
+
export default interface ViewabilityTrackerViewProps extends OverridableComponentProps<ViewProps, {
|
|
6
|
+
/**
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @default 1000
|
|
13
|
+
*/
|
|
14
|
+
measurementIntervalMillis?: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
onViewabilityChange?: (viewability: Viewability) => void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @default 50
|
|
23
|
+
*/
|
|
24
|
+
visiblePercentThreshold?: number;
|
|
25
|
+
}> {}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { View } from 'react-native';
|
|
2
|
+
import { clamp } from '@fountain-ui/utils';
|
|
3
|
+
|
|
4
|
+
interface Rect {
|
|
5
|
+
top: number,
|
|
6
|
+
bottom: number;
|
|
7
|
+
left: number;
|
|
8
|
+
right: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ViewabilityDetail {
|
|
12
|
+
visiblePercent: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MeasureViewabilityParameters {
|
|
16
|
+
view: View;
|
|
17
|
+
windowWidth: number;
|
|
18
|
+
windowHeight: number;
|
|
19
|
+
onViewabilityDetailMeasured: (detail: ViewabilityDetail) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const computeRectSize = (rect: Rect): number =>
|
|
23
|
+
(rect.bottom - rect.top) * (rect.right - rect.left);
|
|
24
|
+
|
|
25
|
+
const normalizePagePosition = (value?: number): number =>
|
|
26
|
+
(value != null && Number.isFinite(value)) ? value : Number.MAX_SAFE_INTEGER;
|
|
27
|
+
|
|
28
|
+
const normalizeViewSize = (size: number): number =>
|
|
29
|
+
Number.isFinite(size) && size > 0 ? size : Number.MAX_SAFE_INTEGER;
|
|
30
|
+
|
|
31
|
+
export default function measureViewability({
|
|
32
|
+
view,
|
|
33
|
+
windowWidth,
|
|
34
|
+
windowHeight,
|
|
35
|
+
onViewabilityDetailMeasured,
|
|
36
|
+
}: MeasureViewabilityParameters) {
|
|
37
|
+
view.measure((x, y, width, height, pageX?: number, pageY?: number) => {
|
|
38
|
+
const safePageX = normalizePagePosition(pageX);
|
|
39
|
+
const safePageY = normalizePagePosition(pageY);
|
|
40
|
+
|
|
41
|
+
const visibleRect: Rect = {
|
|
42
|
+
top: clamp(safePageY, 0, windowHeight),
|
|
43
|
+
bottom: clamp(safePageY + height, 0, windowHeight),
|
|
44
|
+
left: clamp(safePageX, 0, windowWidth),
|
|
45
|
+
right: clamp(safePageX + width, 0, windowWidth),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const visibleRectSize = computeRectSize(visibleRect);
|
|
49
|
+
const viewSize = normalizeViewSize(width * height);
|
|
50
|
+
const visiblePercent = Math.round(visibleRectSize / viewSize * 100);
|
|
51
|
+
|
|
52
|
+
onViewabilityDetailMeasured?.({ visiblePercent });
|
|
53
|
+
});
|
|
54
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import type { View } from 'react-native';
|
|
4
|
+
import { useValidWindowDimensions } from '@fountain-ui/core';
|
|
5
|
+
import { useDeferredExecutor } from '../hooks';
|
|
6
|
+
import type { ViewabilityDetail } from './measureViewability';
|
|
7
|
+
import measureViewability from './measureViewability';
|
|
8
|
+
import type Viewability from './Viewability';
|
|
9
|
+
|
|
10
|
+
export interface ViewabilityTrackerConfig {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
measurementIntervalMillis: number;
|
|
13
|
+
onViewabilityChange?: (viewability: Viewability) => void;
|
|
14
|
+
viewRef: RefObject<View>;
|
|
15
|
+
visiblePercentThreshold: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const initialViewability: Readonly<Viewability> = { visible: false };
|
|
19
|
+
|
|
20
|
+
export default function useViewabilityTracker(config: ViewabilityTrackerConfig) {
|
|
21
|
+
const {
|
|
22
|
+
enabled,
|
|
23
|
+
measurementIntervalMillis,
|
|
24
|
+
onViewabilityChange,
|
|
25
|
+
viewRef,
|
|
26
|
+
visiblePercentThreshold,
|
|
27
|
+
} = config;
|
|
28
|
+
|
|
29
|
+
const viewabilityRef = useRef<Viewability>(initialViewability);
|
|
30
|
+
|
|
31
|
+
const executor = useDeferredExecutor();
|
|
32
|
+
|
|
33
|
+
const window = useValidWindowDimensions();
|
|
34
|
+
|
|
35
|
+
const maybeMeasureRecursive = () => {
|
|
36
|
+
if (!enabled) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const mapViewabilityDetailToViewability = (detail: ViewabilityDetail): Viewability => {
|
|
41
|
+
return { visible: detail.visiblePercent >= visiblePercentThreshold };
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const isViewabilityEquals = (a: Viewability, b: Viewability): boolean => {
|
|
45
|
+
return a.visible === b.visible;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const dispatchViewabilityChanged = (viewability: Viewability) => {
|
|
49
|
+
executor.execute(() => onViewabilityChange?.(viewability));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const onViewabilityDetailMeasured = (detail: ViewabilityDetail) => {
|
|
53
|
+
const nextViewability = mapViewabilityDetailToViewability(detail);
|
|
54
|
+
|
|
55
|
+
if (!isViewabilityEquals(viewabilityRef.current, nextViewability)) {
|
|
56
|
+
viewabilityRef.current = nextViewability;
|
|
57
|
+
|
|
58
|
+
dispatchViewabilityChanged(nextViewability);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
maybeMeasureRecursive();
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const maybeMeasure = () => {
|
|
65
|
+
if (viewRef.current) {
|
|
66
|
+
measureViewability({
|
|
67
|
+
view: viewRef.current,
|
|
68
|
+
windowWidth: window.width,
|
|
69
|
+
windowHeight: window.height,
|
|
70
|
+
onViewabilityDetailMeasured,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
executor.execute(maybeMeasure, measurementIntervalMillis);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (enabled) {
|
|
80
|
+
maybeMeasureRecursive();
|
|
81
|
+
} else {
|
|
82
|
+
executor.cancel();
|
|
83
|
+
}
|
|
84
|
+
}, [enabled]);
|
|
85
|
+
};
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { default as useDeferredExecutor } from './useDeferredExecutor';
|
|
2
|
+
export { default as useIsMounted } from './useIsMounted';
|
|
1
3
|
export { default as useUnstableCollapsibleAppBar } from './useUnstableCollapsibleAppBar';
|
|
2
4
|
export { default as useUnstableToggleDisplayStyle } from './useUnstableToggleDisplayStyle';
|
|
3
5
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import useIsMounted from './useIsMounted';
|
|
3
|
+
|
|
4
|
+
export interface Runnable {
|
|
5
|
+
(): void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface DeferredExecute {
|
|
9
|
+
(runnable: Runnable, delay?: number): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DeferredExecutor {
|
|
13
|
+
cancel: () => void;
|
|
14
|
+
execute: DeferredExecute;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default function useDeferredExecutor(): DeferredExecutor {
|
|
18
|
+
const isMounted = useIsMounted();
|
|
19
|
+
const timeoutIdRef = useRef<NodeJS.Timer | null>(null);
|
|
20
|
+
|
|
21
|
+
const cancel = useCallback(() => {
|
|
22
|
+
if (timeoutIdRef.current) {
|
|
23
|
+
clearTimeout(timeoutIdRef.current);
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
return cancel;
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
const execute = useCallback<DeferredExecute>((runnable, delay) => {
|
|
32
|
+
if (!isMounted()) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
cancel();
|
|
37
|
+
|
|
38
|
+
if (Number.isFinite(delay)) {
|
|
39
|
+
timeoutIdRef.current = setTimeout(() => runnable(), delay);
|
|
40
|
+
} else {
|
|
41
|
+
runnable();
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
45
|
+
return { cancel, execute };
|
|
46
|
+
};
|
package/src/hooks/useHeight.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ViewProps } from 'react-native';
|
|
3
|
-
import
|
|
3
|
+
import { useWorkletCallback } from 'react-native-reanimated';
|
|
4
4
|
|
|
5
5
|
type OnLayoutCallback = ViewProps['onLayout'];
|
|
6
6
|
|
|
7
7
|
export default function useHeight(initialHeight = 0): [number, OnLayoutCallback] {
|
|
8
8
|
const [height, setHeight] = React.useState<number>(initialHeight);
|
|
9
9
|
|
|
10
|
-
const onLayout =
|
|
10
|
+
const onLayout = useWorkletCallback((e) => {
|
|
11
11
|
setHeight(e.nativeEvent.layout.height);
|
|
12
12
|
}, []);
|
|
13
13
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface UseIsMounted {
|
|
4
|
+
(): boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default function useIsMounted(): UseIsMounted {
|
|
8
|
+
const mountedRef = useRef<boolean>(false);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
mountedRef.current = true;
|
|
12
|
+
|
|
13
|
+
return () => {
|
|
14
|
+
mountedRef.current = false;
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
return useCallback(() => mountedRef.current, []);
|
|
19
|
+
};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
2
|
import { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
-
import
|
|
3
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
4
|
+
import {
|
|
5
|
+
useAnimatedScrollHandler,
|
|
6
|
+
useAnimatedStyle,
|
|
7
|
+
useDerivedValue,
|
|
8
|
+
useSharedValue,
|
|
9
|
+
withTiming,
|
|
10
|
+
} from 'react-native-reanimated';
|
|
4
11
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
5
12
|
import useAppbarStyles from './useAppbarStyles';
|
|
6
13
|
import useElevationStyle from './useElevationStyle';
|
|
@@ -22,13 +29,12 @@ export interface ContentInsets {
|
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
export interface Options {
|
|
25
|
-
translucent?: boolean;
|
|
26
32
|
shouldTranslateYReset?: boolean;
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
export interface CollapsibleAppBar {
|
|
30
36
|
appBarStyle: ViewStyleProp;
|
|
31
|
-
vectorY:
|
|
37
|
+
vectorY: SharedValue<number>;
|
|
32
38
|
onAppBarLayout: OnLayoutCallback;
|
|
33
39
|
onCollapsibleToolbarLayout: OnLayoutCallback;
|
|
34
40
|
onScroll: OnScroll;
|
|
@@ -37,7 +43,6 @@ export interface CollapsibleAppBar {
|
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
const defaultOptions: Required<Options> = {
|
|
40
|
-
translucent: false,
|
|
41
46
|
shouldTranslateYReset: false,
|
|
42
47
|
};
|
|
43
48
|
|
|
@@ -45,7 +50,6 @@ const ANIMATION_DURATION_MILLIS = 100;
|
|
|
45
50
|
|
|
46
51
|
const SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';
|
|
47
52
|
|
|
48
|
-
|
|
49
53
|
function useLargerValueOfLastTwoValues(value: number) {
|
|
50
54
|
const refLatestTwoValues = useRef([0, 0]);
|
|
51
55
|
|
|
@@ -55,12 +59,8 @@ function useLargerValueOfLastTwoValues(value: number) {
|
|
|
55
59
|
return Math.max(...refLatestTwoValues.current);
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
|
|
59
62
|
export default function useUnstableCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {
|
|
60
|
-
const {
|
|
61
|
-
translucent,
|
|
62
|
-
shouldTranslateYReset,
|
|
63
|
-
}: Required<Options> = {
|
|
63
|
+
const { shouldTranslateYReset }: Required<Options> = {
|
|
64
64
|
...defaultOptions,
|
|
65
65
|
...userOptions,
|
|
66
66
|
};
|
|
@@ -73,38 +73,55 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
|
|
|
73
73
|
const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);
|
|
74
74
|
const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();
|
|
75
75
|
|
|
76
|
-
const maxTranslateY =
|
|
76
|
+
const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight, [collapsibleToolbarHeight]);
|
|
77
77
|
|
|
78
|
-
const translateY =
|
|
79
|
-
const lastTranslateY =
|
|
80
|
-
const lastOffsetY =
|
|
81
|
-
const prevOffsetY =
|
|
82
|
-
const overlapped =
|
|
83
|
-
const vectorY =
|
|
78
|
+
const translateY = useSharedValue<number>(0);
|
|
79
|
+
const lastTranslateY = useSharedValue<number>(0);
|
|
80
|
+
const lastOffsetY = useSharedValue<number>(0);
|
|
81
|
+
const prevOffsetY = useSharedValue<number>(0);
|
|
82
|
+
const overlapped = useSharedValue<boolean>(false);
|
|
83
|
+
const vectorY = useSharedValue<number>(0);
|
|
84
84
|
|
|
85
85
|
const elevationStyle = useElevationStyle(4);
|
|
86
|
-
const animatedStyle =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
86
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
87
|
+
const transform = [{ translateY: translateY.value }];
|
|
88
|
+
|
|
89
|
+
if (Platform.OS === 'web') {
|
|
90
|
+
return {
|
|
91
|
+
transform,
|
|
92
|
+
boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (Platform.OS === 'android') {
|
|
96
|
+
return {
|
|
97
|
+
transform,
|
|
98
|
+
elevation: overlapped.value ? elevationStyle?.elevation : 0,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (Platform.OS === 'ios') {
|
|
102
|
+
return {
|
|
103
|
+
transform,
|
|
104
|
+
shadowColor: elevationStyle?.shadowColor,
|
|
105
|
+
shadowOffset: elevationStyle?.shadowOffset,
|
|
106
|
+
shadowRadius: elevationStyle?.shadowRadius,
|
|
107
|
+
shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {};
|
|
111
|
+
}, [
|
|
112
|
+
/**
|
|
113
|
+
* FIXME: Consider add `elevationStyle` to dependencies.
|
|
114
|
+
*/
|
|
115
|
+
]);
|
|
116
|
+
|
|
117
|
+
const indexRef = useRef<number>(0);
|
|
118
|
+
const offsetsRef = useRef<Array<number>>([]);
|
|
119
|
+
|
|
120
|
+
const onScrollViewChanged = useCallback((nextIndex: number) => {
|
|
104
121
|
const prevIndex = indexRef.current;
|
|
105
122
|
if (prevIndex === nextIndex) {
|
|
106
123
|
if (shouldTranslateYReset) {
|
|
107
|
-
translateY.value =
|
|
124
|
+
translateY.value = withTiming(0, {
|
|
108
125
|
duration: ANIMATION_DURATION_MILLIS,
|
|
109
126
|
});
|
|
110
127
|
|
|
@@ -128,15 +145,15 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
|
|
|
128
145
|
|
|
129
146
|
// If next ScrollView's offset is too short, expand app bar.
|
|
130
147
|
if (translateY.value < 0 && savedOffsetY < appBarHeight) {
|
|
131
|
-
translateY.value =
|
|
148
|
+
translateY.value = withTiming(0, {
|
|
132
149
|
duration: ANIMATION_DURATION_MILLIS,
|
|
133
150
|
});
|
|
134
151
|
|
|
135
152
|
vectorY.value = 0;
|
|
136
153
|
}
|
|
137
|
-
};
|
|
154
|
+
}, [appBarHeight]);
|
|
138
155
|
|
|
139
|
-
const scrollHandler =
|
|
156
|
+
const scrollHandler = useAnimatedScrollHandler({
|
|
140
157
|
onBeginDrag: () => {
|
|
141
158
|
lastTranslateY.value = translateY.value;
|
|
142
159
|
},
|
|
@@ -162,13 +179,13 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
|
|
|
162
179
|
} else {
|
|
163
180
|
if (offsetY > -maxTy) {
|
|
164
181
|
if (ty === 0) {
|
|
165
|
-
translateY.value =
|
|
182
|
+
translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {
|
|
166
183
|
duration: ANIMATION_DURATION_MILLIS,
|
|
167
184
|
});
|
|
168
185
|
}
|
|
169
186
|
} else {
|
|
170
187
|
if (ty === maxTy) {
|
|
171
|
-
translateY.value =
|
|
188
|
+
translateY.value = withTiming(0, {
|
|
172
189
|
duration: ANIMATION_DURATION_MILLIS,
|
|
173
190
|
});
|
|
174
191
|
}
|
|
@@ -201,17 +218,17 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
|
|
|
201
218
|
|
|
202
219
|
overlapped.value = offsetY + nextTranslateY > 0;
|
|
203
220
|
|
|
204
|
-
translateY.value =
|
|
221
|
+
translateY.value = withTiming(nextTranslateY, {
|
|
205
222
|
duration: ANIMATION_DURATION_MILLIS,
|
|
206
223
|
});
|
|
207
224
|
},
|
|
208
|
-
});
|
|
225
|
+
}, [appBarHeight]);
|
|
209
226
|
|
|
210
227
|
const hasCollapsible = collapsibleToolbarHeight > 0;
|
|
211
228
|
|
|
212
229
|
const appBarStyle = [
|
|
213
230
|
animatedStyle,
|
|
214
|
-
|
|
231
|
+
{ paddingTop: safeAreaInsets.top },
|
|
215
232
|
hasCollapsible ? styles.floating : undefined,
|
|
216
233
|
];
|
|
217
234
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
2
|
+
import { useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
2
3
|
|
|
3
4
|
export default function useAnimatedDisplayStyle(
|
|
4
|
-
vectorY:
|
|
5
|
+
vectorY: SharedValue<number>,
|
|
5
6
|
threshold: number = 200,
|
|
6
7
|
defaultDisplay: 'flex' | 'none' = 'flex',
|
|
7
8
|
) {
|
|
8
|
-
const display =
|
|
9
|
+
const display = useSharedValue(defaultDisplay);
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
useAnimatedReaction(
|
|
11
12
|
() => vectorY.value,
|
|
12
13
|
(vy) => {
|
|
13
14
|
if (vy >= threshold) {
|
|
@@ -16,9 +17,10 @@ export default function useAnimatedDisplayStyle(
|
|
|
16
17
|
display.value = 'flex';
|
|
17
18
|
}
|
|
18
19
|
},
|
|
20
|
+
[threshold],
|
|
19
21
|
);
|
|
20
22
|
|
|
21
|
-
return
|
|
23
|
+
return useAnimatedStyle(() => ({
|
|
22
24
|
display: display.value,
|
|
23
|
-
}));
|
|
25
|
+
}), []);
|
|
24
26
|
};
|
package/src/index.ts
CHANGED
|
@@ -19,4 +19,7 @@ export * from './ComicViewer';
|
|
|
19
19
|
export { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';
|
|
20
20
|
export * from './StatusBarProvider';
|
|
21
21
|
|
|
22
|
+
export { default as ViewabilityTrackerView } from './ViewabilityTrackerView';
|
|
23
|
+
export * from './ViewabilityTrackerView';
|
|
24
|
+
|
|
22
25
|
export * from './hooks';
|