@fountain-ui/lab 2.0.0-beta.11 → 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/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/ViewPager/ChildrenMemoizedPage.js +44 -47
- 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 +23 -10
- package/build/commonjs/ViewPager/ViewPagerNative.js.map +1 -1
- package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
- package/build/commonjs/ViewPager/ViewPagerWeb.js +9 -7
- 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 +3 -1
- package/build/commonjs/ViewPager/utils.js.map +1 -1
- package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
- package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
- package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
- package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
- package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
- package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
- package/build/commonjs/hooks/index.js +16 -0
- package/build/commonjs/hooks/index.js.map +1 -1
- package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
- package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
- package/build/commonjs/hooks/useIsMounted.js +22 -0
- package/build/commonjs/hooks/useIsMounted.js.map +1 -0
- package/build/commonjs/index.js +22 -1
- package/build/commonjs/index.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/ViewPager/ChildrenMemoizedPage.js +40 -45
- 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 +26 -13
- package/build/module/ViewPager/ViewPagerNative.js.map +1 -1
- package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
- package/build/module/ViewPager/ViewPagerWeb.js +10 -8
- 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 +1 -0
- package/build/module/ViewPager/utils.js.map +1 -1
- package/build/module/ViewabilityTrackerView/Viewability.js +2 -0
- package/build/module/ViewabilityTrackerView/Viewability.js.map +1 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js +28 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
- package/build/module/ViewabilityTrackerView/index.js +2 -0
- package/build/module/ViewabilityTrackerView/index.js.map +1 -0
- package/build/module/ViewabilityTrackerView/measureViewability.js +34 -0
- package/build/module/ViewabilityTrackerView/measureViewability.js.map +1 -0
- package/build/module/ViewabilityTrackerView/useViewabilityTracker.js +73 -0
- package/build/module/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
- package/build/module/hooks/index.js +2 -0
- package/build/module/hooks/index.js.map +1 -1
- package/build/module/hooks/useDeferredExecutor.js +33 -0
- package/build/module/hooks/useDeferredExecutor.js.map +1 -0
- package/build/module/hooks/useIsMounted.js +13 -0
- package/build/module/hooks/useIsMounted.js.map +1 -0
- package/build/module/index.js +2 -0
- package/build/module/index.js.map +1 -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/ViewPager/PageStateContext.d.ts +7 -0
- package/build/typescript/ViewPager/ViewPagerNative.d.ts +1 -1
- package/build/typescript/ViewPager/ViewPagerProps.d.ts +11 -0
- package/build/typescript/ViewPager/ViewPagerWeb.d.ts +1 -1
- package/build/typescript/ViewPager/index.d.ts +1 -0
- package/build/typescript/ViewPager/index.native.d.ts +1 -0
- package/build/typescript/ViewPager/utils.d.ts +1 -0
- 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/index.d.ts +2 -0
- package/package.json +4 -19
- 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/ViewPager/ChildrenMemoizedPage.tsx +48 -43
- package/src/ViewPager/PageStateContext.ts +15 -0
- package/src/ViewPager/ViewPagerNative.tsx +35 -11
- package/src/ViewPager/ViewPagerProps.ts +13 -0
- package/src/ViewPager/ViewPagerWeb.tsx +9 -5
- package/src/ViewPager/index.native.ts +1 -0
- package/src/ViewPager/index.ts +1 -0
- package/src/ViewPager/utils.tsx +2 -1
- 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/useIsMounted.ts +19 -0
- 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/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/typescript/Carousel/CarouselNative.d.ts +0 -2
- package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
- package/build/typescript/Carousel/index.native.d.ts +0 -1
- package/build/typescript/Carousel/utils.d.ts +0 -6
- package/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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","SimpleItemVisibilityStore","constructor","initialValue","store","subscribe","listener","listeners","push","index","indexOf","splice","dispatch","ranges","id","removeAllListeners","length","normalize","windowSize","numberOfData","mod","value","modulo","makeVisibleIndexRanges","ws","firstIndex","lastIndex","halfNumberOfAdjacent","Math","floor","leftSide","rightSide","leftRanges","rightRanges","useItemVisibilityStore","params","currentIndex","initialRange","current","newRanges"],"sources":["useItemVisibilityStore.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport type { ItemVisibilityStore, VisibleIndexRanges } from '../types';\n\nexport interface Parameters {\n currentIndex: number;\n numberOfData: number;\n windowSize: number;\n}\n\nclass SimpleItemVisibilityStore implements ItemVisibilityStore {\n\n private store: VisibleIndexRanges;\n\n constructor(initialValue: VisibleIndexRanges) {\n this.store = initialValue;\n }\n\n private listeners: Array<(ranges: VisibleIndexRanges) => void> = [];\n\n subscribe(listener: (ranges: VisibleIndexRanges) => void) {\n this.listeners.push(listener);\n\n listener(this.store);\n\n return () => {\n const index = this.listeners.indexOf(listener);\n this.listeners.splice(index, 1);\n };\n }\n\n dispatch(ranges: VisibleIndexRanges): void {\n this.store = ranges;\n for (const id in this.listeners) {\n const listener = this.listeners[id];\n listener?.(ranges);\n }\n }\n\n removeAllListeners(): void {\n this.listeners.splice(0, this.listeners.length);\n }\n\n}\n\nfunction normalize(windowSize: number, numberOfData: number): number {\n if (windowSize <= 0) {\n return numberOfData;\n }\n if (windowSize > 0 && windowSize % 2 === 0) {\n return windowSize + 1;\n }\n return windowSize;\n}\n\nfunction mod(value: number, modulo: number): number {\n return ((value % modulo) + modulo) % modulo;\n}\n\nfunction makeVisibleIndexRanges(numberOfData: number, windowSize: number, index: number): VisibleIndexRanges {\n const ws = normalize(windowSize, numberOfData);\n\n const firstIndex = 0;\n const lastIndex = numberOfData - 1;\n const halfNumberOfAdjacent = Math.floor(ws / 2);\n\n const leftSide = index - halfNumberOfAdjacent;\n const rightSide = index + halfNumberOfAdjacent;\n\n const leftRanges = leftSide >= 0\n ? [[leftSide, index]]\n : [[firstIndex, index], [mod(leftSide, numberOfData), lastIndex]];\n\n const rightRanges = rightSide < numberOfData\n ? [[index, rightSide]]\n : [[index, lastIndex], [firstIndex, mod(rightSide, numberOfData)]];\n\n // @ts-ignore\n return [\n ...leftRanges,\n ...rightRanges,\n ];\n}\n\nexport default function useItemVisibilityStore(params: Parameters): ItemVisibilityStore {\n const {\n currentIndex,\n numberOfData,\n windowSize,\n } = params;\n\n const [initialRange] = useState(() => makeVisibleIndexRanges(numberOfData, windowSize, currentIndex));\n const store = useRef(new SimpleItemVisibilityStore(initialRange)).current;\n\n useEffect(() => {\n const newRanges = makeVisibleIndexRanges(numberOfData, windowSize, currentIndex);\n\n store.dispatch(newRanges);\n }, [currentIndex, numberOfData, windowSize]);\n\n useEffect(() => {\n return () => {\n store.removeAllListeners();\n };\n }, []);\n\n return store;\n};\n"],"mappings":";;AAAA,SAASA,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,QAA4C,OAA5C;;AASA,MAAMC,yBAAN,CAA+D;EAI3DC,WAAW,CAACC,YAAD,EAAmC;IAAA;;IAAA,mCAImB,EAJnB;;IAC1C,KAAKC,KAAL,GAAaD,YAAb;EACH;;EAIDE,SAAS,CAACC,QAAD,EAAiD;IACtD,KAAKC,SAAL,CAAeC,IAAf,CAAoBF,QAApB;IAEAA,QAAQ,CAAC,KAAKF,KAAN,CAAR;IAEA,OAAO,MAAM;MACT,MAAMK,KAAK,GAAG,KAAKF,SAAL,CAAeG,OAAf,CAAuBJ,QAAvB,CAAd;MACA,KAAKC,SAAL,CAAeI,MAAf,CAAsBF,KAAtB,EAA6B,CAA7B;IACH,CAHD;EAIH;;EAEDG,QAAQ,CAACC,MAAD,EAAmC;IACvC,KAAKT,KAAL,GAAaS,MAAb;;IACA,KAAK,MAAMC,EAAX,IAAiB,KAAKP,SAAtB,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X,YAAX,CAAJ,EAA8BO,SAA9B,CAAtB,CAFN;EAIA,MAAMO,WAAW,GAAGF,SAAS,GAAGZ,YAAZ,GACd,CAAC,CAACV,KAAD,EAAQsB,SAAR,CAAD,CADc,GAEd,CAAC,CAACtB,KAAD,EAAQiB,SAAR,CAAD,EAAqB,CAACD,UAAD,EAAaL,GAAG,CAACW,SAAD,EAAYZ,YAAZ,CAAhB,CAArB,CAFN,CAdyG,CAkBzG;;EACA,OAAO,CACH,GAAGa,UADA,EAEH,GAAGC,WAFA,CAAP;AAIH;;AAED,eAAe,SAASC,sBAAT,CAAgCC,MAAhC,EAAyE;EACpF,MAAM;IACFC,YADE;IAEFjB,YAFE;IAGFD;EAHE,IAIFiB,MAJJ;EAMA,MAAM,CAACE,YAAD,IAAiBrC,QAAQ,CAAC,MAAMuB,sBAAsB,CAACJ,YAAD,EAAeD,UAAf,EAA2BkB,YAA3B,CAA7B,CAA/B;EACA,MAAMhC,KAAK,GAAGL,MAAM,CAAC,IAAIE,yBAAJ,CAA8BoC,YAA9B,CAAD,CAAN,CAAoDC,OAAlE;EAEAxC,SAAS,CAAC,MAAM;IACZ,MAAMyC,SAAS,GAAGhB,sBAAsB,CAACJ,YAAD,EAAeD,UAAf,EAA2BkB,YAA3B,CAAxC;IAEAhC,KAAK,CAACQ,QAAN,CAAe2B,SAAf;EACH,CAJQ,EAIN,CAACH,YAAD,EAAejB,YAAf,EAA6BD,UAA7B,CAJM,CAAT;EAMApB,SAAS,CAAC,MAAM;IACZ,OAAO,MAAM;MACTM,KAAK,CAACW,kBAAN;IACH,CAFD;EAGH,CAJQ,EAIN,EAJM,CAAT;EAMA,OAAOX,KAAP;AACH;AAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
export default function useLoopedData(originalData, loop) {
|
|
3
|
+
return useMemo(() => {
|
|
4
|
+
if (!loop) {
|
|
5
|
+
return originalData;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const numberOfData = originalData.length;
|
|
9
|
+
|
|
10
|
+
if (numberOfData === 1) {
|
|
11
|
+
const [first] = originalData;
|
|
12
|
+
return [first, first, first];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (numberOfData === 2) {
|
|
16
|
+
const [first, second] = originalData;
|
|
17
|
+
return [first, second, first, second];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return originalData;
|
|
21
|
+
}, [originalData, loop]);
|
|
22
|
+
}
|
|
23
|
+
;
|
|
24
|
+
//# sourceMappingURL=useLoopedData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","useLoopedData","originalData","loop","numberOfData","length","first","second"],"sources":["useLoopedData.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nexport default function useLoopedData<ItemT>(\n originalData: ReadonlyArray<ItemT>,\n loop: boolean,\n): ReadonlyArray<ItemT> {\n return useMemo(() => {\n if (!loop) {\n return originalData;\n }\n\n const numberOfData = originalData.length;\n\n if (numberOfData === 1) {\n const [first] = originalData;\n return [first, first, first];\n }\n\n if (numberOfData === 2) {\n const [first, second] = originalData;\n return [first, second, first, second];\n }\n\n return originalData;\n }, [originalData, loop]);\n};\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;AAEA,eAAe,SAASC,aAAT,CACXC,YADW,EAEXC,IAFW,EAGS;EACpB,OAAOH,OAAO,CAAC,MAAM;IACjB,IAAI,CAACG,IAAL,EAAW;MACP,OAAOD,YAAP;IACH;;IAED,MAAME,YAAY,GAAGF,YAAY,CAACG,MAAlC;;IAEA,IAAID,YAAY,KAAK,CAArB,EAAwB;MACpB,MAAM,CAACE,KAAD,IAAUJ,YAAhB;MACA,OAAO,CAACI,KAAD,EAAQA,KAAR,EAAeA,KAAf,CAAP;IACH;;IAED,IAAIF,YAAY,KAAK,CAArB,EAAwB;MACpB,MAAM,CAACE,KAAD,EAAQC,MAAR,IAAkBL,YAAxB;MACA,OAAO,CAACI,KAAD,EAAQC,MAAR,EAAgBD,KAAhB,EAAuBC,MAAvB,CAAP;IACH;;IAED,OAAOL,YAAP;EACH,CAlBa,EAkBX,CAACA,YAAD,EAAeC,IAAf,CAlBW,CAAd;AAmBH;AAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { Animated, Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
function directionToValue(itemWidth) {
|
|
5
|
+
return function (direction) {
|
|
6
|
+
switch (direction) {
|
|
7
|
+
case 'next':
|
|
8
|
+
return -itemWidth;
|
|
9
|
+
|
|
10
|
+
case 'prev':
|
|
11
|
+
return itemWidth;
|
|
12
|
+
|
|
13
|
+
case 'stay':
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function usePagingAnimation(config) {
|
|
20
|
+
const {
|
|
21
|
+
controlledTx,
|
|
22
|
+
createScrollAnimation,
|
|
23
|
+
getCurrentIndex,
|
|
24
|
+
itemWidth,
|
|
25
|
+
lastIndex,
|
|
26
|
+
loop,
|
|
27
|
+
numberOfData,
|
|
28
|
+
offsetTx
|
|
29
|
+
} = config;
|
|
30
|
+
const animationRef = useRef(null);
|
|
31
|
+
const toValueRef = useRef(0);
|
|
32
|
+
const globalInterpolation = useMemo(() => Animated.add(controlledTx, offsetTx), [controlledTx, offsetTx]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const subscriptionId = controlledTx.addListener(value => {
|
|
35
|
+
const currentTx = value.value; // Prevent infinite loop
|
|
36
|
+
|
|
37
|
+
if (currentTx !== 0) {
|
|
38
|
+
const maxWidth = numberOfData * itemWidth;
|
|
39
|
+
|
|
40
|
+
if (Math.abs(Math.round(currentTx)) === Math.round(maxWidth)) {
|
|
41
|
+
// reset position
|
|
42
|
+
controlledTx.setValue(0);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return () => {
|
|
47
|
+
controlledTx.removeListener(subscriptionId);
|
|
48
|
+
};
|
|
49
|
+
}, [numberOfData, itemWidth]);
|
|
50
|
+
const finalizeAnimation = useCallback(() => {
|
|
51
|
+
const stopUnfinishedSnapAnimation = () => {
|
|
52
|
+
if (animationRef.current) {
|
|
53
|
+
var _animationRef$current;
|
|
54
|
+
|
|
55
|
+
(_animationRef$current = animationRef.current) === null || _animationRef$current === void 0 ? void 0 : _animationRef$current.stop();
|
|
56
|
+
animationRef.current = null;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const resetBoundary = () => {
|
|
61
|
+
controlledTx.setOffset(toValueRef.current);
|
|
62
|
+
controlledTx.flattenOffset(); // FIXME: react-native-web bug maybe?
|
|
63
|
+
// `AnimatedValue.flattenOffset()` does not trigger any event listener.
|
|
64
|
+
// Accessing value directly via `_value` is dangerous but working on web (`useNativeDriver` always false).
|
|
65
|
+
// So setting same value with `value.setValue(value._value)` will trigger event listener.
|
|
66
|
+
|
|
67
|
+
if (Platform.OS === 'web') {
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
controlledTx.setValue(controlledTx._value);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
offsetTx.setValue(0);
|
|
73
|
+
toValueRef.current = 0;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
stopUnfinishedSnapAnimation();
|
|
77
|
+
resetBoundary();
|
|
78
|
+
}, [controlledTx]);
|
|
79
|
+
const startAnimation = useCallback(function (direction) {
|
|
80
|
+
let isGesture = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
81
|
+
const getToValueByDirection = directionToValue(itemWidth);
|
|
82
|
+
const currentIndex = getCurrentIndex();
|
|
83
|
+
|
|
84
|
+
const computeToValueOnNoLoop = () => {
|
|
85
|
+
if (currentIndex === 0 && direction === 'prev') {
|
|
86
|
+
return isGesture ? getToValueByDirection('stay') : -lastIndex * itemWidth; // last position
|
|
87
|
+
} else if (currentIndex === lastIndex && direction === 'next') {
|
|
88
|
+
return isGesture ? getToValueByDirection('stay') : lastIndex * itemWidth; // first position
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return getToValueByDirection(direction);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const toValue = loop ? getToValueByDirection(direction) : computeToValueOnNoLoop();
|
|
95
|
+
const animation = createScrollAnimation(offsetTx, toValue);
|
|
96
|
+
animationRef.current = animation;
|
|
97
|
+
toValueRef.current = toValue;
|
|
98
|
+
animation.start(_ref => {
|
|
99
|
+
let {
|
|
100
|
+
finished
|
|
101
|
+
} = _ref;
|
|
102
|
+
|
|
103
|
+
if (finished) {
|
|
104
|
+
finalizeAnimation();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}, [createScrollAnimation, getCurrentIndex, finalizeAnimation, itemWidth, lastIndex, loop]);
|
|
108
|
+
return {
|
|
109
|
+
globalInterpolation,
|
|
110
|
+
finalizeAnimation,
|
|
111
|
+
startAnimation
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
;
|
|
115
|
+
//# sourceMappingURL=usePagingAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useMemo","useRef","Animated","Platform","directionToValue","itemWidth","direction","usePagingAnimation","config","controlledTx","createScrollAnimation","getCurrentIndex","lastIndex","loop","numberOfData","offsetTx","animationRef","toValueRef","globalInterpolation","add","subscriptionId","addListener","value","currentTx","maxWidth","Math","abs","round","setValue","removeListener","finalizeAnimation","stopUnfinishedSnapAnimation","current","stop","resetBoundary","setOffset","flattenOffset","OS","_value","startAnimation","isGesture","getToValueByDirection","currentIndex","computeToValueOnNoLoop","toValue","animation","start","finished"],"sources":["usePagingAnimation.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { Animated, Platform } from 'react-native';\nimport type { CreateScrollAnimation, GetCurrentIndex, PagingDirection, StartPagingAnimation } from '../types';\n\nexport interface PagingAnimationConfig {\n controlledTx: Animated.Value;\n createScrollAnimation: CreateScrollAnimation;\n getCurrentIndex: GetCurrentIndex;\n itemWidth: number;\n lastIndex: number;\n loop: boolean;\n numberOfData: number;\n offsetTx: Animated.Value;\n}\n\nexport interface UsePagingAnimation {\n finalizeAnimation: () => void;\n globalInterpolation: Animated.AnimatedInterpolation;\n startAnimation: StartPagingAnimation;\n}\n\nfunction directionToValue(itemWidth: number) {\n return function (direction: PagingDirection): number {\n switch (direction) {\n case 'next':\n return -itemWidth;\n case 'prev':\n return itemWidth;\n case 'stay':\n return 0;\n }\n };\n}\n\nexport default function usePagingAnimation(config: PagingAnimationConfig): UsePagingAnimation {\n const {\n controlledTx,\n createScrollAnimation,\n getCurrentIndex,\n itemWidth,\n lastIndex,\n loop,\n numberOfData,\n offsetTx,\n } = config;\n\n const animationRef = useRef<Animated.CompositeAnimation | null>(null);\n const toValueRef = useRef<number>(0);\n\n const globalInterpolation = useMemo(\n () => Animated.add(controlledTx, offsetTx),\n [controlledTx, offsetTx],\n );\n\n useEffect(() => {\n const subscriptionId = controlledTx.addListener((value) => {\n const currentTx = value.value;\n\n // Prevent infinite loop\n if (currentTx !== 0) {\n const maxWidth = numberOfData * itemWidth;\n\n if (Math.abs(Math.round(currentTx)) === Math.round(maxWidth)) {\n // reset position\n controlledTx.setValue(0);\n }\n }\n });\n\n return () => {\n controlledTx.removeListener(subscriptionId);\n };\n }, [numberOfData, itemWidth]);\n\n const finalizeAnimation = useCallback(() => {\n const stopUnfinishedSnapAnimation = () => {\n if (animationRef.current) {\n animationRef.current?.stop();\n animationRef.current = null;\n }\n };\n\n const resetBoundary = () => {\n controlledTx.setOffset(toValueRef.current);\n controlledTx.flattenOffset();\n\n // FIXME: react-native-web bug maybe?\n // `AnimatedValue.flattenOffset()` does not trigger any event listener.\n // Accessing value directly via `_value` is dangerous but working on web (`useNativeDriver` always false).\n // So setting same value with `value.setValue(value._value)` will trigger event listener.\n if (Platform.OS === 'web') {\n // @ts-ignore\n controlledTx.setValue(controlledTx._value);\n }\n\n offsetTx.setValue(0);\n toValueRef.current = 0;\n };\n\n stopUnfinishedSnapAnimation();\n\n resetBoundary();\n }, [controlledTx]);\n\n const startAnimation = useCallback((direction: PagingDirection, isGesture: boolean = false) => {\n const getToValueByDirection = directionToValue(itemWidth);\n\n const currentIndex = getCurrentIndex();\n\n const computeToValueOnNoLoop = (): number => {\n if (currentIndex === 0 && direction === 'prev') {\n return isGesture\n ? getToValueByDirection('stay')\n : -lastIndex * itemWidth; // last position\n } else if (currentIndex === lastIndex && direction === 'next') {\n return isGesture\n ? getToValueByDirection('stay')\n : lastIndex * itemWidth; // first position\n }\n return getToValueByDirection(direction);\n };\n\n const toValue = loop ? getToValueByDirection(direction) : computeToValueOnNoLoop();\n const animation = createScrollAnimation(offsetTx, toValue);\n\n animationRef.current = animation;\n toValueRef.current = toValue;\n\n animation.start(({ finished }) => {\n if (finished) {\n finalizeAnimation();\n }\n });\n }, [\n createScrollAnimation,\n getCurrentIndex,\n finalizeAnimation,\n itemWidth,\n lastIndex,\n loop,\n ]);\n\n return {\n globalInterpolation,\n finalizeAnimation,\n startAnimation,\n };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,OAAjC,EAA0CC,MAA1C,QAAwD,OAAxD;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,cAAnC;;AAoBA,SAASC,gBAAT,CAA0BC,SAA1B,EAA6C;EACzC,OAAO,UAAUC,SAAV,EAA8C;IACjD,QAAQA,SAAR;MACI,KAAK,MAAL;QACI,OAAO,CAACD,SAAR;;MACJ,KAAK,MAAL;QACI,OAAOA,SAAP;;MACJ,KAAK,MAAL;QACI,OAAO,CAAP;IANR;EAQH,CATD;AAUH;;AAED,eAAe,SAASE,kBAAT,CAA4BC,MAA5B,EAA+E;EAC1F,MAAM;IACFC,YADE;IAEFC,qBAFE;IAGFC,eAHE;IAIFN,SAJE;IAKFO,SALE;IAM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IAEAC,SAAS,CAACC,KAAV,CAAgB,QAAkB;MAAA,IAAjB;QAAEC;MAAF,CAAiB;;MAC9B,IAAIA,QAAJ,EAAc;QACVjB,iBAAiB;MACpB;IACJ,CAJD;EAKH,CA7BiC,EA6B/B,CACCpB,qBADD,EAECC,eAFD,EAGCmB,iBAHD,EAICzB,SAJD,EAKCO,SALD,EAMCC,IAND,CA7B+B,CAAlC;EAsCA,OAAO;IACHK,mBADG;IAEHY,iBAFG;IAGHS;EAHG,CAAP;AAKH;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from './
|
|
1
|
+
{"version":3,"names":["default","normalItemStyleFactory","parallaxItemStyleFactory"],"sources":["index.ts"],"sourcesContent":["export { default } from './Carousel';\nexport type { default as CarouselProps } from './CarouselProps';\nexport type { CarouselInstance } from './types';\nexport { normalItemStyleFactory, parallaxItemStyleFactory } from './animation';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,YAAxB;AAGA,SAASC,sBAAT,EAAiCC,wBAAjC,QAAiE,aAAjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["directions"],"sources":["types.ts"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type { Animated, ViewProps } from 'react-native';\n\nconst directions = ['next', 'prev', 'stay'] as const;\n\nexport type PagingDirection = (typeof directions)[number];\n\nexport interface RenderItem<T> {\n (info: { item: T, index: number, interpolation: Animated.AnimatedInterpolation }): ReactElement | null;\n}\n\nexport interface CreateScrollAnimation {\n (aValue: Animated.AnimatedValue, toValue: number): Animated.CompositeAnimation;\n}\n\nexport interface CreateItemStyle {\n (itemInterpolation: Animated.AnimatedInterpolation, itemWidth: number): Animated.AnimatedProps<ViewProps['style']>;\n}\n\nexport interface GetCurrentIndex {\n (): number;\n}\n\nexport interface IndexController {\n currentIndex: number;\n getCurrentIndex: GetCurrentIndex;\n lastIndex: number;\n monitorElement: ReactElement;\n}\n\nexport interface StartPagingAnimation {\n (direction: PagingDirection, isGesture?: boolean): void;\n}\n\nexport type VisibleIndexRanges = Array<[number, number]>;\n\nexport interface StoreSubscription {\n (): void;\n}\n\nexport interface ItemVisibilityStore {\n dispatch: (ranges: VisibleIndexRanges) => void;\n subscribe: (listener: (ranges: VisibleIndexRanges) => void) => StoreSubscription;\n removeAllListeners: () => void;\n}\n\nexport interface AutoplayController {\n pause: () => void;\n resume: () => void;\n}\n\nexport interface CarouselInstance {\n /**\n * Scroll to next visible item.\n */\n next: () => void;\n\n /**\n * Scroll to previous visible item.\n */\n prev: () => void;\n\n /**\n * Get current visible item index.\n */\n getCurrentIndex: GetCurrentIndex;\n}\n"],"mappings":"AAGA,MAAMA,UAAU,GAAG,CAAC,MAAD,EAAS,MAAT,EAAiB,MAAjB,CAAnB"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import React, { memo, useState } from 'react';
|
|
1
|
+
import React, { memo, useMemo, useState } from 'react';
|
|
2
2
|
import { Platform, View } from 'react-native';
|
|
3
3
|
import { runOnJS, useAnimatedReaction } from 'react-native-reanimated';
|
|
4
4
|
import { StyleSheet } from '@fountain-ui/core';
|
|
5
|
-
|
|
5
|
+
import PageStateContext from './PageStateContext';
|
|
6
6
|
const styles = StyleSheet.create({
|
|
7
|
+
fill: {
|
|
8
|
+
width: '100%',
|
|
9
|
+
height: '100%'
|
|
10
|
+
},
|
|
7
11
|
none: {
|
|
8
12
|
display: 'none'
|
|
9
13
|
}
|
|
@@ -14,79 +18,70 @@ function Page(props) {
|
|
|
14
18
|
index,
|
|
15
19
|
children,
|
|
16
20
|
loading,
|
|
21
|
+
offscreenPageRerenderLimit,
|
|
17
22
|
sharedIndex
|
|
18
23
|
} = props;
|
|
19
24
|
|
|
20
25
|
const assumeInitialPageState = () => {
|
|
21
26
|
const activeIndex = sharedIndex.value;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
if (Platform.OS === 'web') {
|
|
25
|
-
return {
|
|
26
|
-
active,
|
|
27
|
-
visited: active
|
|
28
|
-
};
|
|
29
|
-
}
|
|
27
|
+
const isActive = index === activeIndex;
|
|
30
28
|
|
|
31
29
|
if (loading === 'eager') {
|
|
32
30
|
return {
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
isActive,
|
|
32
|
+
isLoaded: true
|
|
35
33
|
};
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
const
|
|
36
|
+
const isLoaded = index >= activeIndex - offscreenPageRerenderLimit && index <= activeIndex + offscreenPageRerenderLimit;
|
|
39
37
|
return {
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
isActive,
|
|
39
|
+
isLoaded
|
|
42
40
|
};
|
|
43
41
|
};
|
|
44
42
|
|
|
45
43
|
const [pageState, setPageState] = useState(assumeInitialPageState);
|
|
46
|
-
const content = pageState.
|
|
44
|
+
const content = pageState.isLoaded ? children : null;
|
|
47
45
|
|
|
48
|
-
const
|
|
49
|
-
setPageState(prevState => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (neighbor && !prevState.visited) {
|
|
58
|
-
return { ...prevState,
|
|
59
|
-
visited: true
|
|
60
|
-
};
|
|
61
|
-
}
|
|
46
|
+
const onActiveStateChange = isActive => {
|
|
47
|
+
setPageState(prevState => ({ ...prevState,
|
|
48
|
+
isActive,
|
|
49
|
+
isLoaded: isActive || prevState.isLoaded
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
62
52
|
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
const onBecomeNeighbor = () => {
|
|
54
|
+
setPageState(prevState => ({ ...prevState,
|
|
55
|
+
isLoaded: true
|
|
56
|
+
}));
|
|
65
57
|
};
|
|
66
58
|
|
|
67
59
|
useAnimatedReaction(() => {
|
|
68
60
|
const activeIndex = sharedIndex.value;
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
61
|
+
const isActive = index === activeIndex;
|
|
62
|
+
const shouldRerender = index >= activeIndex - offscreenPageRerenderLimit && index <= activeIndex + offscreenPageRerenderLimit;
|
|
63
|
+
const becomeNeighbor = shouldRerender && !isActive;
|
|
72
64
|
return {
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
isActive,
|
|
66
|
+
becomeNeighbor
|
|
75
67
|
};
|
|
76
68
|
}, (nextState, prevState) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
runOnJS(updatePageState)(nextState.willActive, nextState.willNeighbor);
|
|
69
|
+
if (nextState.isActive !== (prevState === null || prevState === void 0 ? void 0 : prevState.isActive)) {
|
|
70
|
+
runOnJS(onActiveStateChange)(nextState.isActive);
|
|
71
|
+
} else if (nextState.becomeNeighbor) {
|
|
72
|
+
runOnJS(onBecomeNeighbor)();
|
|
82
73
|
}
|
|
83
74
|
}, [index]);
|
|
84
|
-
const
|
|
75
|
+
const contextValue = useMemo(() => ({
|
|
76
|
+
isActive: pageState.isActive
|
|
77
|
+
}), [pageState.isActive]);
|
|
78
|
+
const style = Platform.OS === 'web' ? pageState.isActive ? StyleSheet.absoluteFill : styles.none : styles.fill;
|
|
85
79
|
return /*#__PURE__*/React.createElement(View, {
|
|
86
|
-
children: content,
|
|
87
80
|
collapsable: false,
|
|
88
81
|
style: style
|
|
89
|
-
}
|
|
82
|
+
}, /*#__PURE__*/React.createElement(PageStateContext.Provider, {
|
|
83
|
+
value: contextValue
|
|
84
|
+
}, content));
|
|
90
85
|
}
|
|
91
86
|
|
|
92
87
|
export default /*#__PURE__*/memo(Page, (prevProps, nextProps) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","memo","useState","Platform","View","runOnJS","useAnimatedReaction","StyleSheet","
|
|
1
|
+
{"version":3,"names":["React","memo","useMemo","useState","Platform","View","runOnJS","useAnimatedReaction","StyleSheet","PageStateContext","styles","create","fill","width","height","none","display","Page","props","index","children","loading","offscreenPageRerenderLimit","sharedIndex","assumeInitialPageState","activeIndex","value","isActive","isLoaded","pageState","setPageState","content","onActiveStateChange","prevState","onBecomeNeighbor","shouldRerender","becomeNeighbor","nextState","contextValue","style","OS","absoluteFill","prevProps","nextProps","rerenderKey"],"sources":["ChildrenMemoizedPage.tsx"],"sourcesContent":["import React, { memo, useMemo, useState } from 'react';\nimport { Platform, View } from 'react-native';\nimport { runOnJS, useAnimatedReaction } from 'react-native-reanimated';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type { PageProps } from './ViewPagerProps';\nimport PageStateContext from './PageStateContext';\n\nconst styles = StyleSheet.create({\n fill: { width: '100%', height: '100%' },\n none: { display: 'none' },\n});\n\ninterface InternalPageState {\n isActive: boolean;\n isLoaded: boolean;\n}\n\nfunction Page(props: PageProps) {\n const {\n index,\n children,\n loading,\n offscreenPageRerenderLimit,\n sharedIndex,\n } = props;\n\n const assumeInitialPageState = (): InternalPageState => {\n const activeIndex = sharedIndex.value;\n\n const isActive = index === activeIndex;\n\n if (loading === 'eager') {\n return { isActive, isLoaded: true };\n }\n\n const isLoaded = index >= activeIndex - offscreenPageRerenderLimit\n && index <= activeIndex + offscreenPageRerenderLimit;\n\n return { isActive, isLoaded };\n };\n\n const [pageState, setPageState] = useState<InternalPageState>(assumeInitialPageState);\n\n const content = pageState.isLoaded ? children : null;\n\n const onActiveStateChange = (isActive: boolean) => {\n setPageState(prevState => ({\n ...prevState,\n isActive,\n isLoaded: isActive || prevState.isLoaded,\n }));\n };\n\n const onBecomeNeighbor = () => {\n setPageState(prevState => ({\n ...prevState,\n isLoaded: true,\n }));\n };\n\n useAnimatedReaction(\n () => {\n const activeIndex = sharedIndex.value;\n\n const isActive = index === activeIndex;\n\n const shouldRerender = index >= activeIndex - offscreenPageRerenderLimit\n && index <= activeIndex + offscreenPageRerenderLimit;\n\n const becomeNeighbor = shouldRerender && !isActive;\n\n return { isActive, becomeNeighbor };\n },\n (nextState, prevState) => {\n if (nextState.isActive !== prevState?.isActive) {\n runOnJS(onActiveStateChange)(nextState.isActive);\n } else if (nextState.becomeNeighbor) {\n runOnJS(onBecomeNeighbor)();\n }\n },\n [index],\n );\n\n const contextValue = useMemo(() => ({\n isActive: pageState.isActive,\n }), [pageState.isActive]);\n\n const style = Platform.OS === 'web'\n ? (pageState.isActive ? StyleSheet.absoluteFill : styles.none)\n : styles.fill;\n\n return (\n <View\n collapsable={false}\n style={style}\n >\n <PageStateContext.Provider value={contextValue}>\n {content}\n </PageStateContext.Provider>\n </View>\n );\n}\n\nexport default memo(Page, (prevProps, nextProps) => {\n if (prevProps.rerenderKey !== nextProps.rerenderKey) {\n return false;\n }\n\n return prevProps.index !== nextProps.index;\n});\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,IAAhB,EAAsBC,OAAtB,EAA+BC,QAA/B,QAA+C,OAA/C;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,cAA/B;AACA,SAASC,OAAT,EAAkBC,mBAAlB,QAA6C,yBAA7C;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA,OAAOC,gBAAP,MAA6B,oBAA7B;AAEA,MAAMC,MAAM,GAAGF,UAAU,CAACG,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IAAEC,KAAK,EAAE,MAAT;IAAiBC,MAAM,EAAE;EAAzB,CADuB;EAE7BC,IAAI,EAAE;IAAEC,OAAO,EAAE;EAAX;AAFuB,CAAlB,CAAf;;AAUA,SAASC,IAAT,CAAcC,KAAd,EAAgC;EAC5B,MAAM;IACFC,KADE;IAEFC,QAFE;IAGFC,OAHE;IAIFC,0BAJE;IAKFC;EALE,IAMFL,KANJ;;EAQA,MAAMM,sBAAsB,GAAG,MAAyB;IACpD,MAAMC,WAAW,GAAGF,WAAW,CAACG,KAAhC;IAEA,MAAMC,QAAQ,GAAGR,KAAK,KAAKM,WAA3B;;IAEA,IAAIJ,OAAO,KAAK,OAAhB,EAAyB;MACrB,OAAO;QAAEM,QAAF;QAAYC,QAAQ,EAAE;MAAtB,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IU,SAAS,CAACD,cAAd,EAA8B;MACjC9B,OAAO,CAAC4B,gBAAD,CAAP;IACH;EACJ,CAnBc,EAoBf,CAACf,KAAD,CApBe,CAAnB;EAuBA,MAAMmB,YAAY,GAAGpC,OAAO,CAAC,OAAO;IAChCyB,QAAQ,EAAEE,SAAS,CAACF;EADY,CAAP,CAAD,EAExB,CAACE,SAAS,CAACF,QAAX,CAFwB,CAA5B;EAIA,MAAMY,KAAK,GAAGnC,QAAQ,CAACoC,EAAT,KAAgB,KAAhB,GACPX,SAAS,CAACF,QAAV,GAAqBnB,UAAU,CAACiC,YAAhC,GAA+C/B,MAAM,CAACK,IAD/C,GAERL,MAAM,CAACE,IAFb;EAIA,oBACI,oBAAC,IAAD;IACI,WAAW,EAAE,KADjB;IAEI,KAAK,EAAE2B;EAFX,gBAII,oBAAC,gBAAD,CAAkB,QAAlB;IAA2B,KAAK,EAAED;EAAlC,GACKP,OADL,CAJJ,CADJ;AAUH;;AAED,4BAAe9B,IAAI,CAACgB,IAAD,EAAO,CAACyB,SAAD,EAAYC,SAAZ,KAA0B;EAChD,IAAID,SAAS,CAACE,WAAV,KAA0BD,SAAS,CAACC,WAAxC,EAAqD;IACjD,OAAO,KAAP;EACH;;EAED,OAAOF,SAAS,CAACvB,KAAV,KAAoBwB,SAAS,CAACxB,KAArC;AACH,CANkB,CAAnB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
const initialPageState = {
|
|
3
|
+
isActive: false
|
|
4
|
+
};
|
|
5
|
+
const PageStateContext = /*#__PURE__*/createContext(initialPageState);
|
|
6
|
+
export const useViewPagerPageState = () => {
|
|
7
|
+
return useContext(PageStateContext);
|
|
8
|
+
};
|
|
9
|
+
export default PageStateContext;
|
|
10
|
+
//# sourceMappingURL=PageStateContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","useContext","initialPageState","isActive","PageStateContext","useViewPagerPageState"],"sources":["PageStateContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\ninterface PageState {\n isActive: boolean;\n}\n\nconst initialPageState: Readonly<PageState> = { isActive: false };\n\nconst PageStateContext = createContext<PageState>(initialPageState);\n\nexport const useViewPagerPageState = () => {\n return useContext(PageStateContext);\n};\n\nexport default PageStateContext;\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAMA,MAAMC,gBAAqC,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAA9C;AAEA,MAAMC,gBAAgB,gBAAGJ,aAAa,CAAYE,gBAAZ,CAAtC;AAEA,OAAO,MAAMG,qBAAqB,GAAG,MAAM;EACvC,OAAOJ,UAAU,CAACG,gBAAD,CAAjB;AACH,CAFM;AAIP,eAAeA,gBAAf"}
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
-
import React, { Children, forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
|
1
|
+
import React, { Children, forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from 'react';
|
|
2
2
|
import RNViewPager from 'react-native-pager-view';
|
|
3
|
-
import { useSharedValue } from 'react-native-reanimated';
|
|
4
|
-
import { defaultInitialPage, defaultLoading, defaultPageComponent } from './utils';
|
|
3
|
+
import { runOnJS, useAnimatedReaction, useSharedValue } from 'react-native-reanimated';
|
|
4
|
+
import { defaultInitialPage, defaultLoading, defaultOffscreenPageRerenderLimit, defaultPageComponent } from './utils';
|
|
5
5
|
const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
|
|
6
6
|
const {
|
|
7
7
|
children,
|
|
8
8
|
initialPage = defaultInitialPage,
|
|
9
9
|
keyboardDismissMode = 'on-drag',
|
|
10
10
|
loading = defaultLoading,
|
|
11
|
+
offscreenPageRerenderLimit = defaultOffscreenPageRerenderLimit,
|
|
11
12
|
onChange,
|
|
12
13
|
pageComponent = defaultPageComponent,
|
|
13
14
|
pageForceRerenderKey,
|
|
14
15
|
scrollEnabled = true,
|
|
15
|
-
style
|
|
16
|
+
style,
|
|
17
|
+
UNSTABLE_sharedIndex
|
|
16
18
|
} = props;
|
|
17
|
-
const
|
|
19
|
+
const fallbackSharedIndex = useSharedValue(initialPage);
|
|
20
|
+
const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;
|
|
18
21
|
const pagerRef = useRef(null);
|
|
19
|
-
|
|
20
|
-
const setPage = newIndex => {
|
|
21
|
-
requestAnimationFrame(() => {
|
|
22
|
+
const animationFrameRef = useRef(NaN);
|
|
23
|
+
const setPage = useCallback(newIndex => {
|
|
24
|
+
animationFrameRef.current = requestAnimationFrame(() => {
|
|
22
25
|
var _pagerRef$current;
|
|
23
26
|
|
|
24
27
|
(_pagerRef$current = pagerRef.current) === null || _pagerRef$current === void 0 ? void 0 : _pagerRef$current.setPage(newIndex);
|
|
25
28
|
});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
}, []);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
return () => {
|
|
32
|
+
if (animationFrameRef.current) {
|
|
33
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
useAnimatedReaction(() => sharedIndex.value, result => {
|
|
38
|
+
runOnJS(setPage)(result);
|
|
39
|
+
}, [setPage]);
|
|
31
40
|
const handlePageSelected = useCallback(e => {
|
|
32
41
|
const currentIndex = sharedIndex.value;
|
|
33
42
|
const nextIndex = e.nativeEvent.position;
|
|
@@ -42,6 +51,9 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
|
|
|
42
51
|
onChange(nextIndex);
|
|
43
52
|
}
|
|
44
53
|
}, [onChange]);
|
|
54
|
+
useImperativeHandle(ref, () => ({
|
|
55
|
+
setPage
|
|
56
|
+
}), [setPage]);
|
|
45
57
|
const PageComponent = pageComponent;
|
|
46
58
|
return /*#__PURE__*/React.createElement(RNViewPager, {
|
|
47
59
|
ref: pagerRef,
|
|
@@ -56,6 +68,7 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
|
|
|
56
68
|
children: child,
|
|
57
69
|
index: index,
|
|
58
70
|
loading: loading,
|
|
71
|
+
offscreenPageRerenderLimit: offscreenPageRerenderLimit,
|
|
59
72
|
rerenderKey: pageForceRerenderKey,
|
|
60
73
|
sharedIndex: sharedIndex
|
|
61
74
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Children","forwardRef","useCallback","useImperativeHandle","useRef","RNViewPager","useSharedValue","defaultInitialPage","defaultLoading","defaultPageComponent","ViewPager","props","ref","children","initialPage","keyboardDismissMode","loading","onChange","pageComponent","pageForceRerenderKey","scrollEnabled","style","sharedIndex","pagerRef","setPage","newIndex","requestAnimationFrame","
|
|
1
|
+
{"version":3,"names":["React","Children","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","RNViewPager","runOnJS","useAnimatedReaction","useSharedValue","defaultInitialPage","defaultLoading","defaultOffscreenPageRerenderLimit","defaultPageComponent","ViewPager","props","ref","children","initialPage","keyboardDismissMode","loading","offscreenPageRerenderLimit","onChange","pageComponent","pageForceRerenderKey","scrollEnabled","style","UNSTABLE_sharedIndex","fallbackSharedIndex","sharedIndex","pagerRef","animationFrameRef","NaN","setPage","newIndex","current","requestAnimationFrame","cancelAnimationFrame","value","result","handlePageSelected","e","currentIndex","nextIndex","nativeEvent","position","PageComponent","map","child","index"],"sources":["ViewPagerNative.tsx"],"sourcesContent":["import React, { Children, forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from 'react';\nimport type { ViewPagerOnPageSelectedEvent } from 'react-native-pager-view';\nimport RNViewPager from 'react-native-pager-view';\nimport { runOnJS, useAnimatedReaction, useSharedValue } from 'react-native-reanimated';\nimport type ViewPagerProps from './ViewPagerProps';\nimport type { ViewPagerInstance } from './ViewPagerProps';\nimport { defaultInitialPage, defaultLoading, defaultOffscreenPageRerenderLimit, defaultPageComponent } from './utils';\n\nconst ViewPager = forwardRef<ViewPagerInstance, ViewPagerProps>(function ViewPager(props, ref) {\n const {\n children,\n initialPage = defaultInitialPage,\n keyboardDismissMode = 'on-drag',\n loading = defaultLoading,\n offscreenPageRerenderLimit = defaultOffscreenPageRerenderLimit,\n onChange,\n pageComponent = defaultPageComponent,\n pageForceRerenderKey,\n scrollEnabled = true,\n style,\n UNSTABLE_sharedIndex,\n } = props;\n\n const fallbackSharedIndex = useSharedValue<number>(initialPage);\n\n const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;\n\n const pagerRef = useRef<RNViewPager | null>(null);\n\n const animationFrameRef = useRef<number>(NaN);\n\n const setPage = useCallback((newIndex: number) => {\n animationFrameRef.current = requestAnimationFrame(() => {\n pagerRef.current?.setPage(newIndex);\n });\n }, []);\n\n useEffect(() => {\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current);\n }\n };\n }, []);\n\n useAnimatedReaction(\n () => sharedIndex.value,\n (result) => {\n runOnJS(setPage)(result);\n },\n [setPage],\n );\n\n const handlePageSelected = useCallback((e: ViewPagerOnPageSelectedEvent) => {\n const currentIndex = sharedIndex.value;\n const nextIndex = e.nativeEvent.position;\n\n if (currentIndex === nextIndex) {\n return;\n }\n\n sharedIndex.value = nextIndex;\n\n if (onChange) {\n onChange(nextIndex);\n }\n }, [onChange]);\n\n useImperativeHandle(\n ref,\n () => ({ setPage }),\n [setPage],\n );\n\n const PageComponent = pageComponent;\n\n return (\n <RNViewPager\n ref={pagerRef}\n initialPage={initialPage}\n keyboardDismissMode={keyboardDismissMode}\n onPageSelected={handlePageSelected}\n pageMargin={8}\n scrollEnabled={scrollEnabled}\n style={style}\n >\n {Children.map(children, (child, index) => (\n <PageComponent\n key={index}\n children={child}\n index={index}\n loading={loading}\n offscreenPageRerenderLimit={offscreenPageRerenderLimit}\n rerenderKey={pageForceRerenderKey}\n sharedIndex={sharedIndex}\n />\n ))}\n </R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B;IAOI,WAAW,EAAEK;EAPjB,EADH,CATL,CADJ;AAuBH,CA3F2B,CAA5B;AA6FA,eAAef,SAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["ViewPagerProps.ts"],"sourcesContent":["import type { ComponentType, PropsWithChildren, ReactNode, Ref } from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport type KeyboardDismissMode = 'none' | 'on-drag';\n\nexport type PageProps = PropsWithChildren<ViewProps> & {\n index: number;\n loading: ViewPagerProps['loading'];\n sharedIndex: SharedValue<number>;\n rerenderKey?: ViewPagerProps['pageForceRerenderKey'];\n};\n\nexport type PageComponent = ComponentType<PageProps>;\n\nexport type Loading = 'lazy' | 'eager';\n\nexport interface ViewPagerInstance {\n /**\n * Function to scroll to a specific page in the ViewPager. Invalid index is ignored.\n * @param index\n */\n setPage: (index: number) => void;\n}\n\nexport default interface ViewPagerProps extends ComponentProps<{\n ref?: Ref<ViewPagerInstance>;\n\n /**\n * Collection of ViewPager components.\n */\n children?: ReactNode;\n\n /**\n * Index of initial page that should be selected.\n * @default 0\n */\n initialPage?: number;\n\n /**\n * Whether to load the page immediately (`eager`) or on an as-needed basis (`lazy`).\n * @default 'lazy'\n */\n loading?: Loading;\n\n /**\n * Callback fired when an index is changed.\n */\n onChange?: (newIndex: number) => void,\n\n /**\n * The component used to render the wrapper of the page.\n * @default 'ChildrenMemoizedPage'\n */\n pageComponent?: PageComponent,\n\n /**\n * When this value is changed, page will be rerender.\n */\n pageForceRerenderKey?: any;\n\n /**\n * Mobile only. Should pager view scroll, when scroll enabled.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * Mobile only. Determines whether the keyboard gets dismissed in response to a drag.\n * @default 'on-drag'\n */\n keyboardDismissMode?: KeyboardDismissMode;\n}> {}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["ViewPagerProps.ts"],"sourcesContent":["import type { ComponentType, PropsWithChildren, ReactNode, Ref } from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport type KeyboardDismissMode = 'none' | 'on-drag';\n\nexport type PageProps = PropsWithChildren<ViewProps> & {\n index: number;\n loading: ViewPagerProps['loading'];\n offscreenPageRerenderLimit: number;\n sharedIndex: SharedValue<number>;\n rerenderKey?: ViewPagerProps['pageForceRerenderKey'];\n};\n\nexport type PageComponent = ComponentType<PageProps>;\n\nexport type Loading = 'lazy' | 'eager';\n\nexport interface ViewPagerInstance {\n /**\n * Function to scroll to a specific page in the ViewPager. Invalid index is ignored.\n * @param index\n */\n setPage: (index: number) => void;\n}\n\nexport default interface ViewPagerProps extends ComponentProps<{\n ref?: Ref<ViewPagerInstance>;\n\n /**\n * Collection of ViewPager components.\n */\n children?: ReactNode;\n\n /**\n * Index of initial page that should be selected.\n * @default 0\n */\n initialPage?: number;\n\n /**\n * Whether to load the page immediately (`eager`) or on an as-needed basis (`lazy`).\n * @default 'lazy'\n */\n loading?: Loading;\n\n /**\n * Mobile only. The number of pages that should be re-rendered to either side of the current page.\n * Changing this value after the component mount has no effect.\n * @default 0\n */\n offscreenPageRerenderLimit?: number;\n\n /**\n * Callback fired when an index is changed.\n */\n onChange?: (newIndex: number) => void,\n\n /**\n * The component used to render the wrapper of the page.\n * @default 'ChildrenMemoizedPage'\n */\n pageComponent?: PageComponent,\n\n /**\n * When this value is changed, page will be rerender.\n */\n pageForceRerenderKey?: any;\n\n /**\n * Mobile only. Should pager view scroll, when scroll enabled.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * Mobile only. Determines whether the keyboard gets dismissed in response to a drag.\n * @default 'on-drag'\n */\n keyboardDismissMode?: KeyboardDismissMode;\n\n /**\n * Unstable API.\n */\n UNSTABLE_sharedIndex?: SharedValue<number>;\n}> {}\n"],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Children, forwardRef, useImperativeHandle } from 'react';
|
|
1
|
+
import React, { Children, forwardRef, useImperativeHandle, useCallback } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { useSharedValue } from 'react-native-reanimated';
|
|
4
4
|
import { StyleSheet } from '@fountain-ui/core';
|
|
@@ -17,17 +17,17 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
|
|
|
17
17
|
loading = defaultLoading,
|
|
18
18
|
pageComponent = defaultPageComponent,
|
|
19
19
|
pageForceRerenderKey,
|
|
20
|
-
style
|
|
20
|
+
style,
|
|
21
|
+
UNSTABLE_sharedIndex
|
|
21
22
|
} = props;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const setPage = newIndex => {
|
|
23
|
+
const fallbackSharedIndex = useSharedValue(initialPage);
|
|
24
|
+
const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;
|
|
25
|
+
const setPage = useCallback(newIndex => {
|
|
25
26
|
sharedIndex.value = newIndex;
|
|
26
|
-
};
|
|
27
|
-
|
|
27
|
+
}, [sharedIndex]);
|
|
28
28
|
useImperativeHandle(ref, () => ({
|
|
29
29
|
setPage
|
|
30
|
-
}), []);
|
|
30
|
+
}), [setPage]);
|
|
31
31
|
const PageComponent = pageComponent;
|
|
32
32
|
return /*#__PURE__*/React.createElement(View, {
|
|
33
33
|
style: [styles.root, style]
|
|
@@ -36,6 +36,8 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
|
|
|
36
36
|
children: child,
|
|
37
37
|
index: index,
|
|
38
38
|
loading: loading,
|
|
39
|
+
offscreenPageRerenderLimit: 0 // All offscreen pages will not be re-rendered
|
|
40
|
+
,
|
|
39
41
|
rerenderKey: pageForceRerenderKey,
|
|
40
42
|
sharedIndex: sharedIndex
|
|
41
43
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Children","forwardRef","useImperativeHandle","View","useSharedValue","StyleSheet","defaultInitialPage","defaultLoading","defaultPageComponent","styles","create","root","overflow","position","ViewPager","props","ref","children","initialPage","loading","pageComponent","pageForceRerenderKey","style","sharedIndex","setPage","newIndex","value","PageComponent","map","child","index"],"sources":["ViewPagerWeb.tsx"],"sourcesContent":["import React, { Children, forwardRef, useImperativeHandle } from 'react';\nimport { View } from 'react-native';\nimport { useSharedValue } from 'react-native-reanimated';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type ViewPagerProps from './ViewPagerProps';\nimport type { ViewPagerInstance } from './ViewPagerProps';\nimport { defaultInitialPage, defaultLoading, defaultPageComponent } from './utils';\n\nconst styles = StyleSheet.create({\n root: {\n // @ts-ignore\n overflow: 'auto',\n position: 'relative',\n },\n});\n\nconst ViewPager = forwardRef<ViewPagerInstance, ViewPagerProps>(function ViewPager(props, ref) {\n const {\n children,\n initialPage = defaultInitialPage,\n loading = defaultLoading,\n pageComponent = defaultPageComponent,\n pageForceRerenderKey,\n style,\n } = props;\n\n const
|
|
1
|
+
{"version":3,"names":["React","Children","forwardRef","useImperativeHandle","useCallback","View","useSharedValue","StyleSheet","defaultInitialPage","defaultLoading","defaultPageComponent","styles","create","root","overflow","position","ViewPager","props","ref","children","initialPage","loading","pageComponent","pageForceRerenderKey","style","UNSTABLE_sharedIndex","fallbackSharedIndex","sharedIndex","setPage","newIndex","value","PageComponent","map","child","index"],"sources":["ViewPagerWeb.tsx"],"sourcesContent":["import React, { Children, forwardRef, useImperativeHandle, useCallback } from 'react';\nimport { View } from 'react-native';\nimport { useSharedValue } from 'react-native-reanimated';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type ViewPagerProps from './ViewPagerProps';\nimport type { ViewPagerInstance } from './ViewPagerProps';\nimport { defaultInitialPage, defaultLoading, defaultPageComponent } from './utils';\n\nconst styles = StyleSheet.create({\n root: {\n // @ts-ignore\n overflow: 'auto',\n position: 'relative',\n },\n});\n\nconst ViewPager = forwardRef<ViewPagerInstance, ViewPagerProps>(function ViewPager(props, ref) {\n const {\n children,\n initialPage = defaultInitialPage,\n loading = defaultLoading,\n pageComponent = defaultPageComponent,\n pageForceRerenderKey,\n style,\n UNSTABLE_sharedIndex,\n } = props;\n\n const fallbackSharedIndex = useSharedValue<number>(initialPage);\n\n const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;\n\n const setPage = useCallback((newIndex: number) => {\n sharedIndex.value = newIndex;\n }, [sharedIndex]);\n\n useImperativeHandle(\n ref,\n () => ({ setPage }),\n [setPage],\n );\n\n const PageComponent = pageComponent;\n\n return (\n <View style={[styles.root, style]}>\n {Children.map(children, (child, index) => (\n <PageComponent\n key={index}\n children={child}\n index={index}\n loading={loading}\n offscreenPageRerenderLimit={0} // All offscreen pages will not be re-rendered\n rerenderKey={pageForceRerenderKey}\n sharedIndex={sharedIndex}\n />\n ))}\n </View>\n );\n});\n\nexport default ViewPager;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,UAA1B,EAAsCC,mBAAtC,EAA2DC,WAA3D,QAA8E,OAA9E;AACA,SAASC,IAAT,QAAqB,cAArB;AACA,SAASC,cAAT,QAA+B,yBAA/B;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAGA,SAASC,kBAAT,EAA6BC,cAA7B,EAA6CC,oBAA7C,QAAyE,SAAzE;AAEA,MAAMC,MAAM,GAAGJ,UAAU,CAACK,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACF;IACAC,QAAQ,EAAE,MAFR;IAGFC,QAAQ,EAAE;EAHR;AADuB,CAAlB,CAAf;AAQA,MAAMC,SAAS,gBAAGd,UAAU,CAAoC,SAASc,SAAT,CAAmBC,KAAnB,EAA0BC,GAA1B,EAA+B;EAC3F,MAAM;IACFC,QADE;IAEFC,WAAW,GAAGZ,kBAFZ;IAGFa,OAAO,GAAGZ,cAHR;IAIFa,aAAa,GAAGZ,oBAJd;IAKFa,oBALE;IAMFC,KANE;IAOFC;EAPE,IAQFR,KARJ;EAUA,MAAMS,mBAAmB,GAAGpB,cAAc,CAASc,WAAT,CAA1C;EAEA,MAAMO,WAAW,GAAGF,oBAAoB,IAAIC,mBAA5C;EAEA,MAAME,OAAO,GAAGxB,WAAW,CAAEyB,QAAD,IAAsB;IAC9CF,WAAW,CAACG,KAAZ,GAAoBD,QAApB;EACH,CAF0B,EAExB,CAACF,WAAD,CAFwB,CAA3B;EAIAxB,mBAAmB,CACfe,GADe,EAEf,OAAO;IAAEU;EAAF,CAAP,CAFe,EAGf,CAACA,OAAD,CAHe,CAAnB;EAMA,MAAMG,aAAa,GAAGT,aAAtB;EAEA,oBACI,oBAAC,IAAD;IAAM,KAAK,EAAE,CAACX,MAAM,CAACE,IAAR,EAAcW,KAAd;EAAb,GACKvB,QAAQ,CAAC+B,GAAT,CAAab,QAAb,EAAuB,CAACc,KAAD,EAAQC,KAAR,kBACpB,oBAAC,aAAD;IACI,GAAG,EAAEA,KADT;IAEI,QAAQ,EAAED,KAFd;IAGI,KAAK,EAAEC,KAHX;IAII,OAAO,EAAEb,OAJb;IAKI,0BAA0B,EAAE,CALhC,CAKmC;IALnC;IAMI,WAAW,EAAEE,oBANjB;IAOI,WAAW,EAAEI;EAPjB,EADH,CADL,CADJ;AAeH,CA1C2B,CAA5B;AA4CA,eAAeX,SAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from './ViewPagerWeb';\nexport type { default as ViewPagerProps, ViewPagerInstance } from './ViewPagerProps';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,gBAAxB"}
|
|
1
|
+
{"version":3,"names":["default","useViewPagerPageState"],"sources":["index.ts"],"sourcesContent":["export { default } from './ViewPagerWeb';\nexport type { default as ViewPagerProps, ViewPagerInstance } from './ViewPagerProps';\nexport { useViewPagerPageState } from './PageStateContext';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,gBAAxB;AAEA,SAASC,qBAAT,QAAsC,oBAAtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default"],"sources":["index.native.ts"],"sourcesContent":["export { default } from './ViewPagerNative';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,mBAAxB"}
|
|
1
|
+
{"version":3,"names":["default","useViewPagerPageState"],"sources":["index.native.ts"],"sourcesContent":["export { default } from './ViewPagerNative';\nexport { useViewPagerPageState } from './PageStateContext';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,mBAAxB;AACA,SAASC,qBAAT,QAAsC,oBAAtC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ChildrenMemoizedPage from './ChildrenMemoizedPage';
|
|
2
2
|
export const defaultInitialPage = 0;
|
|
3
3
|
export const defaultLoading = 'lazy';
|
|
4
|
+
export const defaultOffscreenPageRerenderLimit = 0;
|
|
4
5
|
export const defaultPageComponent = ChildrenMemoizedPage;
|
|
5
6
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ChildrenMemoizedPage","defaultInitialPage","defaultLoading","defaultPageComponent"],"sources":["utils.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"names":["ChildrenMemoizedPage","defaultInitialPage","defaultLoading","defaultOffscreenPageRerenderLimit","defaultPageComponent"],"sources":["utils.tsx"],"sourcesContent":["import { Loading, PageComponent } from './ViewPagerProps';\nimport ChildrenMemoizedPage from './ChildrenMemoizedPage';\n\nexport const defaultInitialPage: number = 0;\n\nexport const defaultLoading: Loading = 'lazy';\n\nexport const defaultOffscreenPageRerenderLimit: number = 0;\n\nexport const defaultPageComponent: PageComponent = ChildrenMemoizedPage;\n"],"mappings":"AACA,OAAOA,oBAAP,MAAiC,wBAAjC;AAEA,OAAO,MAAMC,kBAA0B,GAAG,CAAnC;AAEP,OAAO,MAAMC,cAAuB,GAAG,MAAhC;AAEP,OAAO,MAAMC,iCAAyC,GAAG,CAAlD;AAEP,OAAO,MAAMC,oBAAmC,GAAGJ,oBAA5C"}
|