@fountain-ui/lab 2.0.0-beta.8 → 2.0.0-beta.80
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 +8 -10
- package/build/commonjs/AnimatedY/AnimatedY.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetNative.js +65 -7
- package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetWeb.js +41 -13
- package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
- package/build/commonjs/BottomSheet/useDynamicSnapPoints.js +65 -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 +26 -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 +84 -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 +230 -92
- 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/FastScroll.js +175 -0
- package/build/commonjs/ComicViewer/FastScroll.js.map +1 -0
- package/build/commonjs/ComicViewer/{ComicViewerItemProps.js → FastScrollProps.js} +1 -1
- package/build/commonjs/ComicViewer/FastScrollProps.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 +53 -59
- package/build/commonjs/ComicViewer/ViewerItem.js.map +1 -1
- package/build/commonjs/ComicViewer/index.js.map +1 -1
- package/build/commonjs/ComicViewer/util.js +27 -0
- package/build/commonjs/ComicViewer/util.js.map +1 -0
- package/build/commonjs/DateTimePicker/DateTimePicker.js +10 -1
- package/build/commonjs/DateTimePicker/DateTimePicker.js.map +1 -1
- package/build/commonjs/FlipCard/FlipCard.js +2 -2
- package/build/commonjs/FlipCard/FlipCard.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 +14 -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 +152 -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 +43 -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 -45
- 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/useDeferredExecutor.js +45 -0
- package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
- package/build/commonjs/hooks/useHeight.js +4 -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 +19 -25
- package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
- package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js +2 -2
- package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
- package/build/commonjs/index.js +22 -1
- package/build/commonjs/index.js.map +1 -1
- package/build/module/AnimatedY/AnimatedY.js +8 -7
- package/build/module/AnimatedY/AnimatedY.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetNative.js +64 -9
- package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetWeb.js +40 -14
- package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
- package/build/module/BottomSheet/useDynamicSnapPoints.js +52 -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 +12 -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 +69 -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 +229 -93
- 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/FastScroll.js +152 -0
- package/build/module/ComicViewer/FastScroll.js.map +1 -0
- package/build/module/ComicViewer/FastScrollProps.js +2 -0
- package/build/module/ComicViewer/FastScrollProps.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 +53 -60
- package/build/module/ComicViewer/ViewerItem.js.map +1 -1
- package/build/module/ComicViewer/index.js.map +1 -1
- package/build/module/ComicViewer/util.js +15 -0
- package/build/module/ComicViewer/util.js.map +1 -0
- package/build/module/DateTimePicker/DateTimePicker.js +11 -2
- package/build/module/DateTimePicker/DateTimePicker.js.map +1 -1
- package/build/module/FlipCard/FlipCard.js +2 -2
- package/build/module/FlipCard/FlipCard.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 +5 -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 +129 -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 +28 -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 -34
- 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/useDeferredExecutor.js +33 -0
- package/build/module/hooks/useDeferredExecutor.js.map +1 -0
- package/build/module/hooks/useHeight.js +2 -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 +19 -19
- package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
- package/build/module/hooks/useUnstableToggleDisplayStyle.js +2 -2
- 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 +1 -0
- package/build/typescript/BottomSheet/BottomSheetNative.d.ts +1 -0
- package/build/typescript/BottomSheet/BottomSheetProps.d.ts +32 -1
- package/build/typescript/BottomSheet/BottomSheetWeb.d.ts +1 -0
- package/build/typescript/BottomSheet/TransparentBackdrop.d.ts +1 -0
- package/build/typescript/BottomSheet/useDynamicSnapPoints.d.ts +12 -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 +2 -1
- package/build/typescript/ComicViewer/ComicViewerProps.d.ts +61 -43
- package/build/typescript/ComicViewer/EncodedTile.d.ts +2 -0
- package/build/typescript/ComicViewer/FastScroll.d.ts +4 -0
- package/build/typescript/ComicViewer/FastScrollProps.d.ts +74 -0
- package/build/typescript/ComicViewer/ReloadButton.d.ts +7 -0
- package/build/typescript/ComicViewer/ViewerItem.d.ts +46 -7
- package/build/typescript/ComicViewer/index.d.ts +3 -2
- package/build/typescript/ComicViewer/util.d.ts +2 -0
- package/build/typescript/DateTimePicker/DateTimePicker.d.ts +1 -0
- package/build/typescript/DateTimePicker/YearPicker.d.ts +1 -0
- package/build/typescript/FlipCard/FlipCard.d.ts +1 -0
- package/build/typescript/StatusBarProvider/StatusBarProvider.d.ts +1 -0
- 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 +21 -27
- 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 +3 -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/index.d.ts +2 -0
- package/package.json +9 -24
- package/src/AnimatedY/AnimatedY.tsx +10 -7
- package/src/BottomSheet/BottomSheetNative.tsx +68 -6
- package/src/BottomSheet/BottomSheetProps.ts +38 -1
- package/src/BottomSheet/BottomSheetWeb.tsx +54 -16
- package/src/BottomSheet/useDynamicSnapPoints.ts +73 -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 +14 -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 +93 -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 +268 -106
- package/src/ComicViewer/ComicViewerProps.ts +66 -44
- package/src/ComicViewer/EncodedTile.ts +3 -0
- package/src/ComicViewer/FastScroll.tsx +176 -0
- package/src/ComicViewer/FastScrollProps.ts +88 -0
- package/src/ComicViewer/ReloadButton.tsx +36 -0
- package/src/ComicViewer/ViewerItem.tsx +104 -62
- package/src/ComicViewer/index.ts +8 -2
- package/src/ComicViewer/util.ts +15 -0
- package/src/DateTimePicker/DateTimePicker.tsx +9 -1
- package/src/FlipCard/FlipCard.tsx +2 -2
- 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 +152 -0
- package/src/ViewPager/ViewPager.tsx +69 -0
- package/src/ViewPager/ViewPagerProps.ts +25 -34
- 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 +3 -4
- package/src/hooks/useIsMounted.ts +19 -0
- package/src/hooks/useUnstableCollapsibleAppBar.ts +17 -13
- package/src/hooks/useUnstableToggleDisplayStyle.ts +2 -1
- 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.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 -75
- 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/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 -58
- 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/typescript/Carousel/CarouselNative.d.ts +0 -2
- 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 -2
- package/build/typescript/ViewPager/ViewPagerWeb.d.ts +0 -2
- package/build/typescript/ViewPager/index.native.d.ts +0 -1
- 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 -73
- package/src/ViewPager/ViewPagerWeb.tsx +0 -52
- package/src/ViewPager/index.native.ts +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import useIsMounted from './useIsMounted';
|
|
3
|
+
export default function useDeferredExecutor() {
|
|
4
|
+
const isMounted = useIsMounted();
|
|
5
|
+
const timeoutIdRef = useRef(null);
|
|
6
|
+
const cancel = useCallback(() => {
|
|
7
|
+
if (timeoutIdRef.current) {
|
|
8
|
+
clearTimeout(timeoutIdRef.current);
|
|
9
|
+
}
|
|
10
|
+
}, []);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
return cancel;
|
|
13
|
+
}, []);
|
|
14
|
+
const execute = useCallback((runnable, delay) => {
|
|
15
|
+
if (!isMounted()) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
cancel();
|
|
20
|
+
|
|
21
|
+
if (Number.isFinite(delay)) {
|
|
22
|
+
timeoutIdRef.current = setTimeout(() => runnable(), delay);
|
|
23
|
+
} else {
|
|
24
|
+
runnable();
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
return {
|
|
28
|
+
cancel,
|
|
29
|
+
execute
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
;
|
|
33
|
+
//# sourceMappingURL=useDeferredExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useIsMounted","useDeferredExecutor","isMounted","timeoutIdRef","cancel","current","clearTimeout","execute","runnable","delay","Number","isFinite","setTimeout"],"sources":["useDeferredExecutor.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport useIsMounted from './useIsMounted';\n\nexport interface Runnable {\n (): void;\n}\n\nexport interface DeferredExecute {\n (runnable: Runnable, delay?: number): void;\n}\n\nexport interface DeferredExecutor {\n cancel: () => void;\n execute: DeferredExecute;\n}\n\nexport default function useDeferredExecutor(): DeferredExecutor {\n const isMounted = useIsMounted();\n const timeoutIdRef = useRef<NodeJS.Timer | null>(null);\n\n const cancel = useCallback(() => {\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n }\n }, []);\n\n useEffect(() => {\n return cancel;\n }, []);\n\n const execute = useCallback<DeferredExecute>((runnable, delay) => {\n if (!isMounted()) {\n return;\n }\n\n cancel();\n\n if (Number.isFinite(delay)) {\n timeoutIdRef.current = setTimeout(() => runnable(), delay);\n } else {\n runnable();\n }\n }, []);\n\n return { cancel, execute };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAeA,eAAe,SAASC,mBAAT,GAAiD;EAC5D,MAAMC,SAAS,GAAGF,YAAY,EAA9B;EACA,MAAMG,YAAY,GAAGJ,MAAM,CAAsB,IAAtB,CAA3B;EAEA,MAAMK,MAAM,GAAGP,WAAW,CAAC,MAAM;IAC7B,IAAIM,YAAY,CAACE,OAAjB,EAA0B;MACtBC,YAAY,CAACH,YAAY,CAACE,OAAd,CAAZ;IACH;EACJ,CAJyB,EAIvB,EAJuB,CAA1B;EAMAP,SAAS,CAAC,MAAM;IACZ,OAAOM,MAAP;EACH,CAFQ,EAEN,EAFM,CAAT;EAIA,MAAMG,OAAO,GAAGV,WAAW,CAAkB,CAACW,QAAD,EAAWC,KAAX,KAAqB;IAC9D,IAAI,CAACP,SAAS,EAAd,EAAkB;MACd;IACH;;IAEDE,MAAM;;IAEN,IAAIM,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAAJ,EAA4B;MACxBN,YAAY,CAACE,OAAb,GAAuBO,UAAU,CAAC,MAAMJ,QAAQ,EAAf,EAAmBC,KAAnB,CAAjC;IACH,CAFD,MAEO;MACHD,QAAQ;IACX;EACJ,CAZ0B,EAYxB,EAZwB,CAA3B;EAcA,OAAO;IAAEJ,MAAF;IAAUG;EAAV,CAAP;AACH;AAAA"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useWorkletCallback } from 'react-native-reanimated';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
3
2
|
export default function useHeight() {
|
|
4
3
|
let initialHeight = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
5
4
|
const [height, setHeight] = React.useState(initialHeight);
|
|
6
|
-
const onLayout =
|
|
5
|
+
const onLayout = useCallback(e => {
|
|
7
6
|
setHeight(e.nativeEvent.layout.height);
|
|
8
7
|
}, []);
|
|
9
8
|
return [height, onLayout];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useHeight","initialHeight","height","setHeight","useState","onLayout","e","nativeEvent","layout"],"sources":["useHeight.ts"],"sourcesContent":["import React, { useCallback } from 'react';\nimport { LayoutChangeEvent, ViewProps } from 'react-native';\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport default function useHeight(initialHeight = 0): [number, OnLayoutCallback] {\n const [height, setHeight] = React.useState<number>(initialHeight);\n\n const onLayout = useCallback((e: LayoutChangeEvent) => {\n setHeight(e.nativeEvent.layout.height);\n }, []);\n\n return [height, onLayout];\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AAKA,eAAe,SAASC,SAAT,GAAkE;EAAA,IAA/CC,aAA+C,uEAA/B,CAA+B;EAC7E,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBL,KAAK,CAACM,QAAN,CAAuBH,aAAvB,CAA5B;EAEA,MAAMI,QAAQ,GAAGN,WAAW,CAAEO,CAAD,IAA0B;IACnDH,SAAS,CAACG,CAAC,CAACC,WAAF,CAAcC,MAAd,CAAqBN,MAAtB,CAAT;EACH,CAF2B,EAEzB,EAFyB,CAA5B;EAIA,OAAO,CAACA,MAAD,EAASG,QAAT,CAAP;AACH;AAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
export default function useIsMounted() {
|
|
3
|
+
const mountedRef = useRef(false);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
mountedRef.current = true;
|
|
6
|
+
return () => {
|
|
7
|
+
mountedRef.current = false;
|
|
8
|
+
};
|
|
9
|
+
}, []);
|
|
10
|
+
return useCallback(() => mountedRef.current, []);
|
|
11
|
+
}
|
|
12
|
+
;
|
|
13
|
+
//# sourceMappingURL=useIsMounted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useIsMounted","mountedRef","current"],"sources":["useIsMounted.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\nexport interface UseIsMounted {\n (): boolean;\n}\n\nexport default function useIsMounted(): UseIsMounted {\n const mountedRef = useRef<boolean>(false);\n\n useEffect(() => {\n mountedRef.current = true;\n\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n return useCallback(() => mountedRef.current, []);\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;AAMA,eAAe,SAASC,YAAT,GAAsC;EACjD,MAAMC,UAAU,GAAGF,MAAM,CAAU,KAAV,CAAzB;EAEAD,SAAS,CAAC,MAAM;IACZG,UAAU,CAACC,OAAX,GAAqB,IAArB;IAEA,OAAO,MAAM;MACTD,UAAU,CAACC,OAAX,GAAqB,KAArB;IACH,CAFD;EAGH,CANQ,EAMN,EANM,CAAT;EAQA,OAAOL,WAAW,CAAC,MAAMI,UAAU,CAACC,OAAlB,EAA2B,EAA3B,CAAlB;AACH;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
import { useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
4
4
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
@@ -30,7 +30,7 @@ export default function useUnstableCollapsibleAppBar() {
|
|
|
30
30
|
const [appBarHeight, onAppBarLayout] = useHeight();
|
|
31
31
|
const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);
|
|
32
32
|
const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();
|
|
33
|
-
const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight);
|
|
33
|
+
const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight, [collapsibleToolbarHeight]);
|
|
34
34
|
const translateY = useSharedValue(0);
|
|
35
35
|
const lastTranslateY = useSharedValue(0);
|
|
36
36
|
const lastOffsetY = useSharedValue(0);
|
|
@@ -39,29 +39,27 @@ export default function useUnstableCollapsibleAppBar() {
|
|
|
39
39
|
const vectorY = useSharedValue(0);
|
|
40
40
|
const elevationStyle = useElevationStyle(4);
|
|
41
41
|
const animatedStyle = useAnimatedStyle(() => {
|
|
42
|
+
const transform = [{
|
|
43
|
+
translateY: translateY.value
|
|
44
|
+
}];
|
|
45
|
+
|
|
42
46
|
if (Platform.OS === 'web') {
|
|
43
47
|
return {
|
|
44
|
-
transform
|
|
45
|
-
translateY: translateY.value
|
|
46
|
-
}],
|
|
48
|
+
transform,
|
|
47
49
|
boxShadow: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.boxShadow : 0
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
if (Platform.OS === 'android') {
|
|
52
54
|
return {
|
|
53
|
-
transform
|
|
54
|
-
translateY: translateY.value
|
|
55
|
-
}],
|
|
55
|
+
transform,
|
|
56
56
|
elevation: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.elevation : 0
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (Platform.OS === 'ios') {
|
|
61
61
|
return {
|
|
62
|
-
transform
|
|
63
|
-
translateY: translateY.value
|
|
64
|
-
}],
|
|
62
|
+
transform,
|
|
65
63
|
shadowColor: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowColor,
|
|
66
64
|
shadowOffset: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowOffset,
|
|
67
65
|
shadowRadius: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowRadius,
|
|
@@ -70,11 +68,14 @@ export default function useUnstableCollapsibleAppBar() {
|
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
return {};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
}, [
|
|
72
|
+
/**
|
|
73
|
+
* FIXME: Consider add `elevationStyle` to dependencies.
|
|
74
|
+
*/
|
|
75
|
+
]);
|
|
76
|
+
const indexRef = useRef(0);
|
|
77
|
+
const offsetsRef = useRef([]);
|
|
78
|
+
const onScrollViewChanged = useCallback(nextIndex => {
|
|
78
79
|
const prevIndex = indexRef.current;
|
|
79
80
|
|
|
80
81
|
if (prevIndex === nextIndex) {
|
|
@@ -103,8 +104,7 @@ export default function useUnstableCollapsibleAppBar() {
|
|
|
103
104
|
});
|
|
104
105
|
vectorY.value = 0;
|
|
105
106
|
}
|
|
106
|
-
};
|
|
107
|
-
|
|
107
|
+
}, [appBarHeight]);
|
|
108
108
|
const scrollHandler = useAnimatedScrollHandler({
|
|
109
109
|
onBeginDrag: () => {
|
|
110
110
|
lastTranslateY.value = translateY.value;
|
|
@@ -163,7 +163,7 @@ export default function useUnstableCollapsibleAppBar() {
|
|
|
163
163
|
duration: ANIMATION_DURATION_MILLIS
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
});
|
|
166
|
+
}, [appBarHeight]);
|
|
167
167
|
const hasCollapsible = collapsibleToolbarHeight > 0;
|
|
168
168
|
const appBarStyle = [animatedStyle, {
|
|
169
169
|
paddingTop: safeAreaInsets.top
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRef","Platform","useAnimatedScrollHandler","useAnimatedStyle","useDerivedValue","useSharedValue","withTiming","useSafeAreaInsets","useAppbarStyles","useElevationStyle","useHeight","defaultOptions","shouldTranslateYReset","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useLargerValueOfLastTwoValues","value","refLatestTwoValues","current","shift","push","Math","max","useUnstableCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","appBarMaxHeight","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","translateY","lastTranslateY","lastOffsetY","prevOffsetY","overlapped","vectorY","elevationStyle","animatedStyle","transform","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","duration","savedOffsetY","scrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","deltaY","dy","min","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","floating","undefined","scrollContentInsets"],"sources":["useUnstableCollapsibleAppBar.ts"],"sourcesContent":["import React, { useRef } from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport {\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport useAppbarStyles from './useAppbarStyles';\nimport useElevationStyle from './useElevationStyle';\nimport useHeight from './useHeight';\n\ntype WebOnlyStyle = { boxShadow: any };\n\ntype ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | WebOnlyStyle | Falsy>;\n\ntype OnScroll = ScrollViewProps['onScroll'];\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport interface ContentInsets {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n}\n\nexport interface Options {\n shouldTranslateYReset?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n vectorY: SharedValue<number>;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n shouldTranslateYReset: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\n\nfunction useLargerValueOfLastTwoValues(value: number) {\n const refLatestTwoValues = useRef([0, 0]);\n\n refLatestTwoValues.current.shift();\n refLatestTwoValues.current.push(value);\n\n return Math.max(...refLatestTwoValues.current);\n}\n\n\nexport default function useUnstableCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { shouldTranslateYReset }: Required<Options> = {\n ...defaultOptions,\n ...userOptions,\n };\n\n const styles = useAppbarStyles();\n\n const safeAreaInsets = useSafeAreaInsets();\n\n const [appBarHeight, onAppBarLayout] = useHeight();\n const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight);\n\n const translateY = useSharedValue<number>(0);\n const lastTranslateY = useSharedValue<number>(0);\n const lastOffsetY = useSharedValue<number>(0);\n const prevOffsetY = useSharedValue<number>(0);\n const overlapped = useSharedValue<boolean>(false);\n const vectorY = useSharedValue<number>(0);\n\n const elevationStyle = useElevationStyle(4);\n const animatedStyle = useAnimatedStyle(() => {\n if (Platform.OS === 'web') {\n return {\n transform: [{ translateY: translateY.value }],\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n };\n }\n if (Platform.OS === 'android') {\n return {\n transform: [{ translateY: translateY.value }],\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n };\n }\n if (Platform.OS === 'ios') {\n return {\n transform: [{ translateY: translateY.value }],\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n };\n }\n return {};\n });\n\n const indexRef = React.useRef<number>(0);\n const offsetsRef = React.useRef<Array<number>>([]);\n\n const onScrollViewChanged = (nextIndex: number) => {\n const prevIndex = indexRef.current;\n if (prevIndex === nextIndex) {\n if (shouldTranslateYReset) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n offsetsRef.current = [];\n overlapped.value = false;\n }\n\n return;\n }\n\n offsetsRef.current[prevIndex] = lastOffsetY.value;\n\n const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;\n lastOffsetY.value = savedOffsetY;\n\n indexRef.current = nextIndex;\n\n // Determine whether to overlap every time index is changed.\n overlapped.value = savedOffsetY > 0;\n\n // If next ScrollView's offset is too short, expand app bar.\n if (translateY.value < 0 && savedOffsetY < appBarHeight) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n }\n };\n\n const scrollHandler = useAnimatedScrollHandler({\n onBeginDrag: () => {\n lastTranslateY.value = translateY.value;\n },\n onMomentumBegin: () => {\n lastTranslateY.value = translateY.value;\n },\n onScroll: (event) => {\n const offsetY = event.contentOffset.y;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n const deltaY = offsetY - prevOffsetY.value;\n vectorY.value = (vectorY.value * deltaY >= 0 && offsetY > 0) ? vectorY.value + deltaY : deltaY;\n prevOffsetY.value = offsetY;\n\n if (SUPPORTS_DRAG_DETECTION) {\n const dy = offsetY - lastOffsetY.value;\n\n translateY.value = offsetY <= 0 ? 0 : Math.min(Math.max(lastTranslateY.value - dy, maxTy), 0);\n\n overlapped.value = offsetY + translateY.value > 0;\n } else {\n if (offsetY > -maxTy) {\n if (ty === 0) {\n translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n }\n\n overlapped.value = offsetY > 0;\n\n lastOffsetY.value = offsetY;\n }\n },\n onEndDrag: (event) => {\n lastOffsetY.value = event.contentOffset.y;\n },\n onMomentumEnd: (event) => {\n const offsetY = event.contentOffset.y;\n\n lastOffsetY.value = offsetY;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n // If toolbar is already positioned on edge, do nothing.\n if (ty <= maxTy || ty >= 0) {\n return;\n }\n\n const threshold = maxTy * 0.5;\n\n const nextTranslateY = (ty > threshold || offsetY < appBarHeight) ? 0 : maxTy;\n\n overlapped.value = offsetY + nextTranslateY > 0;\n\n translateY.value = withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n });\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n { paddingTop: safeAreaInsets.top },\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n vectorY,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? app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AAO,GAAGjC,YAA7B,GAA6C,CAA7C,GAAiDqC,KAAxE;MAEA3B,UAAU,CAACrB,KAAX,GAAmB4C,OAAO,GAAGW,cAAV,GAA2B,CAA9C;MAEAtC,UAAU,CAACjB,KAAX,GAAmBX,UAAU,CAACkE,cAAD,EAAiB;QAC1ClB,QAAQ,EAAEzC;MADgC,CAAjB,CAA7B;IAGH;EApE0C,CAAD,CAA9C;EAuEA,MAAM4D,cAAc,GAAG1C,wBAAwB,GAAG,CAAlD;EAEA,MAAM2C,WAAW,GAAG,CAChBjC,aADgB,EAEhB;IAAEkC,UAAU,EAAEhD,cAAc,CAACiD;EAA7B,CAFgB,EAGhBH,cAAc,GAAG/C,MAAM,CAACmD,QAAV,GAAqBC,SAHnB,CAApB;EAMA,OAAO;IACHJ,WADG;IAEHnC,OAFG;IAGHV,cAHG;IAIHG,0BAJG;IAKH2B,QAAQ,EAAEH,aALP;IAMHL,mBANG;IAOH4B,mBAAmB,EAAE;MAAEH,GAAG,EAAEH,cAAc,GAAG3C,eAAH,GAAqB;IAA1C;EAPlB,CAAP;AASH;AAAA"}
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","Platform","useAnimatedScrollHandler","useAnimatedStyle","useDerivedValue","useSharedValue","withTiming","useSafeAreaInsets","useAppbarStyles","useElevationStyle","useHeight","defaultOptions","shouldTranslateYReset","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useLargerValueOfLastTwoValues","value","refLatestTwoValues","current","shift","push","Math","max","useUnstableCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","appBarMaxHeight","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","translateY","lastTranslateY","lastOffsetY","prevOffsetY","overlapped","vectorY","elevationStyle","animatedStyle","transform","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","duration","savedOffsetY","scrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","deltaY","dy","min","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","floating","undefined","scrollContentInsets"],"sources":["useUnstableCollapsibleAppBar.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport {\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport useAppbarStyles from './useAppbarStyles';\nimport useElevationStyle from './useElevationStyle';\nimport useHeight from './useHeight';\n\ntype WebOnlyStyle = { boxShadow: any };\n\ntype ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | WebOnlyStyle | Falsy>;\n\ntype OnScroll = ScrollViewProps['onScroll'];\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport interface ContentInsets {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n}\n\nexport interface Options {\n shouldTranslateYReset?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n vectorY: SharedValue<number>;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n shouldTranslateYReset: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\nfunction useLargerValueOfLastTwoValues(value: number) {\n const refLatestTwoValues = useRef([0, 0]);\n\n refLatestTwoValues.current.shift();\n refLatestTwoValues.current.push(value);\n\n return Math.max(...refLatestTwoValues.current);\n}\n\nexport default function useUnstableCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { shouldTranslateYReset }: Required<Options> = {\n ...defaultOptions,\n ...userOptions,\n };\n\n const styles = useAppbarStyles();\n\n const safeAreaInsets = useSafeAreaInsets();\n\n const [appBarHeight, onAppBarLayout] = useHeight();\n const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight, [collapsibleToolbarHeight]);\n\n const translateY = useSharedValue<number>(0);\n const lastTranslateY = useSharedValue<number>(0);\n const lastOffsetY = useSharedValue<number>(0);\n const prevOffsetY = useSharedValue<number>(0);\n const overlapped = useSharedValue<boolean>(false);\n const vectorY = useSharedValue<number>(0);\n\n const elevationStyle = useElevationStyle(4);\n const animatedStyle = useAnimatedStyle(() => {\n const transform = [{ translateY: translateY.value }];\n\n if (Platform.OS === 'web') {\n return {\n transform,\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n };\n }\n if (Platform.OS === 'android') {\n return {\n transform,\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n };\n }\n if (Platform.OS === 'ios') {\n return {\n transform,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n };\n }\n return {};\n }, [\n /**\n * FIXME: Consider add `elevationStyle` to dependencies.\n */\n ]);\n\n const indexRef = useRef<number>(0);\n const offsetsRef = useRef<Array<number>>([]);\n\n const onScrollViewChanged = useCallback((nextIndex: number) => {\n const prevIndex = indexRef.current;\n if (prevIndex === nextIndex) {\n if (shouldTranslateYReset) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n offsetsRef.current = [];\n overlapped.value = false;\n }\n\n return;\n }\n\n offsetsRef.current[prevIndex] = lastOffsetY.value;\n\n const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;\n lastOffsetY.value = savedOffsetY;\n\n indexRef.current = nextIndex;\n\n // Determine whether to overlap every time index is changed.\n overlapped.value = savedOffsetY > 0;\n\n // If next ScrollView's offset is too short, expand app bar.\n if (translateY.value < 0 && savedOffsetY < appBarHeight) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n }\n }, [appBarHeight]);\n\n const scrollHandler = useAnimatedScrollHandler({\n onBeginDrag: () => {\n lastTranslateY.value = translateY.value;\n },\n onMomentumBegin: () => {\n lastTranslateY.value = translateY.value;\n },\n onScroll: (event) => {\n const offsetY = event.contentOffset.y;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n const deltaY = offsetY - prevOffsetY.value;\n vectorY.value = (vectorY.value * deltaY >= 0 && offsetY > 0) ? vectorY.value + deltaY : deltaY;\n prevOffsetY.value = offsetY;\n\n if (SUPPORTS_DRAG_DETECTION) {\n const dy = offsetY - lastOffsetY.value;\n\n translateY.value = offsetY <= 0 ? 0 : Math.min(Math.max(lastTranslateY.value - dy, maxTy), 0);\n\n overlapped.value = offsetY + translateY.value > 0;\n } else {\n if (offsetY > -maxTy) {\n if (ty === 0) {\n translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n }\n\n overlapped.value = offsetY > 0;\n\n lastOffsetY.value = offsetY;\n }\n },\n onEndDrag: (event) => {\n lastOffsetY.value = event.contentOffset.y;\n },\n onMomentumEnd: (event) => {\n const offsetY = event.contentOffset.y;\n\n lastOffsetY.value = offsetY;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n // If toolbar is already positioned on edge, do nothing.\n if (ty <= maxTy || ty >= 0) {\n return;\n }\n\n const threshold = maxTy * 0.5;\n\n const nextTranslateY = (ty > threshold || offsetY < appBarHeight) ? 0 : maxTy;\n\n overlapped.value = offsetY + nextTranslateY > 0;\n\n translateY.value = withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n }, [appBarHeight]);\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n { paddingTop: safeAreaInsets.top },\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n vectorY,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarMaxHeight : 0 },\n };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,OAApC;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AAEA,SACIC,wBADJ,EAEIC,gBAFJ,EAGIC,eAHJ,EAIIC,cAJJ,EAKIC,UALJ,QAMO,yBANP;AAOA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,SAAP,MAAsB,aAAtB;AA+BA,MAAMC,cAAiC,GAAG;EACtCC,qBAAqB,EAAE;AADe,CAA1C;AAIA,MAAMC,yBAAyB,GAAG,GAAlC;AAEA,MAAMC,uBAAuB,GAAGb,QAAQ,CAACc,EAAT,KAAgB,KAAhD;;AAEA,SAASC,6BAAT,CAAuCC,KAAvC,EAAsD;EAClD,MAAMC,kBAAkB,GAAGlB,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,CAAjC;EAEAkB,kBAAkB,CAACC,OAAnB,CAA2BC,KAA3B;EACAF,kBAAkB,CAACC,OAAnB,CAA2BE,IAA3B,CAAgCJ,KAAhC;EAEA,OAAOK,IAAI,CAACC,GAAL,CAAS,GAAGL,kBAAkB,CAACC,OAA/B,CAAP;AACH;;AAED,eAAe,SAASK,4BAAT,GAAgG;EAAA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,KAAK,CAACE,aAAN,CAAoBC,CAApC;MAEA3B,WAAW,CAACnB,KAAZ,GAAoB4C,OAApB;MAEA,MAAMG,EAAE,GAAG9B,UAAU,CAACjB,KAAtB;MACA,MAAMgD,KAAK,GAAGhC,aAAa,CAAChB,KAA5B,CANsB,CAQtB;;MACA,IAAI+C,EAAE,IAAIC,KAAN,IAAeD,EAAE,IAAI,CAAzB,EAA4B;QACxB;MACH;;MAED,MAAMO,SAAS,GAAGN,KAAK,GAAG,GAA1B;MAEA,MAAMO,cAAc,GAAIR,EAAE,GAAGO,SAAL,IAAkBV,OAAO,GAAGjC,YAA7B,GAA6C,CAA7C,GAAiDqC,KAAxE;MAEA3B,UAAU,CAACrB,KAAX,GAAmB4C,OAAO,GAAGW,cAAV,GAA2B,CAA9C;MAEAtC,UAAU,CAACjB,KAAX,GAAmBX,UAAU,CAACkE,cAAD,EAAiB;QAC1ClB,QAAQ,EAAEzC;MADgC,CAAjB,CAA7B;IAGH;EApE0C,CAAD,EAqE3C,CAACe,YAAD,CArE2C,CAA9C;EAuEA,MAAM6C,cAAc,GAAG1C,wBAAwB,GAAG,CAAlD;EAEA,MAAM2C,WAAW,GAAG,CAChBjC,aADgB,EAEhB;IAAEkC,UAAU,EAAEhD,cAAc,CAACiD;EAA7B,CAFgB,EAGhBH,cAAc,GAAG/C,MAAM,CAACmD,QAAV,GAAqBC,SAHnB,CAApB;EAMA,OAAO;IACHJ,WADG;IAEHnC,OAFG;IAGHV,cAHG;IAIHG,0BAJG;IAKH2B,QAAQ,EAAEH,aALP;IAMHL,mBANG;IAOH4B,mBAAmB,EAAE;MAAEH,GAAG,EAAEH,cAAc,GAAG3C,eAAH,GAAqB;IAA1C;EAPlB,CAAP;AASH;AAAA"}
|
|
@@ -9,10 +9,10 @@ export default function useAnimatedDisplayStyle(vectorY) {
|
|
|
9
9
|
} else if (vy < threshold) {
|
|
10
10
|
display.value = 'flex';
|
|
11
11
|
}
|
|
12
|
-
});
|
|
12
|
+
}, [threshold]);
|
|
13
13
|
return useAnimatedStyle(() => ({
|
|
14
14
|
display: display.value
|
|
15
|
-
}));
|
|
15
|
+
}), []);
|
|
16
16
|
}
|
|
17
17
|
;
|
|
18
18
|
//# sourceMappingURL=useUnstableToggleDisplayStyle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedReaction","useAnimatedStyle","useSharedValue","useAnimatedDisplayStyle","vectorY","threshold","defaultDisplay","display","value","vy"],"sources":["useUnstableToggleDisplayStyle.ts"],"sourcesContent":["import type { SharedValue } from 'react-native-reanimated';\nimport { useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';\n\nexport default function useAnimatedDisplayStyle(\n vectorY: SharedValue<number>,\n threshold: number = 200,\n defaultDisplay: 'flex' | 'none' = 'flex',\n) {\n const display = useSharedValue(defaultDisplay);\n\n useAnimatedReaction(\n () => vectorY.value,\n (vy) => {\n if (vy >= threshold) {\n display.value = 'none';\n } else if (vy < threshold) {\n display.value = 'flex';\n }\n },\n );\n\n return useAnimatedStyle(() => ({\n display: display.value,\n }));\n};\n"],"mappings":"AACA,SAASA,mBAAT,EAA8BC,gBAA9B,EAAgDC,cAAhD,QAAsE,yBAAtE;AAEA,eAAe,SAASC,uBAAT,CACXC,OADW,EAIb;EAAA,IAFEC,SAEF,uEAFsB,GAEtB;EAAA,IADEC,cACF,uEADoC,MACpC;EACE,MAAMC,OAAO,GAAGL,cAAc,CAACI,cAAD,CAA9B;EAEAN,mBAAmB,CACf,MAAMI,OAAO,CAACI,KADC,EAEdC,EAAD,IAAQ;IACJ,IAAIA,EAAE,IAAIJ,SAAV,EAAqB;MACjBE,OAAO,CAACC,KAAR,GAAgB,MAAhB;IACH,CAFD,MAEO,IAAIC,EAAE,GAAGJ,SAAT,EAAoB;MACvBE,OAAO,CAACC,KAAR,GAAgB,MAAhB;IACH;EACJ,CARc,CAAnB;
|
|
1
|
+
{"version":3,"names":["useAnimatedReaction","useAnimatedStyle","useSharedValue","useAnimatedDisplayStyle","vectorY","threshold","defaultDisplay","display","value","vy"],"sources":["useUnstableToggleDisplayStyle.ts"],"sourcesContent":["import type { SharedValue } from 'react-native-reanimated';\nimport { useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';\n\nexport default function useAnimatedDisplayStyle(\n vectorY: SharedValue<number>,\n threshold: number = 200,\n defaultDisplay: 'flex' | 'none' = 'flex',\n) {\n const display = useSharedValue(defaultDisplay);\n\n useAnimatedReaction(\n () => vectorY.value,\n (vy) => {\n if (vy >= threshold) {\n display.value = 'none';\n } else if (vy < threshold) {\n display.value = 'flex';\n }\n },\n [threshold],\n );\n\n return useAnimatedStyle(() => ({\n display: display.value,\n }), []);\n};\n"],"mappings":"AACA,SAASA,mBAAT,EAA8BC,gBAA9B,EAAgDC,cAAhD,QAAsE,yBAAtE;AAEA,eAAe,SAASC,uBAAT,CACXC,OADW,EAIb;EAAA,IAFEC,SAEF,uEAFsB,GAEtB;EAAA,IADEC,cACF,uEADoC,MACpC;EACE,MAAMC,OAAO,GAAGL,cAAc,CAACI,cAAD,CAA9B;EAEAN,mBAAmB,CACf,MAAMI,OAAO,CAACI,KADC,EAEdC,EAAD,IAAQ;IACJ,IAAIA,EAAE,IAAIJ,SAAV,EAAqB;MACjBE,OAAO,CAACC,KAAR,GAAgB,MAAhB;IACH,CAFD,MAEO,IAAIC,EAAE,GAAGJ,SAAT,EAAoB;MACvBE,OAAO,CAACC,KAAR,GAAgB,MAAhB;IACH;EACJ,CARc,EASf,CAACH,SAAD,CATe,CAAnB;EAYA,OAAOJ,gBAAgB,CAAC,OAAO;IAC3BM,OAAO,EAAEA,OAAO,CAACC;EADU,CAAP,CAAD,EAEnB,EAFmB,CAAvB;AAGH;AAAA"}
|
package/build/module/index.js
CHANGED
|
@@ -12,5 +12,7 @@ export { default as ComicViewer } from './ComicViewer';
|
|
|
12
12
|
export * from './ComicViewer';
|
|
13
13
|
export { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';
|
|
14
14
|
export * from './StatusBarProvider';
|
|
15
|
+
export { default as ViewabilityTrackerView } from './ViewabilityTrackerView';
|
|
16
|
+
export * from './ViewabilityTrackerView';
|
|
15
17
|
export * from './hooks';
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","BottomSheet","Carousel","DateTimePicker","FlipCard","ViewPager","ComicViewer","StatusBarProvider","useStatusBarContext"],"sources":["index.ts"],"sourcesContent":["export { default as BottomSheet } from './BottomSheet';\nexport * from './BottomSheet';\n\nexport { default as Carousel } from './Carousel';\nexport * from './Carousel';\n\nexport { default as DateTimePicker } from './DateTimePicker';\nexport * from './DateTimePicker';\n\nexport { default as FlipCard } from './FlipCard';\nexport * from './FlipCard';\n\nexport { default as ViewPager } from './ViewPager';\nexport * from './ViewPager';\n\nexport { default as ComicViewer } from './ComicViewer';\nexport * from './ComicViewer';\n\nexport { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';\nexport * from './StatusBarProvider';\n\nexport * from './hooks';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASF,OAAO,IAAIG,cAApB,QAA0C,kBAA1C;AACA,cAAc,kBAAd;AAEA,SAASH,OAAO,IAAII,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASJ,OAAO,IAAIK,SAApB,QAAqC,aAArC;AACA,cAAc,aAAd;AAEA,SAASL,OAAO,IAAIM,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASN,OAAO,IAAIO,iBAApB,EAAuCC,mBAAvC,QAAkE,qBAAlE;AACA,cAAc,qBAAd;AAEA,cAAc,SAAd"}
|
|
1
|
+
{"version":3,"names":["default","BottomSheet","Carousel","DateTimePicker","FlipCard","ViewPager","ComicViewer","StatusBarProvider","useStatusBarContext","ViewabilityTrackerView"],"sources":["index.ts"],"sourcesContent":["export { default as BottomSheet } from './BottomSheet';\nexport * from './BottomSheet';\n\nexport { default as Carousel } from './Carousel';\nexport * from './Carousel';\n\nexport { default as DateTimePicker } from './DateTimePicker';\nexport * from './DateTimePicker';\n\nexport { default as FlipCard } from './FlipCard';\nexport * from './FlipCard';\n\nexport { default as ViewPager } from './ViewPager';\nexport * from './ViewPager';\n\nexport { default as ComicViewer } from './ComicViewer';\nexport * from './ComicViewer';\n\nexport { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';\nexport * from './StatusBarProvider';\n\nexport { default as ViewabilityTrackerView } from './ViewabilityTrackerView';\nexport * from './ViewabilityTrackerView';\n\nexport * from './hooks';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASF,OAAO,IAAIG,cAApB,QAA0C,kBAA1C;AACA,cAAc,kBAAd;AAEA,SAASH,OAAO,IAAII,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASJ,OAAO,IAAIK,SAApB,QAAqC,aAArC;AACA,cAAc,aAAd;AAEA,SAASL,OAAO,IAAIM,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASN,OAAO,IAAIO,iBAApB,EAAuCC,mBAAvC,QAAkE,qBAAlE;AACA,cAAc,qBAAd;AAEA,SAASR,OAAO,IAAIS,sBAApB,QAAkD,0BAAlD;AACA,cAAc,0BAAd;AAEA,cAAc,SAAd"}
|
|
@@ -10,10 +10,29 @@ export default interface BottomSheetProps extends ComponentProps<{
|
|
|
10
10
|
* BottomSheet children, usually the included sub-components.
|
|
11
11
|
*/
|
|
12
12
|
children?: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Enable dynamic sizing for content size.
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
enableDynamicSizing?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Area to be fixed on the top of the bottom sheet.
|
|
20
|
+
*/
|
|
21
|
+
header?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Top element for displaying additional information on the bottom sheet.
|
|
24
|
+
*/
|
|
25
|
+
topElement?: React.ReactNode;
|
|
13
26
|
/**
|
|
14
27
|
* Snap index. You could also provide -1 to bottom sheet in closed state.
|
|
15
28
|
*/
|
|
16
29
|
index: number;
|
|
30
|
+
/**
|
|
31
|
+
* Maximum height(normalized value) of dialog
|
|
32
|
+
* ex. 30% => 0.3 / 90% => 0.9
|
|
33
|
+
* @default 0.9
|
|
34
|
+
*/
|
|
35
|
+
maxHeightNormalizedRatio?: number;
|
|
17
36
|
/**
|
|
18
37
|
* Callback fired when the index is changed.
|
|
19
38
|
* Important! Use memoized value.
|
|
@@ -22,7 +41,19 @@ export default interface BottomSheetProps extends ComponentProps<{
|
|
|
22
41
|
/**
|
|
23
42
|
* Points for the bottom sheet to snap to, points should be sorted from bottom to top.
|
|
24
43
|
* Important! Use memoized value.
|
|
44
|
+
* Only number type or string type(~% format) can be used.
|
|
45
|
+
* @default []
|
|
46
|
+
*/
|
|
47
|
+
snapPoints?: Array<number | string>;
|
|
48
|
+
/**
|
|
49
|
+
* Disable default backgroundColor.
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
disableDefaultBackgroundColor?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Disable default shadow.
|
|
55
|
+
* @default false
|
|
25
56
|
*/
|
|
26
|
-
|
|
57
|
+
disableDefaultShadow?: boolean;
|
|
27
58
|
}> {
|
|
28
59
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface UseDynamicSnapPointsParams {
|
|
2
|
+
enableDynamicSizing: boolean;
|
|
3
|
+
maxHeightNormalizedRatio: number;
|
|
4
|
+
snapPoints: (number | string)[];
|
|
5
|
+
}
|
|
6
|
+
interface UseDynamicSnapPointsReturns {
|
|
7
|
+
convertedSnapPoints: number[];
|
|
8
|
+
handleContentSizeChange: (w: number, h: number) => void;
|
|
9
|
+
highestSnapPoint: number;
|
|
10
|
+
}
|
|
11
|
+
export default function useDynamicSnapPoints(params: UseDynamicSnapPointsParams): UseDynamicSnapPointsReturns;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type CarouselProps from './CarouselProps';
|
|
3
|
+
import type { CarouselInstance } from './types';
|
|
4
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<CarouselProps<any>, "style" | "data" | "scrollEnabled" | "autoplay" | "autoplayInterval" | "createItemStyle" | "createScrollAnimation" | "disableSmartAutoplay" | "initialIndex" | "itemHeight" | "itemWidth" | "loop" | "onIndexChange" | "renderItem" | "windowSize"> & React.RefAttributes<CarouselInstance>>>;
|
|
5
|
+
export default _default;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ListRenderItemInfo } from 'react-native';
|
|
1
|
+
import type { RefObject } from 'react';
|
|
3
2
|
import type { ComponentProps } from '@fountain-ui/core';
|
|
3
|
+
import type { CarouselInstance, CreateItemStyle, CreateScrollAnimation, ItemHeight, OnIndexChange, RenderItem } from './types';
|
|
4
4
|
export default interface CarouselProps<ItemT = any> extends ComponentProps<{
|
|
5
|
+
ref?: RefObject<CarouselInstance>;
|
|
5
6
|
/**
|
|
6
7
|
* If `true`, enable autoplay.
|
|
7
8
|
* @default false
|
|
@@ -13,78 +14,62 @@ export default interface CarouselProps<ItemT = any> extends ComponentProps<{
|
|
|
13
14
|
*/
|
|
14
15
|
autoplayInterval?: number;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* The item style creator function.
|
|
18
|
+
* @default createDefaultItemStyle
|
|
17
19
|
*/
|
|
18
|
-
|
|
20
|
+
createItemStyle?: CreateItemStyle;
|
|
19
21
|
/**
|
|
20
|
-
*
|
|
22
|
+
* The scroll animation creator function.
|
|
23
|
+
* @default createDefaultScrollAnimation
|
|
24
|
+
*/
|
|
25
|
+
createScrollAnimation?: CreateScrollAnimation;
|
|
26
|
+
/**
|
|
27
|
+
* Data for render items.
|
|
21
28
|
*/
|
|
22
29
|
data: ReadonlyArray<ItemT>;
|
|
23
30
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @default
|
|
31
|
+
* If `true`, carousel will detect its own viewability and control autoplay automatically.
|
|
32
|
+
* @default false
|
|
26
33
|
*/
|
|
27
|
-
|
|
34
|
+
disableSmartAutoplay?: boolean;
|
|
28
35
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @default 0
|
|
36
|
+
* Index of initial item that should be selected.
|
|
37
|
+
* @default 0
|
|
31
38
|
*/
|
|
32
|
-
|
|
39
|
+
initialIndex?: number;
|
|
33
40
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
41
|
+
* The item height.
|
|
42
|
+
* For a performance reason, always consider to provide a number value.
|
|
36
43
|
*/
|
|
37
|
-
|
|
44
|
+
itemHeight: ItemHeight;
|
|
38
45
|
/**
|
|
39
|
-
*
|
|
46
|
+
* The item width.
|
|
40
47
|
*/
|
|
41
|
-
|
|
48
|
+
itemWidth: number;
|
|
42
49
|
/**
|
|
43
50
|
* Enable infinite loop mode.
|
|
44
51
|
* @default false
|
|
45
52
|
*/
|
|
46
|
-
|
|
53
|
+
loop?: boolean;
|
|
47
54
|
/**
|
|
48
55
|
* Callback fired when an index is changed.
|
|
49
56
|
*/
|
|
50
|
-
|
|
57
|
+
onIndexChange?: OnIndexChange;
|
|
51
58
|
/**
|
|
52
59
|
* Takes an item from data and renders it into the list.
|
|
53
60
|
*/
|
|
54
|
-
renderItem:
|
|
55
|
-
/**
|
|
56
|
-
* Web only. Number of slides to scroll at once.
|
|
57
|
-
* @default 1
|
|
58
|
-
*/
|
|
59
|
-
slidesToScroll?: number;
|
|
60
|
-
/**
|
|
61
|
-
* Web only. Number of slides to display.
|
|
62
|
-
* @default 1
|
|
63
|
-
*/
|
|
64
|
-
slidesToShow?: number;
|
|
61
|
+
renderItem: RenderItem<ItemT>;
|
|
65
62
|
/**
|
|
66
|
-
*
|
|
63
|
+
* Whether to enable scroll gesture.
|
|
67
64
|
* @default true
|
|
68
65
|
*/
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Web only. Enable arrows to display.
|
|
72
|
-
* @default true
|
|
73
|
-
*/
|
|
74
|
-
arrows?: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Web only. Style of arrows
|
|
77
|
-
* @default true
|
|
78
|
-
*/
|
|
79
|
-
arrowsStyle?: object;
|
|
80
|
-
/**
|
|
81
|
-
* Web only. Style of track
|
|
82
|
-
* @default object
|
|
83
|
-
*/
|
|
84
|
-
trackStyle?: object;
|
|
66
|
+
scrollEnabled?: boolean;
|
|
85
67
|
/**
|
|
86
|
-
*
|
|
68
|
+
* The maximum number of items that can respond to pan gesture events.
|
|
69
|
+
* Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)
|
|
70
|
+
* 0 means all items will respond to pan gesture events.
|
|
71
|
+
* @default 5
|
|
87
72
|
*/
|
|
88
|
-
|
|
73
|
+
windowSize?: number;
|
|
89
74
|
}> {
|
|
90
75
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const itemInterpolationInputRange: number[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as createDefaultItemStyle } from './createDefaultItemStyle';
|
|
2
|
+
export { default as createDefaultScrollAnimation } from './createDefaultScrollAnimation';
|
|
3
|
+
export { default as normalItemStyleFactory } from './normalItemStyleFactory';
|
|
4
|
+
export { default as parallaxItemStyleFactory } from './parallaxItemStyleFactory';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CreateItemStyle } from '../types';
|
|
2
|
+
export interface ParallaxAnimationConfig {
|
|
3
|
+
activeItemScale?: number;
|
|
4
|
+
activeItemOpacity?: number;
|
|
5
|
+
adjacentItemScale?: number;
|
|
6
|
+
adjacentItemOpacity?: number;
|
|
7
|
+
scrollingOffset?: number;
|
|
8
|
+
}
|
|
9
|
+
export default function parallaxItemStyleFactory(config?: ParallaxAnimationConfig): CreateItemStyle;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import type { CreateItemStyle, ItemHeight, ItemVisibilityStore } from '../types';
|
|
4
|
+
export interface InternalContextValue<ItemT> {
|
|
5
|
+
createItemStyle: CreateItemStyle;
|
|
6
|
+
data: ReadonlyArray<ItemT>;
|
|
7
|
+
globalInterpolation: Animated.AnimatedInterpolation;
|
|
8
|
+
itemHeight: ItemHeight;
|
|
9
|
+
itemWidth: number;
|
|
10
|
+
itemVisibilityStore: ItemVisibilityStore;
|
|
11
|
+
loop: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const InternalContext: import("react").Context<InternalContextValue<any>>;
|
|
14
|
+
export default InternalContext;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
4
|
+
export interface ItemViewProps {
|
|
5
|
+
children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;
|
|
6
|
+
index: number;
|
|
7
|
+
onLayout?: ViewProps['onLayout'];
|
|
8
|
+
}
|
|
9
|
+
export default function ItemView(props: ItemViewProps): JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { View, ViewProps } from 'react-native';
|
|
3
|
+
import type { ItemHeight, RenderItem } from '../types';
|
|
4
|
+
export declare type RootViewProps<ItemT> = ViewProps & {
|
|
5
|
+
data: ReadonlyArray<ItemT>;
|
|
6
|
+
itemHeight: ItemHeight;
|
|
7
|
+
originalData: ReadonlyArray<ItemT>;
|
|
8
|
+
renderItem: RenderItem<ItemT>;
|
|
9
|
+
};
|
|
10
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<ViewProps & {
|
|
11
|
+
data: readonly any[];
|
|
12
|
+
itemHeight: ItemHeight;
|
|
13
|
+
originalData: readonly any[];
|
|
14
|
+
renderItem: RenderItem<any>;
|
|
15
|
+
} & React.RefAttributes<View>>>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import type { AutoplayController, StartPagingAnimation } from '../types';
|
|
4
|
+
export interface ScrollViewGestureProps {
|
|
5
|
+
autoplayController: AutoplayController;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
gestureTranslationX: Animated.Value;
|
|
8
|
+
interruptAnimation: () => void;
|
|
9
|
+
scrollEnabled: boolean;
|
|
10
|
+
startPagingAnimation: StartPagingAnimation;
|
|
11
|
+
}
|
|
12
|
+
export default function ScrollViewGesture(props: ScrollViewGestureProps): JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as useAutoplayController } from './useAutoplayController';
|
|
2
|
+
export { default as useIndexController } from './useIndexController';
|
|
3
|
+
export { default as useLoopedData } from './useLoopedData';
|
|
4
|
+
export { default as usePagingAnimator } from './usePagingAnimator';
|
|
5
|
+
export { default as useItemVisibilityStore } from './useItemVisibilityStore';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AutoplayController, StartPagingAnimation } from '../types';
|
|
2
|
+
export interface AutoplayConfig {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
intervalMillis: number;
|
|
5
|
+
startPagingAnimation: StartPagingAnimation;
|
|
6
|
+
}
|
|
7
|
+
export default function useAutoplayController(config: AutoplayConfig): AutoplayController;
|