@fountain-ui/lab 2.0.0-beta.1 → 2.0.0-beta.12
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/BottomSheetNative.js +1 -1
- package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetWeb.js +2 -6
- 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/Carousel/Carousel.js +137 -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 +64 -0
- package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
- package/build/commonjs/Carousel/components/RootView.js +68 -0
- package/build/commonjs/Carousel/components/RootView.js.map +1 -0
- package/build/commonjs/Carousel/components/ScrollViewGesture.js +76 -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/hooks/index.js +64 -0
- package/build/commonjs/Carousel/hooks/index.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useAutoplayController.js +55 -0
- package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useDimensionChangeReaction.js +23 -0
- package/build/commonjs/Carousel/hooks/useDimensionChangeReaction.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useIndexController.js +70 -0
- package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useItemInterpolation.js +63 -0
- package/build/commonjs/Carousel/hooks/useItemInterpolation.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/usePagingAnimation.js +124 -0
- package/build/commonjs/Carousel/hooks/usePagingAnimation.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/types.js +7 -0
- package/build/commonjs/Carousel/types.js.map +1 -0
- package/build/commonjs/ComicViewer/ComicViewer.js +16 -11
- package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
- package/build/commonjs/ComicViewer/ComicViewerItemProps.js.map +1 -1
- package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
- package/build/commonjs/ComicViewer/ViewerItem.js +4 -3
- 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/ChildrenMemoizedPage.js +86 -21
- package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +1 -1
- package/build/commonjs/ViewPager/PageStateContext.js +22 -0
- package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
- package/build/commonjs/ViewPager/ViewPagerNative.js +61 -38
- package/build/commonjs/ViewPager/ViewPagerNative.js.map +1 -1
- package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
- package/build/commonjs/ViewPager/ViewPagerWeb.js +35 -26
- package/build/commonjs/ViewPager/ViewPagerWeb.js.map +1 -1
- package/build/commonjs/ViewPager/index.js +8 -0
- package/build/commonjs/ViewPager/index.js.map +1 -1
- package/build/commonjs/ViewPager/index.native.js +8 -0
- package/build/commonjs/ViewPager/index.native.js.map +1 -1
- package/build/commonjs/ViewPager/utils.js +5 -39
- 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 +56 -57
- 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/BottomSheetNative.js +1 -1
- package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetWeb.js +2 -6
- 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/Carousel/Carousel.js +115 -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 +44 -0
- package/build/module/Carousel/components/ItemView.js.map +1 -0
- package/build/module/Carousel/components/RootView.js +47 -0
- package/build/module/Carousel/components/RootView.js.map +1 -0
- package/build/module/Carousel/components/ScrollViewGesture.js +62 -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/hooks/index.js +8 -0
- package/build/module/Carousel/hooks/index.js.map +1 -0
- package/build/module/Carousel/hooks/useAutoplayController.js +45 -0
- package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
- package/build/module/Carousel/hooks/useDimensionChangeReaction.js +14 -0
- package/build/module/Carousel/hooks/useDimensionChangeReaction.js.map +1 -0
- package/build/module/Carousel/hooks/useIndexController.js +54 -0
- package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
- package/build/module/Carousel/hooks/useItemInterpolation.js +51 -0
- package/build/module/Carousel/hooks/useItemInterpolation.js.map +1 -0
- package/build/module/Carousel/hooks/useItemVisibilityStore.js +87 -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/usePagingAnimation.js +115 -0
- package/build/module/Carousel/hooks/usePagingAnimation.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/types.js +3 -0
- package/build/module/Carousel/types.js.map +1 -0
- package/build/module/ComicViewer/ComicViewer.js +16 -11
- package/build/module/ComicViewer/ComicViewer.js.map +1 -1
- package/build/module/ComicViewer/ComicViewerItemProps.js.map +1 -1
- package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
- package/build/module/ComicViewer/ViewerItem.js +4 -3
- 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/ChildrenMemoizedPage.js +80 -23
- package/build/module/ViewPager/ChildrenMemoizedPage.js.map +1 -1
- package/build/module/ViewPager/PageStateContext.js +10 -0
- package/build/module/ViewPager/PageStateContext.js.map +1 -0
- package/build/module/ViewPager/ViewPagerNative.js +57 -33
- package/build/module/ViewPager/ViewPagerNative.js.map +1 -1
- package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
- package/build/module/ViewPager/ViewPagerWeb.js +29 -24
- package/build/module/ViewPager/ViewPagerWeb.js.map +1 -1
- package/build/module/ViewPager/index.js +1 -0
- package/build/module/ViewPager/index.js.map +1 -1
- package/build/module/ViewPager/index.native.js +1 -0
- package/build/module/ViewPager/index.native.js.map +1 -1
- package/build/module/ViewPager/utils.js +2 -31
- 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 -43
- 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/BottomSheetNative.d.ts +0 -1
- package/build/typescript/BottomSheet/BottomSheetWeb.d.ts +0 -1
- package/build/typescript/BottomSheet/TransparentBackdrop.d.ts +0 -1
- package/build/typescript/Carousel/Carousel.d.ts +5 -0
- package/build/typescript/Carousel/CarouselProps.d.ts +32 -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 +7 -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/hooks/index.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useDimensionChangeReaction.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
- package/build/typescript/Carousel/hooks/useItemInterpolation.d.ts +2 -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/usePagingAnimation.d.ts +18 -0
- package/build/typescript/Carousel/index.d.ts +3 -1
- package/build/typescript/Carousel/types.d.ts +57 -0
- package/build/typescript/ComicViewer/ComicViewer.d.ts +0 -1
- 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/ChildrenMemoizedPage.d.ts +2 -1
- package/build/typescript/ViewPager/PageStateContext.d.ts +7 -0
- package/build/typescript/ViewPager/ViewPagerNative.d.ts +4 -2
- package/build/typescript/ViewPager/ViewPagerProps.d.ts +31 -19
- package/build/typescript/ViewPager/ViewPagerWeb.d.ts +4 -2
- package/build/typescript/ViewPager/index.d.ts +2 -1
- package/build/typescript/ViewPager/index.native.d.ts +1 -0
- package/build/typescript/ViewPager/utils.d.ts +3 -19
- 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 +12 -27
- package/src/AnimatedY/AnimatedY.tsx +13 -10
- package/src/Carousel/Carousel.tsx +151 -0
- package/src/Carousel/CarouselProps.ts +34 -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 +56 -0
- package/src/Carousel/components/RootView.tsx +66 -0
- package/src/Carousel/components/ScrollViewGesture.tsx +80 -0
- package/src/Carousel/components/index.ts +4 -0
- package/src/Carousel/hooks/index.ts +7 -0
- package/src/Carousel/hooks/useAutoplayController.ts +54 -0
- package/src/Carousel/hooks/useDimensionChangeReaction.ts +25 -0
- package/src/Carousel/hooks/useIndexController.tsx +76 -0
- package/src/Carousel/hooks/useItemInterpolation.ts +107 -0
- package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
- package/src/Carousel/hooks/useLoopedData.ts +26 -0
- package/src/Carousel/hooks/usePagingAnimation.ts +148 -0
- package/src/Carousel/index.ts +4 -2
- package/src/Carousel/types.ts +67 -0
- package/src/DateTimePicker/DateTimePicker.tsx +2 -2
- package/src/FlipCard/FlipCard.tsx +8 -8
- package/src/ViewPager/ChildrenMemoizedPage.tsx +97 -23
- package/src/ViewPager/PageStateContext.ts +15 -0
- package/src/ViewPager/ViewPagerNative.tsx +72 -36
- package/src/ViewPager/ViewPagerProps.ts +33 -19
- package/src/ViewPager/ViewPagerWeb.tsx +38 -29
- package/src/ViewPager/index.native.ts +1 -0
- package/src/ViewPager/index.ts +2 -1
- package/src/ViewPager/utils.tsx +4 -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 +56 -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 +59 -42
- 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/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/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/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/hooks/useWidth.ts +0 -17
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { default } from './
|
|
1
|
+
export { default } from './Carousel';
|
|
2
2
|
export type { default as CarouselProps } from './CarouselProps';
|
|
3
|
+
export type { CarouselInstance } from './types';
|
|
4
|
+
export { normalItemStyleFactory, parallaxItemStyleFactory } from './animation';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { Animated, ViewProps } from 'react-native';
|
|
3
|
+
declare const directions: readonly ["next", "prev", "stay"];
|
|
4
|
+
export declare type PagingDirection = (typeof directions)[number];
|
|
5
|
+
export interface RenderItem<T> {
|
|
6
|
+
(info: {
|
|
7
|
+
item: T;
|
|
8
|
+
index: number;
|
|
9
|
+
interpolation: Animated.AnimatedInterpolation;
|
|
10
|
+
}): ReactElement | null;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateScrollAnimation {
|
|
13
|
+
(aValue: Animated.AnimatedValue, toValue: number): Animated.CompositeAnimation;
|
|
14
|
+
}
|
|
15
|
+
export interface CreateItemStyle {
|
|
16
|
+
(itemInterpolation: Animated.AnimatedInterpolation, itemWidth: number): Animated.AnimatedProps<ViewProps['style']>;
|
|
17
|
+
}
|
|
18
|
+
export interface GetCurrentIndex {
|
|
19
|
+
(): number;
|
|
20
|
+
}
|
|
21
|
+
export interface IndexController {
|
|
22
|
+
currentIndex: number;
|
|
23
|
+
getCurrentIndex: GetCurrentIndex;
|
|
24
|
+
lastIndex: number;
|
|
25
|
+
monitorElement: ReactElement;
|
|
26
|
+
}
|
|
27
|
+
export interface StartPagingAnimation {
|
|
28
|
+
(direction: PagingDirection, isGesture?: boolean): void;
|
|
29
|
+
}
|
|
30
|
+
export declare type VisibleIndexRanges = Array<[number, number]>;
|
|
31
|
+
export interface StoreSubscription {
|
|
32
|
+
(): void;
|
|
33
|
+
}
|
|
34
|
+
export interface ItemVisibilityStore {
|
|
35
|
+
dispatch: (ranges: VisibleIndexRanges) => void;
|
|
36
|
+
subscribe: (listener: (ranges: VisibleIndexRanges) => void) => StoreSubscription;
|
|
37
|
+
removeAllListeners: () => void;
|
|
38
|
+
}
|
|
39
|
+
export interface AutoplayController {
|
|
40
|
+
pause: () => void;
|
|
41
|
+
resume: () => void;
|
|
42
|
+
}
|
|
43
|
+
export interface CarouselInstance {
|
|
44
|
+
/**
|
|
45
|
+
* Scroll to next visible item.
|
|
46
|
+
*/
|
|
47
|
+
next: () => void;
|
|
48
|
+
/**
|
|
49
|
+
* Scroll to previous visible item.
|
|
50
|
+
*/
|
|
51
|
+
prev: () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Get current visible item index.
|
|
54
|
+
*/
|
|
55
|
+
getCurrentIndex: GetCurrentIndex;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PageProps } from './ViewPagerProps';
|
|
3
|
-
declare
|
|
3
|
+
declare function Page(props: PageProps): JSX.Element;
|
|
4
|
+
declare const _default: React.MemoExoticComponent<typeof Page>;
|
|
4
5
|
export default _default;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type ViewPagerProps from './ViewPagerProps';
|
|
3
|
-
|
|
3
|
+
import type { ViewPagerInstance } from './ViewPagerProps';
|
|
4
|
+
declare const ViewPager: React.ForwardRefExoticComponent<Pick<ViewPagerProps, "style" | "children" | "onChange" | "scrollEnabled" | "keyboardDismissMode" | "loading" | "initialPage" | "offscreenPageRerenderLimit" | "pageComponent" | "pageForceRerenderKey" | "UNSTABLE_sharedIndex"> & React.RefAttributes<ViewPagerInstance>>;
|
|
5
|
+
export default ViewPager;
|
|
@@ -1,38 +1,46 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ComponentType, PropsWithChildren, ReactNode, Ref } from 'react';
|
|
2
2
|
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
3
4
|
import type { ComponentProps } from '@fountain-ui/core';
|
|
4
5
|
export declare type KeyboardDismissMode = 'none' | 'on-drag';
|
|
5
|
-
export declare type PageProps =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export declare type PageProps = PropsWithChildren<ViewProps> & {
|
|
7
|
+
index: number;
|
|
8
|
+
loading: ViewPagerProps['loading'];
|
|
9
|
+
offscreenPageRerenderLimit: number;
|
|
10
|
+
sharedIndex: SharedValue<number>;
|
|
11
|
+
rerenderKey?: ViewPagerProps['pageForceRerenderKey'];
|
|
9
12
|
};
|
|
10
|
-
export declare type PageComponent =
|
|
13
|
+
export declare type PageComponent = ComponentType<PageProps>;
|
|
11
14
|
export declare type Loading = 'lazy' | 'eager';
|
|
12
|
-
export
|
|
15
|
+
export interface ViewPagerInstance {
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
17
|
+
* Function to scroll to a specific page in the ViewPager. Invalid index is ignored.
|
|
18
|
+
* @param index
|
|
15
19
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
enableVisibleHint?: boolean;
|
|
20
|
+
setPage: (index: number) => void;
|
|
21
|
+
}
|
|
22
|
+
export default interface ViewPagerProps extends ComponentProps<{
|
|
23
|
+
ref?: Ref<ViewPagerInstance>;
|
|
22
24
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @default false
|
|
25
|
+
* Collection of ViewPager components.
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
+
children?: ReactNode;
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
+
* Index of initial page that should be selected.
|
|
30
|
+
* @default 0
|
|
29
31
|
*/
|
|
30
|
-
|
|
32
|
+
initialPage?: number;
|
|
31
33
|
/**
|
|
32
34
|
* Whether to load the page immediately (`eager`) or on an as-needed basis (`lazy`).
|
|
33
35
|
* @default 'lazy'
|
|
34
36
|
*/
|
|
35
37
|
loading?: Loading;
|
|
38
|
+
/**
|
|
39
|
+
* Mobile only. The number of pages that should be re-rendered to either side of the current page.
|
|
40
|
+
* Changing this value after the component mount has no effect.
|
|
41
|
+
* @default 0
|
|
42
|
+
*/
|
|
43
|
+
offscreenPageRerenderLimit?: number;
|
|
36
44
|
/**
|
|
37
45
|
* Callback fired when an index is changed.
|
|
38
46
|
*/
|
|
@@ -56,5 +64,9 @@ export default interface ViewPagerProps extends ComponentProps<{
|
|
|
56
64
|
* @default 'on-drag'
|
|
57
65
|
*/
|
|
58
66
|
keyboardDismissMode?: KeyboardDismissMode;
|
|
67
|
+
/**
|
|
68
|
+
* Unstable API.
|
|
69
|
+
*/
|
|
70
|
+
UNSTABLE_sharedIndex?: SharedValue<number>;
|
|
59
71
|
}> {
|
|
60
72
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type ViewPagerProps from './ViewPagerProps';
|
|
3
|
-
|
|
3
|
+
import type { ViewPagerInstance } from './ViewPagerProps';
|
|
4
|
+
declare const ViewPager: React.ForwardRefExoticComponent<Pick<ViewPagerProps, "style" | "children" | "onChange" | "scrollEnabled" | "keyboardDismissMode" | "loading" | "initialPage" | "offscreenPageRerenderLimit" | "pageComponent" | "pageForceRerenderKey" | "UNSTABLE_sharedIndex"> & React.RefAttributes<ViewPagerInstance>>;
|
|
5
|
+
export default ViewPager;
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export interface PageState {
|
|
4
|
-
visited?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface PageRenderOption {
|
|
7
|
-
enableVisibleHint: boolean;
|
|
8
|
-
enableNeighborPageRerender: boolean;
|
|
9
|
-
index: number;
|
|
10
|
-
loading: Loading;
|
|
11
|
-
pageComponent: PageComponent;
|
|
12
|
-
pageForceRerenderKey?: any;
|
|
13
|
-
}
|
|
14
|
-
export interface PageRenderer {
|
|
15
|
-
(children: ViewPagerProps['children']): React.ReactNode;
|
|
16
|
-
}
|
|
17
|
-
export declare const defaultEnableVisibleHint: boolean;
|
|
18
|
-
export declare const defaultEnableNeighborPageRerender: boolean;
|
|
1
|
+
import { Loading, PageComponent } from './ViewPagerProps';
|
|
2
|
+
export declare const defaultInitialPage: number;
|
|
19
3
|
export declare const defaultLoading: Loading;
|
|
4
|
+
export declare const defaultOffscreenPageRerenderLimit: number;
|
|
20
5
|
export declare const defaultPageComponent: PageComponent;
|
|
21
|
-
export declare const usePageRenderer: ({ enableVisibleHint, index: currentIndex, loading, pageComponent: PageComponent, pageForceRerenderKey, enableNeighborPageRerender, }: PageRenderOption) => PageRenderer;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type { OverridableComponentProps } from '@fountain-ui/core';
|
|
3
|
+
import type Viewability from './Viewability';
|
|
4
|
+
export default interface ViewabilityTrackerViewProps extends OverridableComponentProps<ViewProps, {
|
|
5
|
+
/**
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* @default 1000
|
|
11
|
+
*/
|
|
12
|
+
measurementIntervalMillis?: number;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
onViewabilityChange?: (viewability: Viewability) => void;
|
|
17
|
+
/**
|
|
18
|
+
* @default 50
|
|
19
|
+
*/
|
|
20
|
+
visiblePercentThreshold?: number;
|
|
21
|
+
}> {
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { View } from 'react-native';
|
|
2
|
+
export interface ViewabilityDetail {
|
|
3
|
+
visiblePercent: number;
|
|
4
|
+
}
|
|
5
|
+
export interface MeasureViewabilityParameters {
|
|
6
|
+
view: View;
|
|
7
|
+
windowWidth: number;
|
|
8
|
+
windowHeight: number;
|
|
9
|
+
onViewabilityDetailMeasured: (detail: ViewabilityDetail) => void;
|
|
10
|
+
}
|
|
11
|
+
export default function measureViewability({ view, windowWidth, windowHeight, onViewabilityDetailMeasured, }: MeasureViewabilityParameters): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import type { View } from 'react-native';
|
|
3
|
+
import type Viewability from './Viewability';
|
|
4
|
+
export interface ViewabilityTrackerConfig {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
measurementIntervalMillis: number;
|
|
7
|
+
onViewabilityChange?: (viewability: Viewability) => void;
|
|
8
|
+
viewRef: RefObject<View>;
|
|
9
|
+
visiblePercentThreshold: number;
|
|
10
|
+
}
|
|
11
|
+
export default function useViewabilityTracker(config: ViewabilityTrackerConfig): void;
|
|
@@ -1,2 +1,4 @@
|
|
|
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';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface Runnable {
|
|
2
|
+
(): void;
|
|
3
|
+
}
|
|
4
|
+
export interface DeferredExecute {
|
|
5
|
+
(runnable: Runnable, delay?: number): void;
|
|
6
|
+
}
|
|
7
|
+
export interface DeferredExecutor {
|
|
8
|
+
cancel: () => void;
|
|
9
|
+
execute: DeferredExecute;
|
|
10
|
+
}
|
|
11
|
+
export default function useDeferredExecutor(): DeferredExecutor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Falsy, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';
|
|
2
|
-
import
|
|
2
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
3
3
|
declare type WebOnlyStyle = {
|
|
4
4
|
boxShadow: any;
|
|
5
5
|
};
|
|
@@ -13,12 +13,11 @@ export interface ContentInsets {
|
|
|
13
13
|
right?: number;
|
|
14
14
|
}
|
|
15
15
|
export interface Options {
|
|
16
|
-
translucent?: boolean;
|
|
17
16
|
shouldTranslateYReset?: boolean;
|
|
18
17
|
}
|
|
19
18
|
export interface CollapsibleAppBar {
|
|
20
19
|
appBarStyle: ViewStyleProp;
|
|
21
|
-
vectorY:
|
|
20
|
+
vectorY: SharedValue<number>;
|
|
22
21
|
onAppBarLayout: OnLayoutCallback;
|
|
23
22
|
onCollapsibleToolbarLayout: OnLayoutCallback;
|
|
24
23
|
onScroll: OnScroll;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default function useAnimatedDisplayStyle(vectorY:
|
|
1
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
2
|
+
export default function useAnimatedDisplayStyle(vectorY: SharedValue<number>, threshold?: number, defaultDisplay?: 'flex' | 'none'): {
|
|
3
3
|
display: "flex" | "none";
|
|
4
4
|
};
|
|
@@ -12,4 +12,6 @@ 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';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fountain-ui/lab",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Fountain-UI Team",
|
|
6
6
|
"description": "Incubator for Fountain-UI React components.",
|
|
@@ -15,53 +15,38 @@
|
|
|
15
15
|
"prepare": "bob build"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@emotion/react": "^11.
|
|
19
|
-
"@emotion/styled": "^11.
|
|
20
|
-
"@fountain-ui/icons": "^2.0.0-beta.
|
|
21
|
-
"@fountain-ui/utils": "^2.0.0-beta.
|
|
18
|
+
"@emotion/react": "^11.10.0",
|
|
19
|
+
"@emotion/styled": "^11.10.0",
|
|
20
|
+
"@fountain-ui/icons": "^2.0.0-beta.6",
|
|
21
|
+
"@fountain-ui/utils": "^2.0.0-beta.3",
|
|
22
22
|
"react-native-calendars": "1.1267.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@fountain-ui/core": "^2.0.0-beta.
|
|
25
|
+
"@fountain-ui/core": "^2.0.0-beta.3",
|
|
26
26
|
"@gorhom/bottom-sheet": "^4.1.3",
|
|
27
|
-
"@react-native-community/viewpager": "> 4.2.x",
|
|
28
27
|
"date-fns": "^2.0.0",
|
|
29
28
|
"react": "^16.8.0 || ^17.0.0",
|
|
30
29
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
31
30
|
"react-native": "^0.63.0",
|
|
32
|
-
"react-native-
|
|
33
|
-
"react-
|
|
31
|
+
"react-native-gesture-handler": "^2.0.0",
|
|
32
|
+
"react-native-pager-view": "^4.0.0"
|
|
34
33
|
},
|
|
35
34
|
"peerDependenciesMeta": {
|
|
36
35
|
"@gorhom/bottom-sheet": {
|
|
37
36
|
"optional": true
|
|
38
37
|
},
|
|
39
|
-
"@react-native-community/viewpager": {
|
|
40
|
-
"optional": true
|
|
41
|
-
},
|
|
42
38
|
"react-dom": {
|
|
43
39
|
"optional": true
|
|
44
40
|
},
|
|
45
|
-
"react-native": {
|
|
46
|
-
"optional": true
|
|
47
|
-
},
|
|
48
|
-
"react-slick": {
|
|
49
|
-
"optional": true
|
|
50
|
-
},
|
|
51
|
-
"react-native-snap-carousel": {
|
|
41
|
+
"react-native-pager-view": {
|
|
52
42
|
"optional": true
|
|
53
43
|
}
|
|
54
44
|
},
|
|
55
45
|
"devDependencies": {
|
|
56
|
-
"@fountain-ui/core": "^2.0.0-beta.1",
|
|
57
46
|
"@gorhom/bottom-sheet": "4.1.3",
|
|
58
|
-
"@react-native-community/viewpager": "^4.2.2",
|
|
59
|
-
"@types/react-native-snap-carousel": "^3.8.4",
|
|
60
|
-
"@types/react-slick": "^0.23.5",
|
|
61
47
|
"date-fns": "^2.23.0",
|
|
62
|
-
"react-native-
|
|
63
|
-
"react-native-
|
|
64
|
-
"react-slick": "^0.28.1"
|
|
48
|
+
"react-native-pager-view": "^4.2.4",
|
|
49
|
+
"react-native-safe-area-context": "^3.3.2"
|
|
65
50
|
},
|
|
66
51
|
"react-native-builder-bob": {
|
|
67
52
|
"source": "./src",
|
|
@@ -85,5 +70,5 @@
|
|
|
85
70
|
"publishConfig": {
|
|
86
71
|
"access": "public"
|
|
87
72
|
},
|
|
88
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "efb9e6cc7cc65e52d1084a0c3664f419dc171240"
|
|
89
74
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import type { WithTimingConfig } from 'react-native-reanimated';
|
|
3
|
+
import Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
3
4
|
import type AnimatedYProps from './AnimatedYProps';
|
|
4
5
|
|
|
6
|
+
const ANIMATION_CONFIG: Readonly<WithTimingConfig> = {
|
|
7
|
+
duration: 150,
|
|
8
|
+
easing: Easing.out(Easing.exp),
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
export default function AnimatedY(props: AnimatedYProps) {
|
|
6
12
|
const {
|
|
7
13
|
children,
|
|
@@ -9,17 +15,14 @@ export default function AnimatedY(props: AnimatedYProps) {
|
|
|
9
15
|
style,
|
|
10
16
|
} = props;
|
|
11
17
|
|
|
12
|
-
const animatedY =
|
|
13
|
-
const animatedStyle =
|
|
18
|
+
const animatedY = useSharedValue(translateY);
|
|
19
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
14
20
|
transform: [{ translateY: animatedY.value }],
|
|
15
|
-
}));
|
|
21
|
+
}), []);
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
useEffect(() => {
|
|
18
24
|
if (translateY >= 0) {
|
|
19
|
-
animatedY.value =
|
|
20
|
-
duration: 150,
|
|
21
|
-
easing: Easing.out(Easing.exp),
|
|
22
|
-
});
|
|
25
|
+
animatedY.value = withTiming(translateY, ANIMATION_CONFIG);
|
|
23
26
|
}
|
|
24
27
|
}, [translateY]);
|
|
25
28
|
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import ViewabilityTrackerView from '../ViewabilityTrackerView';
|
|
4
|
+
import type CarouselProps from './CarouselProps';
|
|
5
|
+
import type { CarouselInstance } from './types';
|
|
6
|
+
import {
|
|
7
|
+
useAutoplayController,
|
|
8
|
+
useDimensionChangeReaction,
|
|
9
|
+
useIndexController,
|
|
10
|
+
useItemVisibilityStore,
|
|
11
|
+
useLoopedData,
|
|
12
|
+
usePagingAnimation,
|
|
13
|
+
} from './hooks';
|
|
14
|
+
import { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';
|
|
15
|
+
import { InternalContext, RootView, ScrollViewGesture } from './components';
|
|
16
|
+
|
|
17
|
+
const Carousel = forwardRef<CarouselInstance, CarouselProps>(function Carousel(props, ref) {
|
|
18
|
+
const {
|
|
19
|
+
autoplay = false,
|
|
20
|
+
autoplayInterval = 3000,
|
|
21
|
+
createItemStyle = createDefaultItemStyle,
|
|
22
|
+
createScrollAnimation = createDefaultScrollAnimation,
|
|
23
|
+
data: originalData,
|
|
24
|
+
disableSmartAutoplay = false,
|
|
25
|
+
initialIndex = 0,
|
|
26
|
+
itemHeight,
|
|
27
|
+
itemWidth,
|
|
28
|
+
loop = false,
|
|
29
|
+
onIndexChange,
|
|
30
|
+
renderItem,
|
|
31
|
+
scrollEnabled = true,
|
|
32
|
+
style,
|
|
33
|
+
windowSize = 5,
|
|
34
|
+
} = props;
|
|
35
|
+
|
|
36
|
+
const data = useLoopedData(originalData, loop);
|
|
37
|
+
|
|
38
|
+
const initialTx = itemWidth * initialIndex;
|
|
39
|
+
const controlledTx = useRef(new Animated.Value(initialTx)).current;
|
|
40
|
+
const offsetTx = useRef(new Animated.Value(0)).current;
|
|
41
|
+
|
|
42
|
+
const {
|
|
43
|
+
currentIndex,
|
|
44
|
+
getCurrentIndex,
|
|
45
|
+
lastIndex,
|
|
46
|
+
monitorElement,
|
|
47
|
+
} = useIndexController({
|
|
48
|
+
controlledTx,
|
|
49
|
+
initialIndex,
|
|
50
|
+
itemWidth,
|
|
51
|
+
numberOfOriginalData: originalData.length,
|
|
52
|
+
onIndexChange,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const itemVisibilityStore = useItemVisibilityStore({
|
|
56
|
+
currentIndex,
|
|
57
|
+
numberOfData: data.length,
|
|
58
|
+
windowSize,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const {
|
|
62
|
+
finalizeAnimation,
|
|
63
|
+
globalInterpolation,
|
|
64
|
+
startAnimation,
|
|
65
|
+
} = usePagingAnimation({
|
|
66
|
+
controlledTx,
|
|
67
|
+
createScrollAnimation,
|
|
68
|
+
getCurrentIndex,
|
|
69
|
+
itemWidth,
|
|
70
|
+
lastIndex,
|
|
71
|
+
loop,
|
|
72
|
+
numberOfData: data.length,
|
|
73
|
+
offsetTx,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const autoplayController = useAutoplayController({
|
|
77
|
+
enabled: autoplay,
|
|
78
|
+
intervalMillis: autoplayInterval,
|
|
79
|
+
startPagingAnimation: startAnimation,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
useDimensionChangeReaction({
|
|
83
|
+
controlledTx,
|
|
84
|
+
currentIndex,
|
|
85
|
+
itemWidth,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
useImperativeHandle(
|
|
89
|
+
ref,
|
|
90
|
+
() => ({
|
|
91
|
+
next: () => startAnimation('next'),
|
|
92
|
+
prev: () => startAnimation('prev'),
|
|
93
|
+
getCurrentIndex,
|
|
94
|
+
}),
|
|
95
|
+
[startAnimation, getCurrentIndex],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const contextValue = useMemo(() => ({
|
|
99
|
+
createItemStyle,
|
|
100
|
+
data,
|
|
101
|
+
globalInterpolation,
|
|
102
|
+
itemHeight,
|
|
103
|
+
itemWidth,
|
|
104
|
+
itemVisibilityStore,
|
|
105
|
+
loop,
|
|
106
|
+
}), [
|
|
107
|
+
createItemStyle,
|
|
108
|
+
data,
|
|
109
|
+
globalInterpolation,
|
|
110
|
+
itemHeight,
|
|
111
|
+
itemWidth,
|
|
112
|
+
itemVisibilityStore,
|
|
113
|
+
loop,
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<InternalContext.Provider value={contextValue}>
|
|
118
|
+
{monitorElement}
|
|
119
|
+
|
|
120
|
+
<ViewabilityTrackerView
|
|
121
|
+
enabled={autoplay && !disableSmartAutoplay}
|
|
122
|
+
measurementIntervalMillis={Math.max(3000, autoplayInterval)}
|
|
123
|
+
onViewabilityChange={({ visible }) => {
|
|
124
|
+
if (visible) {
|
|
125
|
+
autoplayController.resume();
|
|
126
|
+
} else {
|
|
127
|
+
autoplayController.pause();
|
|
128
|
+
}
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
<ScrollViewGesture
|
|
132
|
+
autoplayController={autoplayController}
|
|
133
|
+
finalizeAnimation={finalizeAnimation}
|
|
134
|
+
offsetTx={offsetTx}
|
|
135
|
+
scrollEnabled={scrollEnabled}
|
|
136
|
+
startAnimation={startAnimation}
|
|
137
|
+
>
|
|
138
|
+
<RootView
|
|
139
|
+
data={data}
|
|
140
|
+
itemHeight={itemHeight}
|
|
141
|
+
originalData={originalData}
|
|
142
|
+
renderItem={renderItem}
|
|
143
|
+
style={style}
|
|
144
|
+
/>
|
|
145
|
+
</ScrollViewGesture>
|
|
146
|
+
</ViewabilityTrackerView>
|
|
147
|
+
</InternalContext.Provider>
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export default memo(Carousel);
|