@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
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import { InternalContext } from '../components';
|
|
4
|
+
|
|
5
|
+
const OVERSCROLL_FRICTION_FACTOR = 4;
|
|
6
|
+
|
|
7
|
+
export default function useItemInterpolation(index: number): Animated.AnimatedInterpolation {
|
|
8
|
+
const {
|
|
9
|
+
itemWidth,
|
|
10
|
+
data,
|
|
11
|
+
globalInterpolation,
|
|
12
|
+
loop,
|
|
13
|
+
} = useContext(InternalContext);
|
|
14
|
+
|
|
15
|
+
const numberOfData = data.length;
|
|
16
|
+
|
|
17
|
+
const interpolationConfigOnLoop = useMemo<Animated.InterpolationConfigType>(() => {
|
|
18
|
+
const lastIndex = numberOfData - 1;
|
|
19
|
+
const maxWidth = Math.abs(itemWidth * numberOfData);
|
|
20
|
+
const halfOfItemWidth = 0.5 * itemWidth;
|
|
21
|
+
|
|
22
|
+
const positiveCount = Math.round(lastIndex / 2);
|
|
23
|
+
const startPosition = index > positiveCount
|
|
24
|
+
? (index - numberOfData) * itemWidth
|
|
25
|
+
: itemWidth * index;
|
|
26
|
+
|
|
27
|
+
const max = positiveCount * itemWidth;
|
|
28
|
+
const min = -((lastIndex - positiveCount) * itemWidth);
|
|
29
|
+
|
|
30
|
+
const inputRange = [
|
|
31
|
+
-maxWidth,
|
|
32
|
+
min - halfOfItemWidth - startPosition - Number.MIN_VALUE,
|
|
33
|
+
min - halfOfItemWidth - startPosition,
|
|
34
|
+
0,
|
|
35
|
+
max + halfOfItemWidth - startPosition,
|
|
36
|
+
max + halfOfItemWidth - startPosition + Number.MIN_VALUE,
|
|
37
|
+
maxWidth,
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const outputRange = [
|
|
41
|
+
startPosition,
|
|
42
|
+
max + halfOfItemWidth - Number.MIN_VALUE,
|
|
43
|
+
min - halfOfItemWidth,
|
|
44
|
+
startPosition,
|
|
45
|
+
max + halfOfItemWidth,
|
|
46
|
+
min - halfOfItemWidth + Number.MIN_VALUE,
|
|
47
|
+
startPosition,
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
inputRange,
|
|
52
|
+
outputRange,
|
|
53
|
+
extrapolate: 'clamp',
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
index,
|
|
57
|
+
itemWidth,
|
|
58
|
+
numberOfData,
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
const interpolationConfigOnNoLoop = useMemo<Animated.InterpolationConfigType>(() => {
|
|
62
|
+
const lastIndex = numberOfData - 1;
|
|
63
|
+
const maxWidth = itemWidth * lastIndex;
|
|
64
|
+
const startPosition = itemWidth * index;
|
|
65
|
+
const friction = itemWidth / OVERSCROLL_FRICTION_FACTOR;
|
|
66
|
+
|
|
67
|
+
const inputRange = [
|
|
68
|
+
-(maxWidth + itemWidth), // overscroll
|
|
69
|
+
-maxWidth,
|
|
70
|
+
0,
|
|
71
|
+
itemWidth, // overscroll
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const outputRange = [
|
|
75
|
+
-maxWidth + startPosition - friction,
|
|
76
|
+
-maxWidth + startPosition,
|
|
77
|
+
startPosition,
|
|
78
|
+
startPosition + friction,
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
inputRange,
|
|
83
|
+
outputRange,
|
|
84
|
+
extrapolate: 'clamp',
|
|
85
|
+
};
|
|
86
|
+
}, [
|
|
87
|
+
index,
|
|
88
|
+
itemWidth,
|
|
89
|
+
numberOfData,
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
return useMemo(() => {
|
|
93
|
+
const interpolationConfig = loop
|
|
94
|
+
? interpolationConfigOnLoop
|
|
95
|
+
: interpolationConfigOnNoLoop;
|
|
96
|
+
|
|
97
|
+
const offsetX = globalInterpolation.interpolate(interpolationConfig);
|
|
98
|
+
|
|
99
|
+
return Animated.divide(offsetX, itemWidth);
|
|
100
|
+
}, [
|
|
101
|
+
globalInterpolation,
|
|
102
|
+
interpolationConfigOnLoop,
|
|
103
|
+
interpolationConfigOnNoLoop,
|
|
104
|
+
itemWidth,
|
|
105
|
+
loop,
|
|
106
|
+
]);
|
|
107
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import type { ItemVisibilityStore, VisibleIndexRanges } from '../types';
|
|
3
|
+
|
|
4
|
+
export interface Parameters {
|
|
5
|
+
currentIndex: number;
|
|
6
|
+
numberOfData: number;
|
|
7
|
+
windowSize: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class SimpleItemVisibilityStore implements ItemVisibilityStore {
|
|
11
|
+
|
|
12
|
+
private store: VisibleIndexRanges;
|
|
13
|
+
|
|
14
|
+
constructor(initialValue: VisibleIndexRanges) {
|
|
15
|
+
this.store = initialValue;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private listeners: Array<(ranges: VisibleIndexRanges) => void> = [];
|
|
19
|
+
|
|
20
|
+
subscribe(listener: (ranges: VisibleIndexRanges) => void) {
|
|
21
|
+
this.listeners.push(listener);
|
|
22
|
+
|
|
23
|
+
listener(this.store);
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
const index = this.listeners.indexOf(listener);
|
|
27
|
+
this.listeners.splice(index, 1);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
dispatch(ranges: VisibleIndexRanges): void {
|
|
32
|
+
this.store = ranges;
|
|
33
|
+
for (const id in this.listeners) {
|
|
34
|
+
const listener = this.listeners[id];
|
|
35
|
+
listener?.(ranges);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
removeAllListeners(): void {
|
|
40
|
+
this.listeners.splice(0, this.listeners.length);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function normalize(windowSize: number, numberOfData: number): number {
|
|
46
|
+
if (windowSize <= 0) {
|
|
47
|
+
return numberOfData;
|
|
48
|
+
}
|
|
49
|
+
if (windowSize > 0 && windowSize % 2 === 0) {
|
|
50
|
+
return windowSize + 1;
|
|
51
|
+
}
|
|
52
|
+
return windowSize;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function mod(value: number, modulo: number): number {
|
|
56
|
+
return ((value % modulo) + modulo) % modulo;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function makeVisibleIndexRanges(numberOfData: number, windowSize: number, index: number): VisibleIndexRanges {
|
|
60
|
+
const ws = normalize(windowSize, numberOfData);
|
|
61
|
+
|
|
62
|
+
const firstIndex = 0;
|
|
63
|
+
const lastIndex = numberOfData - 1;
|
|
64
|
+
const halfNumberOfAdjacent = Math.floor(ws / 2);
|
|
65
|
+
|
|
66
|
+
const leftSide = index - halfNumberOfAdjacent;
|
|
67
|
+
const rightSide = index + halfNumberOfAdjacent;
|
|
68
|
+
|
|
69
|
+
const leftRanges = leftSide >= 0
|
|
70
|
+
? [[leftSide, index]]
|
|
71
|
+
: [[firstIndex, index], [mod(leftSide, numberOfData), lastIndex]];
|
|
72
|
+
|
|
73
|
+
const rightRanges = rightSide < numberOfData
|
|
74
|
+
? [[index, rightSide]]
|
|
75
|
+
: [[index, lastIndex], [firstIndex, mod(rightSide, numberOfData)]];
|
|
76
|
+
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
return [
|
|
79
|
+
...leftRanges,
|
|
80
|
+
...rightRanges,
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default function useItemVisibilityStore(params: Parameters): ItemVisibilityStore {
|
|
85
|
+
const {
|
|
86
|
+
currentIndex,
|
|
87
|
+
numberOfData,
|
|
88
|
+
windowSize,
|
|
89
|
+
} = params;
|
|
90
|
+
|
|
91
|
+
const [initialRange] = useState(() => makeVisibleIndexRanges(numberOfData, windowSize, currentIndex));
|
|
92
|
+
const store = useRef(new SimpleItemVisibilityStore(initialRange)).current;
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const newRanges = makeVisibleIndexRanges(numberOfData, windowSize, currentIndex);
|
|
96
|
+
|
|
97
|
+
store.dispatch(newRanges);
|
|
98
|
+
}, [currentIndex, numberOfData, windowSize]);
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
return () => {
|
|
102
|
+
store.removeAllListeners();
|
|
103
|
+
};
|
|
104
|
+
}, []);
|
|
105
|
+
|
|
106
|
+
return store;
|
|
107
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
export default function useLoopedData<ItemT>(
|
|
4
|
+
originalData: ReadonlyArray<ItemT>,
|
|
5
|
+
loop: boolean,
|
|
6
|
+
): ReadonlyArray<ItemT> {
|
|
7
|
+
return useMemo(() => {
|
|
8
|
+
if (!loop) {
|
|
9
|
+
return originalData;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const numberOfData = originalData.length;
|
|
13
|
+
|
|
14
|
+
if (numberOfData === 1) {
|
|
15
|
+
const [first] = originalData;
|
|
16
|
+
return [first, first, first];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (numberOfData === 2) {
|
|
20
|
+
const [first, second] = originalData;
|
|
21
|
+
return [first, second, first, second];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return originalData;
|
|
25
|
+
}, [originalData, loop]);
|
|
26
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { Animated, Platform } from 'react-native';
|
|
3
|
+
import type { CreateScrollAnimation, GetCurrentIndex, PagingDirection, StartPagingAnimation } from '../types';
|
|
4
|
+
|
|
5
|
+
export interface PagingAnimationConfig {
|
|
6
|
+
controlledTx: Animated.Value;
|
|
7
|
+
createScrollAnimation: CreateScrollAnimation;
|
|
8
|
+
getCurrentIndex: GetCurrentIndex;
|
|
9
|
+
itemWidth: number;
|
|
10
|
+
lastIndex: number;
|
|
11
|
+
loop: boolean;
|
|
12
|
+
numberOfData: number;
|
|
13
|
+
offsetTx: Animated.Value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface UsePagingAnimation {
|
|
17
|
+
finalizeAnimation: () => void;
|
|
18
|
+
globalInterpolation: Animated.AnimatedInterpolation;
|
|
19
|
+
startAnimation: StartPagingAnimation;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function directionToValue(itemWidth: number) {
|
|
23
|
+
return function (direction: PagingDirection): number {
|
|
24
|
+
switch (direction) {
|
|
25
|
+
case 'next':
|
|
26
|
+
return -itemWidth;
|
|
27
|
+
case 'prev':
|
|
28
|
+
return itemWidth;
|
|
29
|
+
case 'stay':
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default function usePagingAnimation(config: PagingAnimationConfig): UsePagingAnimation {
|
|
36
|
+
const {
|
|
37
|
+
controlledTx,
|
|
38
|
+
createScrollAnimation,
|
|
39
|
+
getCurrentIndex,
|
|
40
|
+
itemWidth,
|
|
41
|
+
lastIndex,
|
|
42
|
+
loop,
|
|
43
|
+
numberOfData,
|
|
44
|
+
offsetTx,
|
|
45
|
+
} = config;
|
|
46
|
+
|
|
47
|
+
const animationRef = useRef<Animated.CompositeAnimation | null>(null);
|
|
48
|
+
const toValueRef = useRef<number>(0);
|
|
49
|
+
|
|
50
|
+
const globalInterpolation = useMemo(
|
|
51
|
+
() => Animated.add(controlledTx, offsetTx),
|
|
52
|
+
[controlledTx, offsetTx],
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const subscriptionId = controlledTx.addListener((value) => {
|
|
57
|
+
const currentTx = value.value;
|
|
58
|
+
|
|
59
|
+
// Prevent infinite loop
|
|
60
|
+
if (currentTx !== 0) {
|
|
61
|
+
const maxWidth = numberOfData * itemWidth;
|
|
62
|
+
|
|
63
|
+
if (Math.abs(Math.round(currentTx)) === Math.round(maxWidth)) {
|
|
64
|
+
// reset position
|
|
65
|
+
controlledTx.setValue(0);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return () => {
|
|
71
|
+
controlledTx.removeListener(subscriptionId);
|
|
72
|
+
};
|
|
73
|
+
}, [numberOfData, itemWidth]);
|
|
74
|
+
|
|
75
|
+
const finalizeAnimation = useCallback(() => {
|
|
76
|
+
const stopUnfinishedSnapAnimation = () => {
|
|
77
|
+
if (animationRef.current) {
|
|
78
|
+
animationRef.current?.stop();
|
|
79
|
+
animationRef.current = null;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const resetBoundary = () => {
|
|
84
|
+
controlledTx.setOffset(toValueRef.current);
|
|
85
|
+
controlledTx.flattenOffset();
|
|
86
|
+
|
|
87
|
+
// FIXME: react-native-web bug maybe?
|
|
88
|
+
// `AnimatedValue.flattenOffset()` does not trigger any event listener.
|
|
89
|
+
// Accessing value directly via `_value` is dangerous but working on web (`useNativeDriver` always false).
|
|
90
|
+
// So setting same value with `value.setValue(value._value)` will trigger event listener.
|
|
91
|
+
if (Platform.OS === 'web') {
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
controlledTx.setValue(controlledTx._value);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
offsetTx.setValue(0);
|
|
97
|
+
toValueRef.current = 0;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
stopUnfinishedSnapAnimation();
|
|
101
|
+
|
|
102
|
+
resetBoundary();
|
|
103
|
+
}, [controlledTx]);
|
|
104
|
+
|
|
105
|
+
const startAnimation = useCallback((direction: PagingDirection, isGesture: boolean = false) => {
|
|
106
|
+
const getToValueByDirection = directionToValue(itemWidth);
|
|
107
|
+
|
|
108
|
+
const currentIndex = getCurrentIndex();
|
|
109
|
+
|
|
110
|
+
const computeToValueOnNoLoop = (): number => {
|
|
111
|
+
if (currentIndex === 0 && direction === 'prev') {
|
|
112
|
+
return isGesture
|
|
113
|
+
? getToValueByDirection('stay')
|
|
114
|
+
: -lastIndex * itemWidth; // last position
|
|
115
|
+
} else if (currentIndex === lastIndex && direction === 'next') {
|
|
116
|
+
return isGesture
|
|
117
|
+
? getToValueByDirection('stay')
|
|
118
|
+
: lastIndex * itemWidth; // first position
|
|
119
|
+
}
|
|
120
|
+
return getToValueByDirection(direction);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const toValue = loop ? getToValueByDirection(direction) : computeToValueOnNoLoop();
|
|
124
|
+
const animation = createScrollAnimation(offsetTx, toValue);
|
|
125
|
+
|
|
126
|
+
animationRef.current = animation;
|
|
127
|
+
toValueRef.current = toValue;
|
|
128
|
+
|
|
129
|
+
animation.start(({ finished }) => {
|
|
130
|
+
if (finished) {
|
|
131
|
+
finalizeAnimation();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}, [
|
|
135
|
+
createScrollAnimation,
|
|
136
|
+
getCurrentIndex,
|
|
137
|
+
finalizeAnimation,
|
|
138
|
+
itemWidth,
|
|
139
|
+
lastIndex,
|
|
140
|
+
loop,
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
globalInterpolation,
|
|
145
|
+
finalizeAnimation,
|
|
146
|
+
startAnimation,
|
|
147
|
+
};
|
|
148
|
+
};
|
package/src/Carousel/index.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { default } from './
|
|
2
|
-
export type { default as CarouselProps } from './CarouselProps';
|
|
1
|
+
export { default } from './Carousel';
|
|
2
|
+
export type { default as CarouselProps } from './CarouselProps';
|
|
3
|
+
export type { CarouselInstance } from './types';
|
|
4
|
+
export { normalItemStyleFactory, parallaxItemStyleFactory } from './animation';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { Animated, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const directions = ['next', 'prev', 'stay'] as const;
|
|
5
|
+
|
|
6
|
+
export type PagingDirection = (typeof directions)[number];
|
|
7
|
+
|
|
8
|
+
export interface RenderItem<T> {
|
|
9
|
+
(info: { item: T, index: number, interpolation: Animated.AnimatedInterpolation }): ReactElement | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CreateScrollAnimation {
|
|
13
|
+
(aValue: Animated.AnimatedValue, toValue: number): Animated.CompositeAnimation;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CreateItemStyle {
|
|
17
|
+
(itemInterpolation: Animated.AnimatedInterpolation, itemWidth: number): Animated.AnimatedProps<ViewProps['style']>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface GetCurrentIndex {
|
|
21
|
+
(): number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IndexController {
|
|
25
|
+
currentIndex: number;
|
|
26
|
+
getCurrentIndex: GetCurrentIndex;
|
|
27
|
+
lastIndex: number;
|
|
28
|
+
monitorElement: ReactElement;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface StartPagingAnimation {
|
|
32
|
+
(direction: PagingDirection, isGesture?: boolean): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type VisibleIndexRanges = Array<[number, number]>;
|
|
36
|
+
|
|
37
|
+
export interface StoreSubscription {
|
|
38
|
+
(): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ItemVisibilityStore {
|
|
42
|
+
dispatch: (ranges: VisibleIndexRanges) => void;
|
|
43
|
+
subscribe: (listener: (ranges: VisibleIndexRanges) => void) => StoreSubscription;
|
|
44
|
+
removeAllListeners: () => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface AutoplayController {
|
|
48
|
+
pause: () => void;
|
|
49
|
+
resume: () => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface CarouselInstance {
|
|
53
|
+
/**
|
|
54
|
+
* Scroll to next visible item.
|
|
55
|
+
*/
|
|
56
|
+
next: () => void;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Scroll to previous visible item.
|
|
60
|
+
*/
|
|
61
|
+
prev: () => void;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get current visible item index.
|
|
65
|
+
*/
|
|
66
|
+
getCurrentIndex: GetCurrentIndex;
|
|
67
|
+
}
|
|
@@ -82,8 +82,8 @@ export default function DateTimePicker(props: DateTimePickerProps) {
|
|
|
82
82
|
/>
|
|
83
83
|
)}
|
|
84
84
|
theme={{
|
|
85
|
-
backgroundColor: theme.palette.
|
|
86
|
-
calendarBackground: theme.palette.
|
|
85
|
+
backgroundColor: theme.palette.paper.default,
|
|
86
|
+
calendarBackground: theme.palette.paper.default,
|
|
87
87
|
dayTextColor: theme.palette.text.primary,
|
|
88
88
|
textDisabledColor: theme.palette.text.hint,
|
|
89
89
|
}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
|
-
import Animated from 'react-native-reanimated';
|
|
3
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
4
4
|
import type FlipCardProps from './FlipCardProps';
|
|
5
5
|
|
|
6
6
|
const styles = StyleSheet.create({
|
|
@@ -27,9 +27,9 @@ export default function FlipCard(props: FlipCardProps) {
|
|
|
27
27
|
style,
|
|
28
28
|
} = props;
|
|
29
29
|
|
|
30
|
-
const sharedAngle =
|
|
30
|
+
const sharedAngle = useSharedValue(0);
|
|
31
31
|
|
|
32
|
-
const animatedFrontCardStyle =
|
|
32
|
+
const animatedFrontCardStyle = useAnimatedStyle(() => {
|
|
33
33
|
return {
|
|
34
34
|
zIndex: sharedAngle.value < Z_INDEX_CHANGE_ANGLE ? 2 : 1,
|
|
35
35
|
transform: [
|
|
@@ -37,9 +37,9 @@ export default function FlipCard(props: FlipCardProps) {
|
|
|
37
37
|
{ rotateX: `${sharedAngle.value}deg` },
|
|
38
38
|
],
|
|
39
39
|
};
|
|
40
|
-
});
|
|
40
|
+
}, []);
|
|
41
41
|
|
|
42
|
-
const animatedBackCardStyle =
|
|
42
|
+
const animatedBackCardStyle = useAnimatedStyle(() => {
|
|
43
43
|
return {
|
|
44
44
|
zIndex: sharedAngle.value <= Z_INDEX_CHANGE_ANGLE ? 1 : 2,
|
|
45
45
|
transform: [
|
|
@@ -47,11 +47,11 @@ export default function FlipCard(props: FlipCardProps) {
|
|
|
47
47
|
{ rotateX: `${(sharedAngle.value + 180)}deg` },
|
|
48
48
|
],
|
|
49
49
|
};
|
|
50
|
-
});
|
|
50
|
+
}, []);
|
|
51
51
|
|
|
52
52
|
useEffect(() => {
|
|
53
53
|
sharedAngle.value = 0;
|
|
54
|
-
sharedAngle.value =
|
|
54
|
+
sharedAngle.value = withTiming(180, { duration: 500 });
|
|
55
55
|
}, [reanimationKey]);
|
|
56
56
|
|
|
57
57
|
return (
|
|
@@ -65,4 +65,4 @@ export default function FlipCard(props: FlipCardProps) {
|
|
|
65
65
|
</Animated.View>
|
|
66
66
|
</View>
|
|
67
67
|
);
|
|
68
|
-
};
|
|
68
|
+
};
|
|
@@ -1,36 +1,110 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
1
|
+
import React, { memo, useMemo, useState } from 'react';
|
|
2
|
+
import { Platform, View } from 'react-native';
|
|
3
|
+
import { runOnJS, useAnimatedReaction } from 'react-native-reanimated';
|
|
4
|
+
import { StyleSheet } from '@fountain-ui/core';
|
|
3
5
|
import type { PageProps } from './ViewPagerProps';
|
|
6
|
+
import PageStateContext from './PageStateContext';
|
|
4
7
|
|
|
5
|
-
const
|
|
6
|
-
|
|
8
|
+
const styles = StyleSheet.create({
|
|
9
|
+
fill: { width: '100%', height: '100%' },
|
|
10
|
+
none: { display: 'none' },
|
|
11
|
+
});
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
interface InternalPageState {
|
|
14
|
+
isActive: boolean;
|
|
15
|
+
isLoaded: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function Page(props: PageProps) {
|
|
19
|
+
const {
|
|
20
|
+
index,
|
|
21
|
+
children,
|
|
22
|
+
loading,
|
|
23
|
+
offscreenPageRerenderLimit,
|
|
24
|
+
sharedIndex,
|
|
25
|
+
} = props;
|
|
26
|
+
|
|
27
|
+
const assumeInitialPageState = (): InternalPageState => {
|
|
28
|
+
const activeIndex = sharedIndex.value;
|
|
29
|
+
|
|
30
|
+
const isActive = index === activeIndex;
|
|
31
|
+
|
|
32
|
+
if (loading === 'eager') {
|
|
33
|
+
return { isActive, isLoaded: true };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const isLoaded = index >= activeIndex - offscreenPageRerenderLimit
|
|
37
|
+
&& index <= activeIndex + offscreenPageRerenderLimit;
|
|
38
|
+
|
|
39
|
+
return { isActive, isLoaded };
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const [pageState, setPageState] = useState<InternalPageState>(assumeInitialPageState);
|
|
43
|
+
|
|
44
|
+
const content = pageState.isLoaded ? children : null;
|
|
45
|
+
|
|
46
|
+
const onActiveStateChange = (isActive: boolean) => {
|
|
47
|
+
setPageState(prevState => ({
|
|
48
|
+
...prevState,
|
|
49
|
+
isActive,
|
|
50
|
+
isLoaded: isActive || prevState.isLoaded,
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const onBecomeNeighbor = () => {
|
|
55
|
+
setPageState(prevState => ({
|
|
56
|
+
...prevState,
|
|
57
|
+
isLoaded: true,
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
useAnimatedReaction(
|
|
62
|
+
() => {
|
|
63
|
+
const activeIndex = sharedIndex.value;
|
|
64
|
+
|
|
65
|
+
const isActive = index === activeIndex;
|
|
66
|
+
|
|
67
|
+
const shouldRerender = index >= activeIndex - offscreenPageRerenderLimit
|
|
68
|
+
&& index <= activeIndex + offscreenPageRerenderLimit;
|
|
69
|
+
|
|
70
|
+
const becomeNeighbor = shouldRerender && !isActive;
|
|
71
|
+
|
|
72
|
+
return { isActive, becomeNeighbor };
|
|
73
|
+
},
|
|
74
|
+
(nextState, prevState) => {
|
|
75
|
+
if (nextState.isActive !== prevState?.isActive) {
|
|
76
|
+
runOnJS(onActiveStateChange)(nextState.isActive);
|
|
77
|
+
} else if (nextState.becomeNeighbor) {
|
|
78
|
+
runOnJS(onBecomeNeighbor)();
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
[index],
|
|
13
82
|
);
|
|
14
|
-
};
|
|
15
83
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
84
|
+
const contextValue = useMemo(() => ({
|
|
85
|
+
isActive: pageState.isActive,
|
|
86
|
+
}), [pageState.isActive]);
|
|
20
87
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
88
|
+
const style = Platform.OS === 'web'
|
|
89
|
+
? (pageState.isActive ? StyleSheet.absoluteFill : styles.none)
|
|
90
|
+
: styles.fill;
|
|
26
91
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
92
|
+
return (
|
|
93
|
+
<View
|
|
94
|
+
collapsable={false}
|
|
95
|
+
style={style}
|
|
96
|
+
>
|
|
97
|
+
<PageStateContext.Provider value={contextValue}>
|
|
98
|
+
{content}
|
|
99
|
+
</PageStateContext.Provider>
|
|
100
|
+
</View>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
30
103
|
|
|
104
|
+
export default memo(Page, (prevProps, nextProps) => {
|
|
31
105
|
if (prevProps.rerenderKey !== nextProps.rerenderKey) {
|
|
32
106
|
return false;
|
|
33
107
|
}
|
|
34
108
|
|
|
35
|
-
return prevProps.
|
|
109
|
+
return prevProps.index !== nextProps.index;
|
|
36
110
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
interface PageState {
|
|
4
|
+
isActive: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const initialPageState: Readonly<PageState> = { isActive: false };
|
|
8
|
+
|
|
9
|
+
const PageStateContext = createContext<PageState>(initialPageState);
|
|
10
|
+
|
|
11
|
+
export const useViewPagerPageState = () => {
|
|
12
|
+
return useContext(PageStateContext);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default PageStateContext;
|