@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,115 @@
|
|
|
1
|
+
import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import ViewabilityTrackerView from '../ViewabilityTrackerView';
|
|
4
|
+
import { useAutoplayController, useDimensionChangeReaction, useIndexController, useItemVisibilityStore, useLoopedData, usePagingAnimation } from './hooks';
|
|
5
|
+
import { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';
|
|
6
|
+
import { InternalContext, RootView, ScrollViewGesture } from './components';
|
|
7
|
+
const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
|
|
8
|
+
const {
|
|
9
|
+
autoplay = false,
|
|
10
|
+
autoplayInterval = 3000,
|
|
11
|
+
createItemStyle = createDefaultItemStyle,
|
|
12
|
+
createScrollAnimation = createDefaultScrollAnimation,
|
|
13
|
+
data: originalData,
|
|
14
|
+
disableSmartAutoplay = false,
|
|
15
|
+
initialIndex = 0,
|
|
16
|
+
itemHeight,
|
|
17
|
+
itemWidth,
|
|
18
|
+
loop = false,
|
|
19
|
+
onIndexChange,
|
|
20
|
+
renderItem,
|
|
21
|
+
scrollEnabled = true,
|
|
22
|
+
style,
|
|
23
|
+
windowSize = 5
|
|
24
|
+
} = props;
|
|
25
|
+
const data = useLoopedData(originalData, loop);
|
|
26
|
+
const initialTx = itemWidth * initialIndex;
|
|
27
|
+
const controlledTx = useRef(new Animated.Value(initialTx)).current;
|
|
28
|
+
const offsetTx = useRef(new Animated.Value(0)).current;
|
|
29
|
+
const {
|
|
30
|
+
currentIndex,
|
|
31
|
+
getCurrentIndex,
|
|
32
|
+
lastIndex,
|
|
33
|
+
monitorElement
|
|
34
|
+
} = useIndexController({
|
|
35
|
+
controlledTx,
|
|
36
|
+
initialIndex,
|
|
37
|
+
itemWidth,
|
|
38
|
+
numberOfOriginalData: originalData.length,
|
|
39
|
+
onIndexChange
|
|
40
|
+
});
|
|
41
|
+
const itemVisibilityStore = useItemVisibilityStore({
|
|
42
|
+
currentIndex,
|
|
43
|
+
numberOfData: data.length,
|
|
44
|
+
windowSize
|
|
45
|
+
});
|
|
46
|
+
const {
|
|
47
|
+
finalizeAnimation,
|
|
48
|
+
globalInterpolation,
|
|
49
|
+
startAnimation
|
|
50
|
+
} = usePagingAnimation({
|
|
51
|
+
controlledTx,
|
|
52
|
+
createScrollAnimation,
|
|
53
|
+
getCurrentIndex,
|
|
54
|
+
itemWidth,
|
|
55
|
+
lastIndex,
|
|
56
|
+
loop,
|
|
57
|
+
numberOfData: data.length,
|
|
58
|
+
offsetTx
|
|
59
|
+
});
|
|
60
|
+
const autoplayController = useAutoplayController({
|
|
61
|
+
enabled: autoplay,
|
|
62
|
+
intervalMillis: autoplayInterval,
|
|
63
|
+
startPagingAnimation: startAnimation
|
|
64
|
+
});
|
|
65
|
+
useDimensionChangeReaction({
|
|
66
|
+
controlledTx,
|
|
67
|
+
currentIndex,
|
|
68
|
+
itemWidth
|
|
69
|
+
});
|
|
70
|
+
useImperativeHandle(ref, () => ({
|
|
71
|
+
next: () => startAnimation('next'),
|
|
72
|
+
prev: () => startAnimation('prev'),
|
|
73
|
+
getCurrentIndex
|
|
74
|
+
}), [startAnimation, getCurrentIndex]);
|
|
75
|
+
const contextValue = useMemo(() => ({
|
|
76
|
+
createItemStyle,
|
|
77
|
+
data,
|
|
78
|
+
globalInterpolation,
|
|
79
|
+
itemHeight,
|
|
80
|
+
itemWidth,
|
|
81
|
+
itemVisibilityStore,
|
|
82
|
+
loop
|
|
83
|
+
}), [createItemStyle, data, globalInterpolation, itemHeight, itemWidth, itemVisibilityStore, loop]);
|
|
84
|
+
return /*#__PURE__*/React.createElement(InternalContext.Provider, {
|
|
85
|
+
value: contextValue
|
|
86
|
+
}, monitorElement, /*#__PURE__*/React.createElement(ViewabilityTrackerView, {
|
|
87
|
+
enabled: autoplay && !disableSmartAutoplay,
|
|
88
|
+
measurementIntervalMillis: Math.max(3000, autoplayInterval),
|
|
89
|
+
onViewabilityChange: _ref => {
|
|
90
|
+
let {
|
|
91
|
+
visible
|
|
92
|
+
} = _ref;
|
|
93
|
+
|
|
94
|
+
if (visible) {
|
|
95
|
+
autoplayController.resume();
|
|
96
|
+
} else {
|
|
97
|
+
autoplayController.pause();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}, /*#__PURE__*/React.createElement(ScrollViewGesture, {
|
|
101
|
+
autoplayController: autoplayController,
|
|
102
|
+
finalizeAnimation: finalizeAnimation,
|
|
103
|
+
offsetTx: offsetTx,
|
|
104
|
+
scrollEnabled: scrollEnabled,
|
|
105
|
+
startAnimation: startAnimation
|
|
106
|
+
}, /*#__PURE__*/React.createElement(RootView, {
|
|
107
|
+
data: data,
|
|
108
|
+
itemHeight: itemHeight,
|
|
109
|
+
originalData: originalData,
|
|
110
|
+
renderItem: renderItem,
|
|
111
|
+
style: style
|
|
112
|
+
}))));
|
|
113
|
+
});
|
|
114
|
+
export default /*#__PURE__*/memo(Carousel);
|
|
115
|
+
//# sourceMappingURL=Carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","memo","useImperativeHandle","useMemo","useRef","Animated","ViewabilityTrackerView","useAutoplayController","useDimensionChangeReaction","useIndexController","useItemVisibilityStore","useLoopedData","usePagingAnimation","createDefaultItemStyle","createDefaultScrollAnimation","InternalContext","RootView","ScrollViewGesture","Carousel","props","ref","autoplay","autoplayInterval","createItemStyle","createScrollAnimation","data","originalData","disableSmartAutoplay","initialIndex","itemHeight","itemWidth","loop","onIndexChange","renderItem","scrollEnabled","style","windowSize","initialTx","controlledTx","Value","current","offsetTx","currentIndex","getCurrentIndex","lastIndex","monitorElement","numberOfOriginalData","length","itemVisibilityStore","numberOfData","finalizeAnimation","globalInterpolation","startAnimation","autoplayController","enabled","intervalMillis","startPagingAnimation","next","prev","contextValue","Math","max","visible","resume","pause"],"sources":["Carousel.tsx"],"sourcesContent":["import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport ViewabilityTrackerView from '../ViewabilityTrackerView';\nimport type CarouselProps from './CarouselProps';\nimport type { CarouselInstance } from './types';\nimport {\n useAutoplayController,\n useDimensionChangeReaction,\n useIndexController,\n useItemVisibilityStore,\n useLoopedData,\n usePagingAnimation,\n} from './hooks';\nimport { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';\nimport { InternalContext, RootView, ScrollViewGesture } from './components';\n\nconst Carousel = forwardRef<CarouselInstance, CarouselProps>(function Carousel(props, ref) {\n const {\n autoplay = false,\n autoplayInterval = 3000,\n createItemStyle = createDefaultItemStyle,\n createScrollAnimation = createDefaultScrollAnimation,\n data: originalData,\n disableSmartAutoplay = false,\n initialIndex = 0,\n itemHeight,\n itemWidth,\n loop = false,\n onIndexChange,\n renderItem,\n scrollEnabled = true,\n style,\n windowSize = 5,\n } = props;\n\n const data = useLoopedData(originalData, loop);\n\n const initialTx = itemWidth * initialIndex;\n const controlledTx = useRef(new Animated.Value(initialTx)).current;\n const offsetTx = useRef(new Animated.Value(0)).current;\n\n const {\n currentIndex,\n getCurrentIndex,\n lastIndex,\n monitorElement,\n } = useIndexController({\n controlledTx,\n initialIndex,\n itemWidth,\n numberOfOriginalData: originalData.length,\n onIndexChange,\n });\n\n const itemVisibilityStore = useItemVisibilityStore({\n currentIndex,\n numberOfData: data.length,\n windowSize,\n });\n\n const {\n finalizeAnimation,\n globalInterpolation,\n startAnimation,\n } = usePagingAnimation({\n controlledTx,\n createScrollAnimation,\n getCurrentIndex,\n itemWidth,\n lastIndex,\n loop,\n numberOfData: data.length,\n offsetTx,\n });\n\n const autoplayController = useAutoplayController({\n enabled: autoplay,\n intervalMillis: autoplayInterval,\n startPagingAnimation: startAnimation,\n });\n\n useDimensionChangeReaction({\n controlledTx,\n currentIndex,\n itemWidth,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n next: () => startAnimation('next'),\n prev: () => startAnimation('prev'),\n getCurrentIndex,\n }),\n [startAnimation, getCurrentIndex],\n );\n\n const contextValue = useMemo(() => ({\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n }), [\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n ]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n {monitorElement}\n\n <ViewabilityTrackerView\n enabled={autoplay && !disableSmartAutoplay}\n measurementIntervalMillis={Math.max(3000, autoplayInterval)}\n onViewabilityChange={({ visible }) => {\n if (visible) {\n autoplayController.resume();\n } else {\n autoplayController.pause();\n }\n }}\n >\n <ScrollViewGesture\n autoplayController={autoplayController}\n finalizeAnimation={finalizeAnimation}\n offsetTx={offsetTx}\n scrollEnabled={scrollEnabled}\n startAnimation={startAnimation}\n >\n <RootView\n data={data}\n itemHeight={itemHeight}\n originalData={originalData}\n renderItem={renderItem}\n style={style}\n />\n </ScrollViewGesture>\n </ViewabilityTrackerView>\n </InternalContext.Provider>\n );\n});\n\nexport default memo(Carousel);\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,IAA5B,EAAkCC,mBAAlC,EAAuDC,OAAvD,EAAgEC,MAAhE,QAA8E,OAA9E;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAGA,SACIC,qBADJ,EAEIC,0BAFJ,EAGIC,kBAHJ,EAIIC,sBAJJ,EAKIC,aALJ,EAMIC,kBANJ,QAOO,SAPP;AAQA,SAASC,sBAAT,EAAiCC,4BAAjC,QAAqE,aAArE;AACA,SAASC,eAAT,EAA0BC,QAA1B,EAAoCC,iBAApC,QAA6D,cAA7D;AAEA,MAAMC,QAAQ,gBAAGlB,UAAU,CAAkC,SAASkB,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EACvF,MAAM;IACFC,QAAQ,GAAG,KADT;IAEFC,gBAAgB,GAAG,IAFjB;IAGFC,eAAe,GAAGV,sBAHhB;IAIFW,qBAAqB,GAAGV,4BAJtB;IAKFW,IAAI,EAAEC,YALJ;IAMFC,oBAAoB,GAAG,KANrB;IAOFC,YAAY,GAAG,CAPb;IAQFC,UARE;IASFC,SATE;IAUFC,IAAI,GAAG,KAVL;IAWFC,aAXE;IAYFC,UAZE;IAaFC,aAAa,GAAG,IAbd;IAcFC,KAdE;IAeFC,UAAU,GAAG;EAfX,IAgBFjB,KAhBJ;EAkBA,MAAMM,IAAI,GAAGd,aAAa,CAACe,YAAD,EAAeK,IAAf,CAA1B;EAEA,MAAMM,SAAS,GAAGP,SAAS,GAAGF,YAA9B;EACA,MAAMU,YAAY,GAAGlC,MAAM,CAAC,IAAIC,QAAQ,CAACkC,KAAb,CAAmBF,SAAnB,CAAD,CAAN,CAAsCG,OAA3D;EACA,MAAMC,QAAQ,GAAGrC,MAAM,CAAC,IAAIC,QAAQ,CAACkC,KAAb,CAAmB,CAAnB,CAAD,CAAN,CAA8BC,OAA/C;EAEA,MAAM;IACFE,YADE;IAEFC,eAFE;IAGFC,SAHE;IAIFC;EAJE,IAKFpC,kBAAkB,CAAC;IACnB6B,YADmB;IAEnBV,YAFmB;IAGnBE,SAHmB;IAInBgB,oBAAoB,EAAEpB,YAAY,CAACqB,MAJhB;IAKnBf;EALmB,CAAD,CALtB;EAaA,MAAMgB,mBAAmB,GAAGtC,sBAAsB,CAAC;IAC/CgC,YAD+C;IAE/CO,YAAY,EAAExB,IAAI,CAACsB,MAF4B;IAG/CX;EAH+C,CAAD,CAAlD;EAMA,MAAM;IACFc,iBADE;IAEFC,mBAFE;IAGFC;EAHE,IAIFxC,kBAAkB,CAAC;IACnB0B,YADmB;IAEnBd,qBAFmB;IAGnBmB,eAHmB;IAInBb,SAJmB;IAKnBc,SALmB;IAMnBb,IANmB;IAOnBkB,YAAY,EAAExB,IAAI,CAACsB,MAPA;IAQnBN;EARmB,CAAD,CAJtB;EAeA,MAAMY,kBAAkB,GAAG9C,qBAAqB,CAAC;IAC7C+C,OAAO,EAAEjC,QADoC;IAE7CkC,cAAc,EAAEjC,gBAF6B;IAG7CkC,oBAAoB,EAAEJ;EAHuB,CAAD,CAAhD;EAMA5C,0BAA0B,CAAC;IACvB8B,YADuB;IAEvBI,YAFuB;IAGvBZ;EAHuB,CAAD,CAA1B;EAMA5B,mBAAmB,CACfkB,GADe,EAEf,OAAO;IACHqC,IAAI,EAAE,MAAML,cAAc,CAAC,MAAD,CADvB;IAEHM,IAAI,EAAE,MAAMN,cAAc,CAAC,MAAD,CAFvB;IAGHT;EAHG,CAAP,CAFe,EAOf,CAACS,cAAD,EAAiBT,eAAjB,CAPe,CAAnB;EAUA,MAAMgB,YAAY,GAAGxD,OAAO,CAAC,OAAO;IAChCoB,eADgC;IAEhCE,IAFgC;IAGhC0B,mBAHgC;IAIhCtB,UAJgC;IAKhCC,SALgC;IAMhCkB,mBANgC;IAOhCjB;EAPgC,CAAP,CAAD,EAQxB,CACAR,eADA,EAEAE,IAFA,EAGA0B,mBAHA,EAIAtB,UAJA,EAKAC,SALA,EAMAkB,mBANA,EAOAjB,IAPA,CARwB,CAA5B;EAkBA,oBACI,oBAAC,eAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAE4B;EAAjC,GACKd,cADL,eAGI,oBAAC,sBAAD;IACI,OAAO,EAAExB,QAAQ,IAAI,CAACM,oBAD1B;IAEI,yBAAyB,EAAEiC,IAAI,CAACC,GAAL,CAAS,IAAT,EAAevC,gBAAf,CAF/B;IAGI,mBAAmB,EAAE,QAAiB;MAAA,IAAhB;QAAEwC;MAAF,CAAgB;;MAClC,IAAIA,OAAJ,EAAa;QACTT,kBAAkB,CAACU,MAAnB;MACH,CAFD,MAEO;QACHV,kBAAkB,CAACW,KAAnB;MACH;IACJ;EATL,gBAWI,oBAAC,iBAAD;IACI,kBAAkB,EAAEX,kBADxB;IAEI,iBAAiB,EAAEH,iBAFvB;IAGI,QAAQ,EAAET,QAHd;IAII,aAAa,EAAEP,aAJnB;IAKI,cAAc,EAAEkB;EALpB,gBAOI,oBAAC,QAAD;IACI,IAAI,EAAE3B,IADV;IAEI,UAAU,EAAEI,UAFhB;IAGI,YAAY,EAAEH,YAHlB;IAII,UAAU,EAAEO,UAJhB;IAKI,KAAK,EAAEE;EALX,EAPJ,CAXJ,CAHJ,CADJ;AAiCH,CApI0B,CAA3B;AAsIA,4BAAelC,IAAI,CAACiB,QAAD,CAAnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type { CarouselInstance, CreateItemStyle, CreateScrollAnimation, RenderItem } from './types';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n ref?: RefObject<CarouselInstance>;\n\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * The item style creator function.\n * @default createDefaultItemStyle\n */\n createItemStyle?: CreateItemStyle;\n\n /**\n * The scroll animation creator function.\n * @default createDefaultScrollAnimation\n */\n createScrollAnimation?: CreateScrollAnimation;\n\n /**\n * Data for render items.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * If `true`, carousel will detect its own viewability and control autoplay automatically.\n * @default false\n */\n disableSmartAutoplay?: boolean;\n\n /**\n * Index of initial item that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * The item width.\n */\n itemHeight: number;\n\n /**\n * The item width.\n */\n itemWidth: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n loop?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onIndexChange?: (newIndex: number) => void;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: RenderItem<ItemT>;\n\n /**\n * Whether to enable scroll gesture.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * The maximum number of items that can respond to pan gesture events.\n * Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)\n * 0 means all items will respond to pan gesture events.\n * @default 5\n */\n windowSize?: number;\n}> {}\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["itemInterpolationInputRange"],"sources":["animationUtils.ts"],"sourcesContent":["export const itemInterpolationInputRange = [-1, 0, 1];\n"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,GAAG,CAAC,CAAC,CAAF,EAAK,CAAL,EAAQ,CAAR,CAApC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["normalItemStyleFactory"],"sources":["createDefaultItemStyle.ts"],"sourcesContent":["import normalItemStyleFactory from './normalItemStyleFactory';\n\nexport default normalItemStyleFactory();\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,0BAAnC;AAEA,eAAeA,sBAAsB,EAArC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Animated, Easing } from 'react-native';
|
|
2
|
+
export default function createDefaultScrollAnimation(animatedValue, toValue) {
|
|
3
|
+
return Animated.timing(animatedValue, {
|
|
4
|
+
toValue: toValue,
|
|
5
|
+
duration: 350,
|
|
6
|
+
easing: Easing.bezier(0.25, 1, 0.5, 1),
|
|
7
|
+
useNativeDriver: true
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
;
|
|
11
|
+
//# sourceMappingURL=createDefaultScrollAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Animated","Easing","createDefaultScrollAnimation","animatedValue","toValue","timing","duration","easing","bezier","useNativeDriver"],"sources":["createDefaultScrollAnimation.ts"],"sourcesContent":["import { Animated, Easing } from 'react-native';\n\nexport default function createDefaultScrollAnimation(\n animatedValue: Animated.Value,\n toValue: number,\n): Animated.CompositeAnimation {\n return Animated.timing(animatedValue, {\n toValue: toValue,\n duration: 350,\n easing: Easing.bezier(0.25, 1, 0.5, 1),\n useNativeDriver: true,\n });\n};\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,MAAnB,QAAiC,cAAjC;AAEA,eAAe,SAASC,4BAAT,CACXC,aADW,EAEXC,OAFW,EAGgB;EAC3B,OAAOJ,QAAQ,CAACK,MAAT,CAAgBF,aAAhB,EAA+B;IAClCC,OAAO,EAAEA,OADyB;IAElCE,QAAQ,EAAE,GAFwB;IAGlCC,MAAM,EAAEN,MAAM,CAACO,MAAP,CAAc,IAAd,EAAoB,CAApB,EAAuB,GAAvB,EAA4B,CAA5B,CAH0B;IAIlCC,eAAe,EAAE;EAJiB,CAA/B,CAAP;AAMH;AAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as createDefaultItemStyle } from './createDefaultItemStyle';
|
|
2
|
+
export { default as createDefaultScrollAnimation } from './createDefaultScrollAnimation';
|
|
3
|
+
export { default as normalItemStyleFactory } from './normalItemStyleFactory';
|
|
4
|
+
export { default as parallaxItemStyleFactory } from './parallaxItemStyleFactory';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","createDefaultItemStyle","createDefaultScrollAnimation","normalItemStyleFactory","parallaxItemStyleFactory"],"sources":["index.ts"],"sourcesContent":["export { default as createDefaultItemStyle } from './createDefaultItemStyle';\nexport { default as createDefaultScrollAnimation } from './createDefaultScrollAnimation';\nexport { default as normalItemStyleFactory } from './normalItemStyleFactory';\nexport { default as parallaxItemStyleFactory } from './parallaxItemStyleFactory';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,sBAApB,QAAkD,0BAAlD;AACA,SAASD,OAAO,IAAIE,4BAApB,QAAwD,gCAAxD;AACA,SAASF,OAAO,IAAIG,sBAApB,QAAkD,0BAAlD;AACA,SAASH,OAAO,IAAII,wBAApB,QAAoD,4BAApD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { itemInterpolationInputRange } from './animationUtils';
|
|
2
|
+
export default function normalItemStyleFactory() {
|
|
3
|
+
const createItemStyle = (itemInterpolation, itemWidth) => {
|
|
4
|
+
const translate = itemInterpolation.interpolate({
|
|
5
|
+
inputRange: itemInterpolationInputRange,
|
|
6
|
+
outputRange: [-itemWidth, 0, itemWidth]
|
|
7
|
+
});
|
|
8
|
+
return {
|
|
9
|
+
transform: [{
|
|
10
|
+
translateX: translate
|
|
11
|
+
}]
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return createItemStyle;
|
|
16
|
+
}
|
|
17
|
+
;
|
|
18
|
+
//# sourceMappingURL=normalItemStyleFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["itemInterpolationInputRange","normalItemStyleFactory","createItemStyle","itemInterpolation","itemWidth","translate","interpolate","inputRange","outputRange","transform","translateX"],"sources":["normalItemStyleFactory.ts"],"sourcesContent":["import type { CreateItemStyle } from '../types';\nimport { itemInterpolationInputRange } from './animationUtils';\n\nexport default function normalItemStyleFactory() {\n const createItemStyle: CreateItemStyle = (itemInterpolation, itemWidth) => {\n const translate = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n -itemWidth,\n 0,\n itemWidth,\n ],\n });\n\n return { transform: [{ translateX: translate }] };\n };\n\n return createItemStyle;\n};\n"],"mappings":"AACA,SAASA,2BAAT,QAA4C,kBAA5C;AAEA,eAAe,SAASC,sBAAT,GAAkC;EAC7C,MAAMC,eAAgC,GAAG,CAACC,iBAAD,EAAoBC,SAApB,KAAkC;IACvE,MAAMC,SAAS,GAAGF,iBAAiB,CAACG,WAAlB,CAA8B;MAC5CC,UAAU,EAAEP,2BADgC;MAE5CQ,WAAW,EAAE,CACT,CAACJ,SADQ,EAET,CAFS,EAGTA,SAHS;IAF+B,CAA9B,CAAlB;IASA,OAAO;MAAEK,SAAS,EAAE,CAAC;QAAEC,UAAU,EAAEL;MAAd,CAAD;IAAb,CAAP;EACH,CAXD;;EAaA,OAAOH,eAAP;AACH;AAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { itemInterpolationInputRange } from './animationUtils';
|
|
2
|
+
const defaultParallaxAnimationConfig = {
|
|
3
|
+
parallaxActiveItemScale: 0.9,
|
|
4
|
+
parallaxActiveItemOpacity: 1,
|
|
5
|
+
parallaxAdjacentItemScale: Math.pow(0.9, 2),
|
|
6
|
+
parallaxAdjacentItemOpacity: 0.5,
|
|
7
|
+
parallaxScrollingOffset: 50
|
|
8
|
+
};
|
|
9
|
+
export default function parallaxItemStyleFactory() {
|
|
10
|
+
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultParallaxAnimationConfig;
|
|
11
|
+
const {
|
|
12
|
+
parallaxActiveItemScale,
|
|
13
|
+
parallaxActiveItemOpacity,
|
|
14
|
+
parallaxAdjacentItemOpacity,
|
|
15
|
+
parallaxAdjacentItemScale,
|
|
16
|
+
parallaxScrollingOffset
|
|
17
|
+
} = { ...config,
|
|
18
|
+
...defaultParallaxAnimationConfig
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const createItemStyle = (itemInterpolation, itemWidth) => {
|
|
22
|
+
const translate = itemInterpolation.interpolate({
|
|
23
|
+
inputRange: itemInterpolationInputRange,
|
|
24
|
+
outputRange: [-itemWidth + parallaxScrollingOffset, 0, itemWidth - parallaxScrollingOffset]
|
|
25
|
+
});
|
|
26
|
+
const zIndex = itemInterpolation.interpolate({
|
|
27
|
+
inputRange: itemInterpolationInputRange,
|
|
28
|
+
outputRange: [0, itemWidth, 0],
|
|
29
|
+
extrapolate: 'clamp'
|
|
30
|
+
});
|
|
31
|
+
const scale = itemInterpolation.interpolate({
|
|
32
|
+
inputRange: itemInterpolationInputRange,
|
|
33
|
+
outputRange: [parallaxAdjacentItemScale, parallaxActiveItemScale, parallaxAdjacentItemScale],
|
|
34
|
+
extrapolate: 'clamp'
|
|
35
|
+
});
|
|
36
|
+
const opacity = itemInterpolation.interpolate({
|
|
37
|
+
inputRange: itemInterpolationInputRange,
|
|
38
|
+
outputRange: [parallaxAdjacentItemOpacity, parallaxActiveItemOpacity, parallaxAdjacentItemOpacity],
|
|
39
|
+
extrapolate: 'clamp'
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
transform: [{
|
|
43
|
+
translateX: translate
|
|
44
|
+
}, {
|
|
45
|
+
scale
|
|
46
|
+
}],
|
|
47
|
+
zIndex,
|
|
48
|
+
opacity
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return createItemStyle;
|
|
53
|
+
}
|
|
54
|
+
;
|
|
55
|
+
//# sourceMappingURL=parallaxItemStyleFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["itemInterpolationInputRange","defaultParallaxAnimationConfig","parallaxActiveItemScale","parallaxActiveItemOpacity","parallaxAdjacentItemScale","Math","pow","parallaxAdjacentItemOpacity","parallaxScrollingOffset","parallaxItemStyleFactory","config","createItemStyle","itemInterpolation","itemWidth","translate","interpolate","inputRange","outputRange","zIndex","extrapolate","scale","opacity","transform","translateX"],"sources":["parallaxItemStyleFactory.ts"],"sourcesContent":["import type { CreateItemStyle } from '../types';\nimport { itemInterpolationInputRange } from './animationUtils';\n\nexport interface ParallaxAnimationConfig {\n parallaxActiveItemScale?: number;\n parallaxActiveItemOpacity?: number;\n parallaxAdjacentItemScale?: number;\n parallaxAdjacentItemOpacity?: number;\n parallaxScrollingOffset?: number;\n}\n\nconst defaultParallaxAnimationConfig: Required<Readonly<ParallaxAnimationConfig>> = {\n parallaxActiveItemScale: 0.9,\n parallaxActiveItemOpacity: 1,\n parallaxAdjacentItemScale: Math.pow(0.9, 2),\n parallaxAdjacentItemOpacity: 0.5,\n parallaxScrollingOffset: 50,\n};\n\nexport default function parallaxItemStyleFactory(config: ParallaxAnimationConfig = defaultParallaxAnimationConfig) {\n const {\n parallaxActiveItemScale,\n parallaxActiveItemOpacity,\n parallaxAdjacentItemOpacity,\n parallaxAdjacentItemScale,\n parallaxScrollingOffset,\n }: Required<ParallaxAnimationConfig> = {\n ...config,\n ...defaultParallaxAnimationConfig,\n };\n\n const createItemStyle: CreateItemStyle = (itemInterpolation, itemWidth) => {\n const translate = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n -itemWidth + parallaxScrollingOffset,\n 0,\n itemWidth - parallaxScrollingOffset,\n ],\n });\n\n const zIndex = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [0, itemWidth, 0],\n extrapolate: 'clamp',\n });\n\n const scale = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n parallaxAdjacentItemScale,\n parallaxActiveItemScale,\n parallaxAdjacentItemScale,\n ],\n extrapolate: 'clamp',\n });\n\n const opacity = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n parallaxAdjacentItemOpacity,\n parallaxActiveItemOpacity,\n parallaxAdjacentItemOpacity,\n ],\n extrapolate: 'clamp',\n });\n\n return {\n transform: [\n { translateX: translate },\n { scale },\n ],\n zIndex,\n opacity,\n };\n };\n\n return createItemStyle;\n};\n"],"mappings":"AACA,SAASA,2BAAT,QAA4C,kBAA5C;AAUA,MAAMC,8BAA2E,GAAG;EAChFC,uBAAuB,EAAE,GADuD;EAEhFC,yBAAyB,EAAE,CAFqD;EAGhFC,yBAAyB,EAAEC,IAAI,CAACC,GAAL,CAAS,GAAT,EAAc,CAAd,CAHqD;EAIhFC,2BAA2B,EAAE,GAJmD;EAKhFC,uBAAuB,EAAE;AALuD,CAApF;AAQA,eAAe,SAASC,wBAAT,GAAoG;EAAA,IAAlEC,MAAkE,uEAAhCT,8BAAgC;EAC/G,MAAM;IACFC,uBADE;IAEFC,yBAFE;IAGFI,2BAHE;IAIFH,yBAJE;IAKFI;EALE,IAMiC,EACnC,GAAGE,MADgC;IAEnC,GAAGT;EAFgC,CANvC;;EAWA,MAAMU,eAAgC,GAAG,CAACC,iBAAD,EAAoBC,SAApB,KAAkC;IACvE,MAAMC,SAAS,GAAGF,iBAAiB,CAACG,WAAlB,CAA8B;MAC5CC,UAAU,EAAEhB,2BADgC;MAE5CiB,WAAW,EAAE,CACT,CAACJ,SAAD,GAAaL,uBADJ,EAET,CAFS,EAGTK,SAAS,GAAGL,uBAHH;IAF+B,CAA9B,CAAlB;IASA,MAAMU,MAAM,GAAGN,iBAAiB,CAACG,WAAlB,CAA8B;MACzCC,UAAU,EAAEhB,2BAD6B;MAEzCiB,WAAW,EAAE,CAAC,CAAD,EAAIJ,SAAJ,EAAe,CAAf,CAF4B;MAGzCM,WAAW,EAAE;IAH4B,CAA9B,CAAf;IAMA,MAAMC,KAAK,GAAGR,iBAAiB,CAACG,WAAlB,CAA8B;MACxCC,UAAU,EAAEhB,2BAD4B;MAExCiB,WAAW,EAAE,CACTb,yBADS,EAETF,uBAFS,EAGTE,yBAHS,CAF2B;MAOxCe,WAAW,EAAE;IAP2B,CAA9B,CAAd;IAUA,MAAME,OAAO,GAAGT,iBAAiB,CAACG,WAAlB,CAA8B;MAC1CC,UAAU,EAAEhB,2BAD8B;MAE1CiB,WAAW,EAAE,CACTV,2BADS,EAETJ,yBAFS,EAGTI,2BAHS,CAF6B;MAO1CY,WAAW,EAAE;IAP6B,CAA9B,CAAhB;IAUA,OAAO;MACHG,SAAS,EAAE,CACP;QAAEC,UAAU,EAAET;MAAd,CADO,EAEP;QAAEM;MAAF,CAFO,CADR;MAKHF,MALG;MAMHG;IANG,CAAP;EAQH,CA5CD;;EA8CA,OAAOV,eAAP;AACH;AAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
const mockItemVisibilityStore = {
|
|
4
|
+
dispatch: () => void 0,
|
|
5
|
+
subscribe: () => () => void 0,
|
|
6
|
+
removeAllListeners: () => void 0
|
|
7
|
+
};
|
|
8
|
+
const initialValue = {
|
|
9
|
+
createItemStyle: () => ({}),
|
|
10
|
+
data: [],
|
|
11
|
+
globalInterpolation: Animated.add(new Animated.Value(0), 0),
|
|
12
|
+
itemHeight: 0,
|
|
13
|
+
itemWidth: 0,
|
|
14
|
+
itemVisibilityStore: mockItemVisibilityStore,
|
|
15
|
+
loop: false
|
|
16
|
+
};
|
|
17
|
+
const InternalContext = /*#__PURE__*/createContext(initialValue);
|
|
18
|
+
export default InternalContext;
|
|
19
|
+
//# sourceMappingURL=InternalContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","Animated","mockItemVisibilityStore","dispatch","subscribe","removeAllListeners","initialValue","createItemStyle","data","globalInterpolation","add","Value","itemHeight","itemWidth","itemVisibilityStore","loop","InternalContext"],"sources":["InternalContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\nimport type { CreateItemStyle, ItemVisibilityStore } from '../types';\n\nexport interface InternalContextValue<ItemT> {\n createItemStyle: CreateItemStyle;\n data: ReadonlyArray<ItemT>;\n globalInterpolation: Animated.AnimatedInterpolation;\n itemHeight: number;\n itemWidth: number;\n itemVisibilityStore: ItemVisibilityStore;\n loop: boolean;\n}\n\nconst mockItemVisibilityStore: ItemVisibilityStore = {\n dispatch: () => void 0,\n subscribe: () => () => void 0,\n removeAllListeners: () => void 0,\n};\n\nconst initialValue: Readonly<InternalContextValue<any>> = {\n createItemStyle: () => ({}),\n data: [],\n globalInterpolation: Animated.add(new Animated.Value(0), 0),\n itemHeight: 0,\n itemWidth: 0,\n itemVisibilityStore: mockItemVisibilityStore,\n loop: false,\n};\n\nconst InternalContext = createContext<InternalContextValue<any>>(initialValue);\n\nexport default InternalContext;\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAaA,MAAMC,uBAA4C,GAAG;EACjDC,QAAQ,EAAE,MAAM,KAAK,CAD4B;EAEjDC,SAAS,EAAE,MAAM,MAAM,KAAK,CAFqB;EAGjDC,kBAAkB,EAAE,MAAM,KAAK;AAHkB,CAArD;AAMA,MAAMC,YAAiD,GAAG;EACtDC,eAAe,EAAE,OAAO,EAAP,CADqC;EAEtDC,IAAI,EAAE,EAFgD;EAGtDC,mBAAmB,EAAER,QAAQ,CAACS,GAAT,CAAa,IAAIT,QAAQ,CAACU,KAAb,CAAmB,CAAnB,CAAb,EAAoC,CAApC,CAHiC;EAItDC,UAAU,EAAE,CAJ0C;EAKtDC,SAAS,EAAE,CAL2C;EAMtDC,mBAAmB,EAAEZ,uBANiC;EAOtDa,IAAI,EAAE;AAPgD,CAA1D;AAUA,MAAMC,eAAe,gBAAGhB,aAAa,CAA4BM,YAA5B,CAArC;AAEA,eAAeU,eAAf"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import { StyleSheet } from '@fountain-ui/core';
|
|
4
|
+
import { useItemInterpolation } from '../hooks';
|
|
5
|
+
import InternalContext from './InternalContext';
|
|
6
|
+
export default function ItemView(props) {
|
|
7
|
+
const {
|
|
8
|
+
children,
|
|
9
|
+
index
|
|
10
|
+
} = props;
|
|
11
|
+
const {
|
|
12
|
+
createItemStyle,
|
|
13
|
+
itemHeight,
|
|
14
|
+
itemWidth,
|
|
15
|
+
itemVisibilityStore
|
|
16
|
+
} = useContext(InternalContext);
|
|
17
|
+
const [visible, setVisible] = useState(false);
|
|
18
|
+
const interpolation = useItemInterpolation(index);
|
|
19
|
+
const itemStyle = useMemo(() => createItemStyle(interpolation, itemWidth), [createItemStyle, interpolation]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
return itemVisibilityStore.subscribe(ranges => {
|
|
22
|
+
const nextVisible = ranges.some(_ref => {
|
|
23
|
+
let [from, to] = _ref;
|
|
24
|
+
return index >= from && index <= to;
|
|
25
|
+
});
|
|
26
|
+
setVisible(nextVisible);
|
|
27
|
+
});
|
|
28
|
+
}, [itemVisibilityStore]);
|
|
29
|
+
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
30
|
+
children: visible ? children(interpolation) : null,
|
|
31
|
+
style: [{
|
|
32
|
+
width: itemWidth,
|
|
33
|
+
height: itemHeight
|
|
34
|
+
}, styles.absolute, // @ts-ignore
|
|
35
|
+
itemStyle]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
;
|
|
39
|
+
const styles = StyleSheet.create({
|
|
40
|
+
absolute: {
|
|
41
|
+
position: 'absolute'
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=ItemView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useContext","useEffect","useMemo","useState","Animated","StyleSheet","useItemInterpolation","InternalContext","ItemView","props","children","index","createItemStyle","itemHeight","itemWidth","itemVisibilityStore","visible","setVisible","interpolation","itemStyle","subscribe","ranges","nextVisible","some","from","to","width","height","styles","absolute","create","position"],"sources":["ItemView.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport { useItemInterpolation } from '../hooks';\nimport InternalContext from './InternalContext';\n\nexport interface ItemViewProps {\n children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;\n index: number;\n}\n\nexport default function ItemView(props: ItemViewProps) {\n const { children, index } = props;\n\n const {\n createItemStyle,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n } = useContext(InternalContext);\n\n const [visible, setVisible] = useState(false);\n\n const interpolation = useItemInterpolation(index);\n\n const itemStyle = useMemo(\n () => createItemStyle(interpolation, itemWidth),\n [createItemStyle, interpolation],\n );\n\n useEffect(() => {\n return itemVisibilityStore.subscribe(ranges => {\n const nextVisible = ranges.some(([from, to]) => index >= from && index <= to);\n setVisible(nextVisible);\n });\n }, [itemVisibilityStore]);\n\n return (\n <Animated.View\n children={visible ? children(interpolation) : null}\n style={[\n { width: itemWidth, height: itemHeight },\n styles.absolute,\n // @ts-ignore\n itemStyle,\n ]}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: 'absolute',\n },\n});\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,SAA5B,EAAuCC,OAAvC,EAAgDC,QAAhD,QAAgE,OAAhE;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,SAASC,oBAAT,QAAqC,UAArC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAOA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;EACnD,MAAM;IAAEC,QAAF;IAAYC;EAAZ,IAAsBF,KAA5B;EAEA,MAAM;IACFG,eADE;IAEFC,UAFE;IAGFC,SAHE;IAIFC;EAJE,IAKFf,UAAU,CAACO,eAAD,CALd;EAOA,MAAM,CAACS,OAAD,EAAUC,UAAV,IAAwBd,QAAQ,CAAC,KAAD,CAAtC;EAEA,MAAMe,aAAa,GAAGZ,oBAAoB,CAACK,KAAD,CAA1C;EAEA,MAAMQ,SAAS,GAAGjB,OAAO,CACrB,MAAMU,eAAe,CAACM,aAAD,EAAgBJ,SAAhB,CADA,EAErB,CAACF,eAAD,EAAkBM,aAAlB,CAFqB,CAAzB;EAKAjB,SAAS,CAAC,MAAM;IACZ,OAAOc,mBAAmB,CAACK,SAApB,CAA8BC,MAAM,IAAI;MAC3C,MAAMC,WAAW,GAAGD,MAAM,CAACE,IAAP,CAAY;QAAA,IAAC,CAACC,IAAD,EAAOC,EAAP,CAAD;QAAA,OAAgBd,KAAK,IAAIa,IAAT,IAAiBb,KAAK,IAAIc,EAA1C;MAAA,CAAZ,CAApB;MACAR,UAAU,CAACK,WAAD,CAAV;IACH,CAHM,CAAP;EAIH,CALQ,EAKN,CAACP,mBAAD,CALM,CAAT;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,QAAQ,EAAEC,OAAO,GAAGN,QAAQ,CAACQ,aAAD,CAAX,GAA6B,IADlD;IAEI,KAAK,EAAE,CACH;MAAEQ,KAAK,EAAEZ,SAAT;MAAoBa,MAAM,EAAEd;IAA5B,CADG,EAEHe,MAAM,CAACC,QAFJ,EAGH;IACAV,SAJG;EAFX,EADJ;AAWH;AAAA;AAED,MAAMS,MAAM,GAAGvB,UAAU,CAACyB,MAAX,CAAkB;EAC7BD,QAAQ,EAAE;IACNE,QAAQ,EAAE;EADJ;AADmB,CAAlB,CAAf"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React, { memo, forwardRef } from 'react';
|
|
4
|
+
import { Animated } from 'react-native';
|
|
5
|
+
import { StyleSheet } from '@fountain-ui/core';
|
|
6
|
+
import ItemView from './ItemView';
|
|
7
|
+
const styles = StyleSheet.create({
|
|
8
|
+
root: {
|
|
9
|
+
width: '100%',
|
|
10
|
+
justifyContent: 'center'
|
|
11
|
+
},
|
|
12
|
+
horizontal: {
|
|
13
|
+
flexDirection: 'row',
|
|
14
|
+
overflow: 'hidden'
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const RootView = /*#__PURE__*/forwardRef(function RootView(props, ref) {
|
|
18
|
+
const {
|
|
19
|
+
data,
|
|
20
|
+
itemHeight,
|
|
21
|
+
originalData,
|
|
22
|
+
renderItem,
|
|
23
|
+
style,
|
|
24
|
+
...otherProps
|
|
25
|
+
} = props;
|
|
26
|
+
|
|
27
|
+
const renderItemView = (item, index) => /*#__PURE__*/React.createElement(ItemView, {
|
|
28
|
+
key: index,
|
|
29
|
+
index: index
|
|
30
|
+
}, interpolation => renderItem({
|
|
31
|
+
item,
|
|
32
|
+
index: index % originalData.length,
|
|
33
|
+
interpolation
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
const viewStyles = [styles.root, styles.horizontal, {
|
|
37
|
+
height: itemHeight
|
|
38
|
+
}, style];
|
|
39
|
+
return /*#__PURE__*/React.createElement(Animated.View, _extends({
|
|
40
|
+
ref: ref
|
|
41
|
+
}, otherProps, {
|
|
42
|
+
children: data.map(renderItemView),
|
|
43
|
+
style: viewStyles
|
|
44
|
+
}));
|
|
45
|
+
});
|
|
46
|
+
export default /*#__PURE__*/memo(RootView);
|
|
47
|
+
//# sourceMappingURL=RootView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","memo","forwardRef","Animated","StyleSheet","ItemView","styles","create","root","width","justifyContent","horizontal","flexDirection","overflow","RootView","props","ref","data","itemHeight","originalData","renderItem","style","otherProps","renderItemView","item","index","interpolation","length","viewStyles","height","map"],"sources":["RootView.tsx"],"sourcesContent":["import React, { memo, ReactElement, forwardRef } from 'react';\nimport type { ViewProps, View } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type { RenderItem } from '../types';\nimport ItemView from './ItemView';\n\nconst styles = StyleSheet.create({\n root: {\n width: '100%',\n justifyContent: 'center',\n },\n horizontal: {\n flexDirection: 'row',\n overflow: 'hidden',\n },\n});\n\nexport type RootViewProps<ItemT> = ViewProps & {\n data: ReadonlyArray<ItemT>;\n itemHeight: number;\n originalData: ReadonlyArray<ItemT>;\n renderItem: RenderItem<ItemT>;\n};\n\nconst RootView = forwardRef<View, RootViewProps<any>>(function RootView(props, ref) {\n const {\n data,\n itemHeight,\n originalData,\n renderItem,\n style,\n ...otherProps\n } = props;\n\n const renderItemView = (item: any, index: number): ReactElement => (\n <ItemView\n key={index}\n index={index}\n >\n {(interpolation) => renderItem({\n item,\n index: index % originalData.length,\n interpolation,\n })}\n </ItemView>\n );\n\n const viewStyles = [\n styles.root,\n styles.horizontal,\n { height: itemHeight },\n style,\n ];\n\n return (\n <Animated.View\n ref={ref}\n {...otherProps}\n children={data.map(renderItemView)}\n style={viewStyles}\n />\n );\n});\n\nexport default memo(RootView);\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,IAAhB,EAAoCC,UAApC,QAAsD,OAAtD;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA,OAAOC,QAAP,MAAqB,YAArB;AAEA,MAAMC,MAAM,GAAGF,UAAU,CAACG,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,KAAK,EAAE,MADL;IAEFC,cAAc,EAAE;EAFd,CADuB;EAK7BC,UAAU,EAAE;IACRC,aAAa,EAAE,KADP;IAERC,QAAQ,EAAE;EAFF;AALiB,CAAlB,CAAf;AAkBA,MAAMC,QAAQ,gBAAGZ,UAAU,CAA2B,SAASY,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EAChF,MAAM;IACFC,IADE;IAEFC,UAFE;IAGFC,YAHE;IAIFC,UAJE;IAKFC,KALE;IAMF,GAAGC;EAND,IAOFP,KAPJ;;EASA,MAAMQ,cAAc,GAAG,CAACC,IAAD,EAAYC,KAAZ,kBACnB,oBAAC,QAAD;IACI,GAAG,EAAEA,KADT;IAEI,KAAK,EAAEA;EAFX,GAIMC,aAAD,IAAmBN,UAAU,CAAC;IAC3BI,IAD2B;IAE3BC,KAAK,EAAEA,KAAK,GAAGN,YAAY,CAACQ,MAFD;IAG3BD;EAH2B,CAAD,CAJlC,CADJ;;EAaA,MAAME,UAAU,GAAG,CACftB,MAAM,CAACE,IADQ,EAEfF,MAAM,CAACK,UAFQ,EAGf;IAAEkB,MAAM,EAAEX;EAAV,CAHe,EAIfG,KAJe,CAAnB;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,GAAG,EAAEL;EADT,GAEQM,UAFR;IAGI,QAAQ,EAAEL,IAAI,CAACa,GAAL,CAASP,cAAT,CAHd;IAII,KAAK,EAAEK;EAJX,GADJ;AAQH,CAtC0B,CAA3B;AAwCA,4BAAe3B,IAAI,CAACa,QAAD,CAAnB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import { PanGestureHandler, State as GestureHandlerState } from 'react-native-gesture-handler';
|
|
4
|
+
const SCROLL_TO_ADJACENT_TX_THRESHOLD = 60;
|
|
5
|
+
const SCROLL_TO_ADJACENT_VX_THRESHOLD = 500;
|
|
6
|
+
const ACTIVE_OFFSET_ABS_X = 5;
|
|
7
|
+
const activeOffsetX = [-ACTIVE_OFFSET_ABS_X, ACTIVE_OFFSET_ABS_X];
|
|
8
|
+
const endAnimationStates = [GestureHandlerState.CANCELLED, GestureHandlerState.END];
|
|
9
|
+
|
|
10
|
+
function shouldScrollToAdjacent(translationX, velocityX) {
|
|
11
|
+
return Math.abs(translationX) >= SCROLL_TO_ADJACENT_TX_THRESHOLD || Math.abs(velocityX) >= SCROLL_TO_ADJACENT_VX_THRESHOLD;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function ScrollViewGesture(props) {
|
|
15
|
+
const {
|
|
16
|
+
autoplayController,
|
|
17
|
+
children,
|
|
18
|
+
finalizeAnimation,
|
|
19
|
+
offsetTx,
|
|
20
|
+
scrollEnabled,
|
|
21
|
+
startAnimation
|
|
22
|
+
} = props;
|
|
23
|
+
const {
|
|
24
|
+
pause: pauseAutoplay,
|
|
25
|
+
resume: resumeAutoplay
|
|
26
|
+
} = autoplayController;
|
|
27
|
+
const handleGestureBegin = useCallback(() => {
|
|
28
|
+
pauseAutoplay();
|
|
29
|
+
finalizeAnimation();
|
|
30
|
+
}, [finalizeAnimation, pauseAutoplay]);
|
|
31
|
+
const handleGestureEvent = useCallback(Animated.event([{
|
|
32
|
+
nativeEvent: {
|
|
33
|
+
translationX: offsetTx
|
|
34
|
+
}
|
|
35
|
+
}], {
|
|
36
|
+
useNativeDriver: true
|
|
37
|
+
}), []);
|
|
38
|
+
const handleHandlerStateChange = useCallback(event => {
|
|
39
|
+
const {
|
|
40
|
+
nativeEvent: {
|
|
41
|
+
translationX,
|
|
42
|
+
velocityX,
|
|
43
|
+
state
|
|
44
|
+
}
|
|
45
|
+
} = event;
|
|
46
|
+
|
|
47
|
+
if (endAnimationStates.includes(state)) {
|
|
48
|
+
const userDirection = shouldScrollToAdjacent(translationX, velocityX) ? translationX < 0 ? 'next' : 'prev' : 'stay';
|
|
49
|
+
startAnimation(userDirection, true);
|
|
50
|
+
resumeAutoplay();
|
|
51
|
+
}
|
|
52
|
+
}, [startAnimation, resumeAutoplay]);
|
|
53
|
+
return /*#__PURE__*/React.createElement(PanGestureHandler, {
|
|
54
|
+
activeOffsetX: activeOffsetX,
|
|
55
|
+
children: children,
|
|
56
|
+
enabled: scrollEnabled,
|
|
57
|
+
onBegan: handleGestureBegin,
|
|
58
|
+
onGestureEvent: handleGestureEvent,
|
|
59
|
+
onHandlerStateChange: handleHandlerStateChange
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=ScrollViewGesture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","Animated","PanGestureHandler","State","GestureHandlerState","SCROLL_TO_ADJACENT_TX_THRESHOLD","SCROLL_TO_ADJACENT_VX_THRESHOLD","ACTIVE_OFFSET_ABS_X","activeOffsetX","endAnimationStates","CANCELLED","END","shouldScrollToAdjacent","translationX","velocityX","Math","abs","ScrollViewGesture","props","autoplayController","children","finalizeAnimation","offsetTx","scrollEnabled","startAnimation","pause","pauseAutoplay","resume","resumeAutoplay","handleGestureBegin","handleGestureEvent","event","nativeEvent","useNativeDriver","handleHandlerStateChange","state","includes","userDirection"],"sources":["ScrollViewGesture.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport React, { useCallback } from 'react';\nimport { Animated } from 'react-native';\nimport type { PanGestureHandlerStateChangeEvent } from 'react-native-gesture-handler';\nimport { PanGestureHandler, State as GestureHandlerState } from 'react-native-gesture-handler';\nimport type { AutoplayController, PagingDirection, StartPagingAnimation } from '../types';\n\nexport interface ScrollViewGestureProps {\n autoplayController: AutoplayController;\n children: ReactNode;\n finalizeAnimation: () => void;\n offsetTx: Animated.Value,\n scrollEnabled: boolean;\n startAnimation: StartPagingAnimation;\n}\n\nconst SCROLL_TO_ADJACENT_TX_THRESHOLD = 60;\nconst SCROLL_TO_ADJACENT_VX_THRESHOLD = 500;\n\nconst ACTIVE_OFFSET_ABS_X = 5;\nconst activeOffsetX: number[] = [-ACTIVE_OFFSET_ABS_X, ACTIVE_OFFSET_ABS_X];\n\nconst endAnimationStates: Readonly<GestureHandlerState[]> = [\n GestureHandlerState.CANCELLED,\n GestureHandlerState.END,\n];\n\nfunction shouldScrollToAdjacent(translationX: number, velocityX: number): boolean {\n return Math.abs(translationX) >= SCROLL_TO_ADJACENT_TX_THRESHOLD\n || Math.abs(velocityX) >= SCROLL_TO_ADJACENT_VX_THRESHOLD;\n}\n\nexport default function ScrollViewGesture(props: ScrollViewGestureProps) {\n const {\n autoplayController,\n children,\n finalizeAnimation,\n offsetTx,\n scrollEnabled,\n startAnimation,\n } = props;\n\n const { pause: pauseAutoplay, resume: resumeAutoplay } = autoplayController;\n\n const handleGestureBegin = useCallback(() => {\n pauseAutoplay();\n\n finalizeAnimation();\n }, [finalizeAnimation, pauseAutoplay]);\n\n const handleGestureEvent = useCallback(Animated.event(\n [{ nativeEvent: { translationX: offsetTx } }],\n { useNativeDriver: true },\n ), []);\n\n const handleHandlerStateChange = useCallback((event: PanGestureHandlerStateChangeEvent) => {\n const { nativeEvent: { translationX, velocityX, state } } = event;\n\n if (endAnimationStates.includes(state)) {\n const userDirection: PagingDirection = shouldScrollToAdjacent(translationX, velocityX)\n ? (translationX < 0 ? 'next' : 'prev')\n : 'stay';\n\n startAnimation(userDirection, true);\n\n resumeAutoplay();\n }\n }, [startAnimation, resumeAutoplay]);\n\n return (\n <PanGestureHandler\n activeOffsetX={activeOffsetX}\n children={children}\n enabled={scrollEnabled}\n onBegan={handleGestureBegin}\n onGestureEvent={handleGestureEvent}\n onHandlerStateChange={handleHandlerStateChange}\n />\n );\n}\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA,SAASC,iBAAT,EAA4BC,KAAK,IAAIC,mBAArC,QAAgE,8BAAhE;AAYA,MAAMC,+BAA+B,GAAG,EAAxC;AACA,MAAMC,+BAA+B,GAAG,GAAxC;AAEA,MAAMC,mBAAmB,GAAG,CAA5B;AACA,MAAMC,aAAuB,GAAG,CAAC,CAACD,mBAAF,EAAuBA,mBAAvB,CAAhC;AAEA,MAAME,kBAAmD,GAAG,CACxDL,mBAAmB,CAACM,SADoC,EAExDN,mBAAmB,CAACO,GAFoC,CAA5D;;AAKA,SAASC,sBAAT,CAAgCC,YAAhC,EAAsDC,SAAtD,EAAkF;EAC9E,OAAOC,IAAI,CAACC,GAAL,CAASH,YAAT,KAA0BR,+BAA1B,IACAU,IAAI,CAACC,GAAL,CAASF,SAAT,KAAuBR,+BAD9B;AAEH;;AAED,eAAe,SAASW,iBAAT,CAA2BC,KAA3B,EAA0D;EACrE,MAAM;IACFC,kBADE;IAEFC,QAFE;IAGFC,iBAHE;IAIFC,QAJE;IAKFC,aALE;IAMFC;EANE,IAOFN,KAPJ;EASA,MAAM;IAAEO,KAAK,EAAEC,aAAT;IAAwBC,MAAM,EAAEC;EAAhC,IAAmDT,kBAAzD;EAEA,MAAMU,kBAAkB,GAAG7B,WAAW,CAAC,MAAM;IACzC0B,aAAa;IAEbL,iBAAiB;EACpB,CAJqC,EAInC,CAACA,iBAAD,EAAoBK,aAApB,CAJmC,CAAtC;EAMA,MAAMI,kBAAkB,GAAG9B,WAAW,CAACC,QAAQ,CAAC8B,KAAT,CACnC,CAAC;IAAEC,WAAW,EAAE;MAAEnB,YAAY,EAAES;IAAhB;EAAf,CAAD,CADmC,EAEnC;IAAEW,eAAe,EAAE;EAAnB,CAFmC,CAAD,EAGnC,EAHmC,CAAtC;EAKA,MAAMC,wBAAwB,GAAGlC,WAAW,CAAE+B,KAAD,IAA8C;IACvF,MAAM;MAAEC,WAAW,EAAE;QAAEnB,YAAF;QAAgBC,SAAhB;QAA2BqB;MAA3B;IAAf,IAAsDJ,KAA5D;;IAEA,IAAItB,kBAAkB,CAAC2B,QAAnB,CAA4BD,KAA5B,CAAJ,EAAwC;MACpC,MAAME,aAA8B,GAAGzB,sBAAsB,CAACC,YAAD,EAAeC,SAAf,CAAtB,GAChCD,YAAY,GAAG,CAAf,GAAmB,MAAnB,GAA4B,MADI,GAEjC,MAFN;MAIAW,cAAc,CAACa,aAAD,EAAgB,IAAhB,CAAd;MAEAT,cAAc;IACjB;EACJ,CAZ2C,EAYzC,CAACJ,cAAD,EAAiBI,cAAjB,CAZyC,CAA5C;EAcA,oBACI,oBAAC,iBAAD;IACI,aAAa,EAAEpB,aADnB;IAEI,QAAQ,EAAEY,QAFd;IAGI,OAAO,EAAEG,aAHb;IAII,OAAO,EAAEM,kBAJb;IAKI,cAAc,EAAEC,kBALpB;IAMI,oBAAoB,EAAEI;EAN1B,EADJ;AAUH"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as InternalContext } from './InternalContext';
|
|
2
|
+
export { default as ItemView } from './ItemView';
|
|
3
|
+
export { default as RootView } from './RootView';
|
|
4
|
+
export { default as ScrollViewGesture } from './ScrollViewGesture';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","InternalContext","ItemView","RootView","ScrollViewGesture"],"sources":["index.ts"],"sourcesContent":["export { default as InternalContext } from './InternalContext';\nexport { default as ItemView } from './ItemView';\nexport { default as RootView } from './RootView';\nexport { default as ScrollViewGesture } from './ScrollViewGesture';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,eAApB,QAA2C,mBAA3C;AACA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,SAASF,OAAO,IAAIG,QAApB,QAAoC,YAApC;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,qBAA7C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as useAutoplayController } from './useAutoplayController';
|
|
2
|
+
export { default as useDimensionChangeReaction } from './useDimensionChangeReaction';
|
|
3
|
+
export { default as useIndexController } from './useIndexController';
|
|
4
|
+
export { default as useItemInterpolation } from './useItemInterpolation';
|
|
5
|
+
export { default as useLoopedData } from './useLoopedData';
|
|
6
|
+
export { default as usePagingAnimation } from './usePagingAnimation';
|
|
7
|
+
export { default as useItemVisibilityStore } from './useItemVisibilityStore';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","useAutoplayController","useDimensionChangeReaction","useIndexController","useItemInterpolation","useLoopedData","usePagingAnimation","useItemVisibilityStore"],"sources":["index.ts"],"sourcesContent":["export { default as useAutoplayController } from './useAutoplayController';\nexport { default as useDimensionChangeReaction } from './useDimensionChangeReaction';\nexport { default as useIndexController } from './useIndexController';\nexport { default as useItemInterpolation } from './useItemInterpolation';\nexport { default as useLoopedData } from './useLoopedData';\nexport { default as usePagingAnimation } from './usePagingAnimation';\nexport { default as useItemVisibilityStore } from './useItemVisibilityStore';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,qBAApB,QAAiD,yBAAjD;AACA,SAASD,OAAO,IAAIE,0BAApB,QAAsD,8BAAtD;AACA,SAASF,OAAO,IAAIG,kBAApB,QAA8C,sBAA9C;AACA,SAASH,OAAO,IAAII,oBAApB,QAAgD,wBAAhD;AACA,SAASJ,OAAO,IAAIK,aAApB,QAAyC,iBAAzC;AACA,SAASL,OAAO,IAAIM,kBAApB,QAA8C,sBAA9C;AACA,SAASN,OAAO,IAAIO,sBAApB,QAAkD,0BAAlD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { useDeferredExecutor } from '../../hooks';
|
|
3
|
+
export default function useAutoplayController(config) {
|
|
4
|
+
const {
|
|
5
|
+
enabled,
|
|
6
|
+
intervalMillis,
|
|
7
|
+
startPagingAnimation
|
|
8
|
+
} = config;
|
|
9
|
+
const paused = useRef(false);
|
|
10
|
+
const executor = useDeferredExecutor();
|
|
11
|
+
const play = useCallback(() => {
|
|
12
|
+
if (paused.current) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
executor.execute(() => {
|
|
17
|
+
startPagingAnimation('next', false);
|
|
18
|
+
play();
|
|
19
|
+
}, intervalMillis);
|
|
20
|
+
}, [intervalMillis, startPagingAnimation]);
|
|
21
|
+
const pause = useCallback(() => {
|
|
22
|
+
executor.cancel();
|
|
23
|
+
paused.current = true;
|
|
24
|
+
}, []);
|
|
25
|
+
const resume = useCallback(() => {
|
|
26
|
+
paused.current = false;
|
|
27
|
+
|
|
28
|
+
if (enabled) {
|
|
29
|
+
play();
|
|
30
|
+
}
|
|
31
|
+
}, [play, enabled]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (enabled) {
|
|
34
|
+
resume();
|
|
35
|
+
} else {
|
|
36
|
+
pause();
|
|
37
|
+
}
|
|
38
|
+
}, [enabled]);
|
|
39
|
+
return {
|
|
40
|
+
pause,
|
|
41
|
+
resume
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
;
|
|
45
|
+
//# sourceMappingURL=useAutoplayController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useDeferredExecutor","useAutoplayController","config","enabled","intervalMillis","startPagingAnimation","paused","executor","play","current","execute","pause","cancel","resume"],"sources":["useAutoplayController.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport type { AutoplayController, StartPagingAnimation } from '../types';\nimport { useDeferredExecutor } from '../../hooks';\n\nexport interface AutoplayConfig {\n enabled: boolean;\n intervalMillis: number;\n startPagingAnimation: StartPagingAnimation;\n}\n\nexport default function useAutoplayController(config: AutoplayConfig): AutoplayController {\n const {\n enabled,\n intervalMillis,\n startPagingAnimation,\n } = config;\n\n const paused = useRef<boolean>(false);\n\n const executor = useDeferredExecutor();\n\n const play = useCallback(() => {\n if (paused.current) {\n return;\n }\n\n executor.execute(() => {\n startPagingAnimation('next', false);\n play();\n }, intervalMillis);\n }, [intervalMillis, startPagingAnimation]);\n\n const pause = useCallback(() => {\n executor.cancel();\n paused.current = true;\n }, []);\n\n const resume = useCallback(() => {\n paused.current = false;\n if (enabled) {\n play();\n }\n }, [play, enabled]);\n\n useEffect(() => {\n if (enabled) {\n resume();\n } else {\n pause();\n }\n }, [enabled]);\n\n return { pause, resume };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;AAEA,SAASC,mBAAT,QAAoC,aAApC;AAQA,eAAe,SAASC,qBAAT,CAA+BC,MAA/B,EAA2E;EACtF,MAAM;IACFC,OADE;IAEFC,cAFE;IAGFC;EAHE,IAIFH,MAJJ;EAMA,MAAMI,MAAM,GAAGP,MAAM,CAAU,KAAV,CAArB;EAEA,MAAMQ,QAAQ,GAAGP,mBAAmB,EAApC;EAEA,MAAMQ,IAAI,GAAGX,WAAW,CAAC,MAAM;IAC3B,IAAIS,MAAM,CAACG,OAAX,EAAoB;MAChB;IACH;;IAEDF,QAAQ,CAACG,OAAT,CAAiB,MAAM;MACnBL,oBAAoB,CAAC,MAAD,EAAS,KAAT,CAApB;MACAG,IAAI;IACP,CAHD,EAGGJ,cAHH;EAIH,CATuB,EASrB,CAACA,cAAD,EAAiBC,oBAAjB,CATqB,CAAxB;EAWA,MAAMM,KAAK,GAAGd,WAAW,CAAC,MAAM;IAC5BU,QAAQ,CAACK,MAAT;IACAN,MAAM,CAACG,OAAP,GAAiB,IAAjB;EACH,CAHwB,EAGtB,EAHsB,CAAzB;EAKA,MAAMI,MAAM,GAAGhB,WAAW,CAAC,MAAM;IAC7BS,MAAM,CAACG,OAAP,GAAiB,KAAjB;;IACA,IAAIN,OAAJ,EAAa;MACTK,IAAI;IACP;EACJ,CALyB,EAKvB,CAACA,IAAD,EAAOL,OAAP,CALuB,CAA1B;EAOAL,SAAS,CAAC,MAAM;IACZ,IAAIK,OAAJ,EAAa;MACTU,MAAM;IACT,CAFD,MAEO;MACHF,KAAK;IACR;EACJ,CANQ,EAMN,CAACR,OAAD,CANM,CAAT;EAQA,OAAO;IAAEQ,KAAF;IAASE;EAAT,CAAP;AACH;AAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
export default function useDimensionChangeReaction(params) {
|
|
3
|
+
const {
|
|
4
|
+
controlledTx,
|
|
5
|
+
currentIndex,
|
|
6
|
+
itemWidth
|
|
7
|
+
} = params;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const newTx = -currentIndex * itemWidth;
|
|
10
|
+
controlledTx.setValue(newTx);
|
|
11
|
+
}, [controlledTx, currentIndex, itemWidth]);
|
|
12
|
+
}
|
|
13
|
+
;
|
|
14
|
+
//# sourceMappingURL=useDimensionChangeReaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useDimensionChangeReaction","params","controlledTx","currentIndex","itemWidth","newTx","setValue"],"sources":["useDimensionChangeReaction.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { Animated } from 'react-native';\n\nexport interface Parameters {\n controlledTx: Animated.AnimatedValue;\n currentIndex: number;\n itemWidth: number;\n}\n\nexport default function useDimensionChangeReaction(params: Parameters) {\n const {\n controlledTx,\n currentIndex,\n itemWidth,\n } = params;\n\n useEffect(() => {\n const newTx = -currentIndex * itemWidth;\n controlledTx.setValue(newTx);\n }, [\n controlledTx,\n currentIndex,\n itemWidth,\n ]);\n};\n"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;AASA,eAAe,SAASC,0BAAT,CAAoCC,MAApC,EAAwD;EACnE,MAAM;IACFC,YADE;IAEFC,YAFE;IAGFC;EAHE,IAIFH,MAJJ;EAMAF,SAAS,CAAC,MAAM;IACZ,MAAMM,KAAK,GAAG,CAACF,YAAD,GAAgBC,SAA9B;IACAF,YAAY,CAACI,QAAb,CAAsBD,KAAtB;EACH,CAHQ,EAGN,CACCH,YADD,EAECC,YAFD,EAGCC,SAHD,CAHM,CAAT;AAQH;AAAA"}
|