react-native-reanimated-carousel 2.5.1 → 3.0.1
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/README.md +22 -62
- package/README.zh-CN.md +21 -63
- package/lib/commonjs/Carousel.js +1 -1
- package/lib/commonjs/Carousel.js.map +1 -1
- package/lib/commonjs/ScrollViewGesture.js +1 -1
- package/lib/commonjs/ScrollViewGesture.js.map +1 -1
- package/lib/commonjs/hooks/useCarouselController.js +1 -1
- package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
- package/lib/commonjs/hooks/useOffsetX.js +1 -1
- package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
- package/lib/commonjs/layouts/BaseLayout.js +1 -1
- package/lib/commonjs/layouts/BaseLayout.js.map +1 -1
- package/lib/commonjs/layouts/ParallaxLayout.js +1 -1
- package/lib/commonjs/layouts/ParallaxLayout.js.map +1 -1
- package/lib/commonjs/layouts/normal.js +1 -1
- package/lib/commonjs/layouts/normal.js.map +1 -1
- package/lib/commonjs/layouts/parallax.js +1 -1
- package/lib/commonjs/layouts/parallax.js.map +1 -1
- package/lib/commonjs/layouts/stack.js +1 -1
- package/lib/commonjs/layouts/stack.js.map +1 -1
- package/lib/commonjs/utils/computedWithAutoFillData.js +1 -1
- package/lib/commonjs/utils/computedWithAutoFillData.js.map +1 -1
- package/lib/commonjs/utils/dealWithAnimation.js +1 -1
- package/lib/commonjs/utils/dealWithAnimation.js.map +1 -1
- package/lib/commonjs/utils/log.js +1 -1
- package/lib/module/ScrollViewGesture.js +9 -4
- package/lib/module/ScrollViewGesture.js.map +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
- package/package.json +13 -12
- package/src/ScrollViewGesture.tsx +19 -13
- package/src/hooks/usePropsErrorBoundary.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCarouselController.tsx"],"names":["useCarouselController","options","size","data","loop","handlerOffsetX","withAnimation","defaultIndex","duration","autoFillData","dataInfo","React","useMemo","length","disable","originalLength","index","sharedIndex","sharedPreIndex","currentFixedPage","useCallback","Math","round","value","fixed","abs","setSharedIndex","newSharedIndex","current","handlerOffsetXValue","toInt","isPositive","i","newSharedIndexValue","rawDataLength","convertToSharedIndex","runOnJS","getCurrentIndex","canSliding","onScrollEnd","onScrollBegin","scrollWithTiming","toValue","onFinished","callback","isFinished","defaultWithAnimation","type","config","easing","Easing","easeOutQuart","dealWithAnimation","next","opts","count","animated","nextPage","prev","prevPage","to","offset","scrollTo","n","getSharedIndex"],"mappings":"6GAAA,qDAEA,uCACA,8DAUA,6DACA,2EACA,iC,0/BAuBO,QAASA,CAAAA,qBAAT,CAA+BC,OAA/B,CAAoE,CACvE,GACIC,CAAAA,IADJ,CASID,OATJ,CACIC,IADJ,CAEIC,IAFJ,CASIF,OATJ,CAEIE,IAFJ,CAGIC,IAHJ,CASIH,OATJ,CAGIG,IAHJ,CAIIC,cAJJ,CASIJ,OATJ,CAIII,cAJJ,CAKIC,aALJ,CASIL,OATJ,CAKIK,aALJ,uBASIL,OATJ,CAMIM,YANJ,CAMIA,YANJ,gCAMmB,CANnB,uBAOIC,QAPJ,CASIP,OATJ,CAOIO,QAPJ,CAQIC,YARJ,CASIR,OATJ,CAQIQ,YARJ,CAWA,GAAMC,CAAAA,QAAQ,CAAGC,eAAMC,OAAN,CACb,iBAAO,CACHC,MAAM,CAAEV,IAAI,CAACU,MADV,CAEHC,OAAO,CAAE,CAACX,IAAI,CAACU,MAFZ,CAGHE,cAAc,CAA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,MAAO,CACHP,IAAI,CAAJA,IADG,CAEHK,IAAI,CAAJA,IAFG,CAGHI,QAAQ,CAARA,QAHG,CAIHzB,eAAe,CAAfA,eAJG,CAKH2B,cAAc,CAAE,gCAAM/C,CAAAA,WAAW,CAACW,OAAlB,EALb,CAAP,CAOH","sourcesContent":["import React, { useRef } from 'react';\nimport type Animated from 'react-native-reanimated';\nimport { Easing } from '../constants';\nimport {\n runOnJS,\n useAnimatedReaction,\n useSharedValue,\n} from 'react-native-reanimated';\nimport type {\n TCarouselActionOptions,\n TCarouselProps,\n WithTimingAnimation,\n} from '../types';\nimport { dealWithAnimation } from '@/utils/dealWithAnimation';\nimport { convertToSharedIndex } from '@/utils/computedWithAutoFillData';\nimport { round } from '@/utils/log';\n\ninterface IOpts {\n loop: boolean;\n size: number;\n data: TCarouselProps['data'];\n autoFillData: TCarouselProps['autoFillData'];\n handlerOffsetX: Animated.SharedValue<number>;\n withAnimation?: TCarouselProps['withAnimation'];\n duration?: number;\n defaultIndex?: number;\n onScrollBegin?: () => void;\n onScrollEnd?: () => void;\n}\n\nexport interface ICarouselController {\n getSharedIndex: () => number;\n prev: (opts?: TCarouselActionOptions) => void;\n next: (opts?: TCarouselActionOptions) => void;\n getCurrentIndex: () => number;\n scrollTo: (opts?: TCarouselActionOptions) => void;\n}\n\nexport function useCarouselController(options: IOpts): ICarouselController {\n const {\n size,\n data,\n loop,\n handlerOffsetX,\n withAnimation,\n defaultIndex = 0,\n duration,\n autoFillData,\n } = options;\n\n const dataInfo = React.useMemo(\n () => ({\n length: data.length,\n disable: !data.length,\n originalLength: data.length,\n }),\n [data]\n );\n\n const index = useSharedValue<number>(defaultIndex);\n // The Index displayed to the user\n const sharedIndex = useRef<number>(defaultIndex);\n const sharedPreIndex = useRef<number>(defaultIndex);\n\n const currentFixedPage = React.useCallback(() => {\n if (loop) {\n return -Math.round(handlerOffsetX.value / size);\n }\n\n const fixed = (handlerOffsetX.value / size) % dataInfo.length;\n return Math.round(\n handlerOffsetX.value <= 0\n ? Math.abs(fixed)\n : Math.abs(fixed > 0 ? dataInfo.length - fixed : 0)\n );\n }, [handlerOffsetX, dataInfo, size, loop]);\n\n function setSharedIndex(newSharedIndex: number) {\n sharedIndex.current = newSharedIndex;\n }\n\n useAnimatedReaction(\n () => {\n const handlerOffsetXValue = handlerOffsetX.value;\n const toInt = round(handlerOffsetXValue / size) % dataInfo.length;\n const isPositive = handlerOffsetXValue <= 0;\n const i = isPositive\n ? Math.abs(toInt)\n : Math.abs(toInt > 0 ? dataInfo.length - toInt : 0);\n\n const newSharedIndexValue = convertToSharedIndex({\n loop,\n rawDataLength: dataInfo.originalLength,\n autoFillData: autoFillData!,\n index: i,\n });\n\n return {\n i,\n newSharedIndexValue,\n };\n },\n ({ i, newSharedIndexValue }) => {\n index.value = i;\n runOnJS(setSharedIndex)(newSharedIndexValue);\n },\n [\n sharedPreIndex,\n sharedIndex,\n size,\n dataInfo,\n index,\n loop,\n autoFillData,\n handlerOffsetX,\n ]\n );\n\n const getCurrentIndex = React.useCallback(() => {\n return index.value;\n }, [index]);\n\n const canSliding = React.useCallback(() => {\n return !dataInfo.disable;\n }, [dataInfo]);\n\n const onScrollEnd = React.useCallback(() => {\n options.onScrollEnd?.();\n }, [options]);\n\n const onScrollBegin = React.useCallback(() => {\n options.onScrollBegin?.();\n }, [options]);\n\n const scrollWithTiming = React.useCallback(\n (toValue: number, onFinished?: () => void) => {\n 'worklet';\n const callback = (isFinished: boolean) => {\n 'worklet';\n if (isFinished) {\n runOnJS(onScrollEnd)();\n onFinished && runOnJS(onFinished)();\n }\n };\n\n const defaultWithAnimation: WithTimingAnimation = {\n type: 'timing',\n config: { duration, easing: Easing.easeOutQuart },\n };\n\n return dealWithAnimation(withAnimation ?? defaultWithAnimation)(\n toValue,\n callback\n );\n },\n [duration, withAnimation, onScrollEnd]\n );\n\n const next = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n 'worklet';\n const { count = 1, animated = true, onFinished } = opts;\n if (!canSliding() || (!loop && index.value >= dataInfo.length - 1))\n return;\n\n onScrollBegin?.();\n\n const nextPage = currentFixedPage() + count;\n index.value = nextPage;\n\n if (animated) {\n handlerOffsetX.value = scrollWithTiming(\n -nextPage * size,\n onFinished\n ) as any;\n } else {\n handlerOffsetX.value = -nextPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n dataInfo,\n onScrollBegin,\n handlerOffsetX,\n size,\n scrollWithTiming,\n currentFixedPage,\n ]\n );\n\n const prev = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n const { count = 1, animated = true, onFinished } = opts;\n if (!canSliding() || (!loop && index.value <= 0)) return;\n\n onScrollBegin?.();\n\n const prevPage = currentFixedPage() - count;\n index.value = prevPage;\n\n if (animated) {\n handlerOffsetX.value = scrollWithTiming(\n -prevPage * size,\n onFinished\n );\n } else {\n handlerOffsetX.value = -prevPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n onScrollBegin,\n handlerOffsetX,\n size,\n scrollWithTiming,\n currentFixedPage,\n ]\n );\n\n const to = React.useCallback(\n (opts: { i: number; animated: boolean; onFinished?: () => void }) => {\n const { i, animated = false, onFinished } = opts;\n if (i === index.value) return;\n if (!canSliding()) return;\n\n onScrollBegin?.();\n\n const offset = handlerOffsetX.value + (index.value - i) * size;\n\n if (animated) {\n index.value = i;\n handlerOffsetX.value = scrollWithTiming(offset, onFinished);\n } else {\n handlerOffsetX.value = offset;\n index.value = i;\n onFinished?.();\n }\n },\n [\n index,\n canSliding,\n onScrollBegin,\n handlerOffsetX,\n size,\n scrollWithTiming,\n ]\n );\n\n const scrollTo = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n const { index: i, count, animated = false, onFinished } = opts;\n\n if (typeof i === 'number' && i > -1) {\n to({ i, animated, onFinished });\n return;\n }\n\n if (!count) {\n return;\n }\n\n const n = Math.round(count);\n\n if (n < 0) {\n prev({ count: Math.abs(n), animated, onFinished });\n } else {\n next({ count: n, animated, onFinished });\n }\n },\n [prev, next, to]\n );\n\n return {\n next,\n prev,\n scrollTo,\n getCurrentIndex,\n getSharedIndex: () => sharedIndex.current,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["useCarouselController.tsx"],"names":["useCarouselController","options","size","data","loop","handlerOffsetX","withAnimation","defaultIndex","duration","autoFillData","dataInfo","React","useMemo","length","disable","originalLength","index","sharedIndex","sharedPreIndex","currentFixedPage","useCallback","Math","round","value","fixed","abs","setSharedIndex","newSharedIndex","current","handlerOffsetXValue","toInt","isPositive","i","newSharedIndexValue","rawDataLength","convertToSharedIndex","runOnJS","getCurrentIndex","canSliding","onScrollEnd","onScrollBegin","scrollWithTiming","toValue","onFinished","callback","isFinished","defaultWithAnimation","type","config","easing","Easing","easeOutQuart","dealWithAnimation","next","opts","count","animated","nextPage","prev","prevPage","to","offset","scrollTo","n","getSharedIndex"],"mappings":"6GAAA,qDAEA,uCACA,8DAUA,6DACA,2EACA,iC,0/BAuBO,QAASA,CAAAA,qBAAT,CAA+BC,OAA/B,CAAoE,CACvE,GACIC,CAAAA,IADJ,CASID,OATJ,CACIC,IADJ,CAEIC,IAFJ,CASIF,OATJ,CAEIE,IAFJ,CAGIC,IAHJ,CASIH,OATJ,CAGIG,IAHJ,CAIIC,cAJJ,CASIJ,OATJ,CAIII,cAJJ,CAKIC,aALJ,CASIL,OATJ,CAKIK,aALJ,uBASIL,OATJ,CAMIM,YANJ,CAMIA,YANJ,gCAMmB,CANnB,uBAOIC,QAPJ,CASIP,OATJ,CAOIO,QAPJ,CAQIC,YARJ,CASIR,OATJ,CAQIQ,YARJ,CAWA,GAAMC,CAAAA,QAAQ,CAAGC,eAAMC,OAAN,CACb,iBAAO,CACHC,MAAM,CAAEV,IAAI,CAACU,MADV,CAEHC,OAAO,CAAE,CAACX,IAAI,CAACU,MAFZ,CAGHE,cAAc,CAAEZ,IAAI,CAACU,MAHlB,CAAP,EADa,CAMb,CAACV,IAAD,CANa,CAAjB,CASA,GAAMa,CAAA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G,CAIHzB,eAAe,CAAfA,eAJG,CAKH2B,cAAc,CAAE,gCAAM/C,CAAAA,WAAW,CAACW,OAAlB,EALb,CAAP,CAOH","sourcesContent":["import React, { useRef } from 'react';\nimport type Animated from 'react-native-reanimated';\nimport { Easing } from '../constants';\nimport {\n runOnJS,\n useAnimatedReaction,\n useSharedValue,\n} from 'react-native-reanimated';\nimport type {\n TCarouselActionOptions,\n TCarouselProps,\n WithTimingAnimation,\n} from '../types';\nimport { dealWithAnimation } from '@/utils/dealWithAnimation';\nimport { convertToSharedIndex } from '@/utils/computedWithAutoFillData';\nimport { round } from '@/utils/log';\n\ninterface IOpts {\n loop: boolean;\n size: number;\n data: TCarouselProps['data'];\n autoFillData: TCarouselProps['autoFillData'];\n handlerOffsetX: Animated.SharedValue<number>;\n withAnimation?: TCarouselProps['withAnimation'];\n duration?: number;\n defaultIndex?: number;\n onScrollBegin?: () => void;\n onScrollEnd?: () => void;\n}\n\nexport interface ICarouselController {\n getSharedIndex: () => number;\n prev: (opts?: TCarouselActionOptions) => void;\n next: (opts?: TCarouselActionOptions) => void;\n getCurrentIndex: () => number;\n scrollTo: (opts?: TCarouselActionOptions) => void;\n}\n\nexport function useCarouselController(options: IOpts): ICarouselController {\n const {\n size,\n data,\n loop,\n handlerOffsetX,\n withAnimation,\n defaultIndex = 0,\n duration,\n autoFillData,\n } = options;\n\n const dataInfo = React.useMemo(\n () => ({\n length: data.length,\n disable: !data.length,\n originalLength: data.length,\n }),\n [data]\n );\n\n const index = useSharedValue<number>(defaultIndex);\n // The Index displayed to the user\n const sharedIndex = useRef<number>(defaultIndex);\n const sharedPreIndex = useRef<number>(defaultIndex);\n\n const currentFixedPage = React.useCallback(() => {\n if (loop) {\n return -Math.round(handlerOffsetX.value / size);\n }\n\n const fixed = (handlerOffsetX.value / size) % dataInfo.length;\n return Math.round(\n handlerOffsetX.value <= 0\n ? Math.abs(fixed)\n : Math.abs(fixed > 0 ? dataInfo.length - fixed : 0)\n );\n }, [handlerOffsetX, dataInfo, size, loop]);\n\n function setSharedIndex(newSharedIndex: number) {\n sharedIndex.current = newSharedIndex;\n }\n\n useAnimatedReaction(\n () => {\n const handlerOffsetXValue = handlerOffsetX.value;\n const toInt = round(handlerOffsetXValue / size) % dataInfo.length;\n const isPositive = handlerOffsetXValue <= 0;\n const i = isPositive\n ? Math.abs(toInt)\n : Math.abs(toInt > 0 ? dataInfo.length - toInt : 0);\n\n const newSharedIndexValue = convertToSharedIndex({\n loop,\n rawDataLength: dataInfo.originalLength,\n autoFillData: autoFillData!,\n index: i,\n });\n\n return {\n i,\n newSharedIndexValue,\n };\n },\n ({ i, newSharedIndexValue }) => {\n index.value = i;\n runOnJS(setSharedIndex)(newSharedIndexValue);\n },\n [\n sharedPreIndex,\n sharedIndex,\n size,\n dataInfo,\n index,\n loop,\n autoFillData,\n handlerOffsetX,\n ]\n );\n\n const getCurrentIndex = React.useCallback(() => {\n return index.value;\n }, [index]);\n\n const canSliding = React.useCallback(() => {\n return !dataInfo.disable;\n }, [dataInfo]);\n\n const onScrollEnd = React.useCallback(() => {\n options.onScrollEnd?.();\n }, [options]);\n\n const onScrollBegin = React.useCallback(() => {\n options.onScrollBegin?.();\n }, [options]);\n\n const scrollWithTiming = React.useCallback(\n (toValue: number, onFinished?: () => void) => {\n 'worklet';\n const callback = (isFinished: boolean) => {\n 'worklet';\n if (isFinished) {\n runOnJS(onScrollEnd)();\n onFinished && runOnJS(onFinished)();\n }\n };\n\n const defaultWithAnimation: WithTimingAnimation = {\n type: 'timing',\n config: { duration, easing: Easing.easeOutQuart },\n };\n\n return dealWithAnimation(withAnimation ?? defaultWithAnimation)(\n toValue,\n callback\n );\n },\n [duration, withAnimation, onScrollEnd]\n );\n\n const next = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n 'worklet';\n const { count = 1, animated = true, onFinished } = opts;\n if (!canSliding() || (!loop && index.value >= dataInfo.length - 1))\n return;\n\n onScrollBegin?.();\n\n const nextPage = currentFixedPage() + count;\n index.value = nextPage;\n\n if (animated) {\n handlerOffsetX.value = scrollWithTiming(\n -nextPage * size,\n onFinished\n ) as any;\n } else {\n handlerOffsetX.value = -nextPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n dataInfo,\n onScrollBegin,\n handlerOffsetX,\n size,\n scrollWithTiming,\n currentFixedPage,\n ]\n );\n\n const prev = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n const { count = 1, animated = true, onFinished } = opts;\n if (!canSliding() || (!loop && index.value <= 0)) return;\n\n onScrollBegin?.();\n\n const prevPage = currentFixedPage() - count;\n index.value = prevPage;\n\n if (animated) {\n handlerOffsetX.value = scrollWithTiming(\n -prevPage * size,\n onFinished\n );\n } else {\n handlerOffsetX.value = -prevPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n onScrollBegin,\n handlerOffsetX,\n size,\n scrollWithTiming,\n currentFixedPage,\n ]\n );\n\n const to = React.useCallback(\n (opts: { i: number; animated: boolean; onFinished?: () => void }) => {\n const { i, animated = false, onFinished } = opts;\n if (i === index.value) return;\n if (!canSliding()) return;\n\n onScrollBegin?.();\n\n const offset = handlerOffsetX.value + (index.value - i) * size;\n\n if (animated) {\n index.value = i;\n handlerOffsetX.value = scrollWithTiming(offset, onFinished);\n } else {\n handlerOffsetX.value = offset;\n index.value = i;\n onFinished?.();\n }\n },\n [\n index,\n canSliding,\n onScrollBegin,\n handlerOffsetX,\n size,\n scrollWithTiming,\n ]\n );\n\n const scrollTo = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n const { index: i, count, animated = false, onFinished } = opts;\n\n if (typeof i === 'number' && i > -1) {\n to({ i, animated, onFinished });\n return;\n }\n\n if (!count) {\n return;\n }\n\n const n = Math.round(count);\n\n if (n < 0) {\n prev({ count: Math.abs(n), animated, onFinished });\n } else {\n next({ count: n, animated, onFinished });\n }\n },\n [prev, next, to]\n );\n\n return {\n next,\n prev,\n scrollTo,\n getCurrentIndex,\n getSharedIndex: () => sharedIndex.current,\n };\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.useOffsetX=void 0;var _reactNativeReanimated=require("react-native-reanimated");var useOffsetX=function useOffsetX(opts,visibleRanges){var handlerOffsetX=opts.handlerOffsetX,index=opts.index,size=opts.size,loop=opts.loop,data=opts.data,_opts$type=opts.type,type=_opts$type===void 0?'positive':_opts$type,_opts$viewCount=opts.viewCount,viewCount=_opts$viewCount===void 0?Math.round((data.length-1)/2):_opts$viewCount;var ITEM_LENGTH=data.length;var VALID_LENGTH=ITEM_LENGTH-1;var TOTAL_WIDTH=size*ITEM_LENGTH;var HALF_WIDTH=0.5*size;var positiveCount=type==='positive'?viewCount:VALID_LENGTH-viewCount;var startPos=size*index;if(index>positiveCount){startPos=(index-ITEM_LENGTH)*size;}var MAX=positiveCount*size;var MIN=-((VALID_LENGTH-positiveCount)*size);var x=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var _visibleRanges$value=visibleRanges.value,negativeRange=_visibleRanges$value.negativeRange,positiveRange=_visibleRanges$value.positiveRange;if((index<negativeRange[0]||index>negativeRange[1])&&(index<positiveRange[0]||index>positiveRange[1])){return Number.MAX_SAFE_INTEGER;}if(loop){var inputRange=[-TOTAL_WIDTH,MIN-HALF_WIDTH-startPos-Number.MIN_VALUE,MIN-HALF_WIDTH-startPos,0,MAX+HALF_WIDTH-startPos,MAX+HALF_WIDTH-startPos+Number.MIN_VALUE,TOTAL_WIDTH];var outputRange=[startPos,MAX+HALF_WIDTH-Number.MIN_VALUE,MIN-HALF_WIDTH,startPos,MAX+HALF_WIDTH,MIN-HALF_WIDTH+Number.MIN_VALUE,startPos];return(0,_reactNativeReanimated.interpolate)(handlerOffsetX.value,inputRange,outputRange,_reactNativeReanimated.Extrapolate.CLAMP);}return handlerOffsetX.value+size*index;};_f._closure={visibleRanges:visibleRanges,index:index,loop:loop,TOTAL_WIDTH:TOTAL_WIDTH,MIN:MIN,HALF_WIDTH:HALF_WIDTH,startPos:startPos,MAX:MAX,interpolate:_reactNativeReanimated.interpolate,handlerOffsetX:handlerOffsetX,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},size:size};_f.asString="function _f(){const{visibleRanges,index,loop,TOTAL_WIDTH,MIN,HALF_WIDTH,startPos,MAX,interpolate,handlerOffsetX,Extrapolate,size}=jsThis._closure;{const{negativeRange:negativeRange,positiveRange:positiveRange}=visibleRanges.value;if((index<negativeRange[0]||index>negativeRange[1])&&(index<positiveRange[0]||index>positiveRange[1])){return Number.MAX_SAFE_INTEGER;}if(loop){const inputRange=[-TOTAL_WIDTH,MIN-HALF_WIDTH-startPos-Number.MIN_VALUE,MIN-HALF_WIDTH-startPos,0,MAX+HALF_WIDTH-startPos,MAX+HALF_WIDTH-startPos+Number.MIN_VALUE,TOTAL_WIDTH];const outputRange=[startPos,MAX+HALF_WIDTH-Number.MIN_VALUE,MIN-HALF_WIDTH,startPos,MAX+HALF_WIDTH,MIN-HALF_WIDTH+Number.MIN_VALUE,startPos];return interpolate(handlerOffsetX.value,inputRange,outputRange,Extrapolate.CLAMP);}return handlerOffsetX.value+size*index;}}";_f.__workletHash=12723241758918;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOffsetX.ts (45:30)";
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useOffsetX=void 0;var _reactNativeReanimated=require("react-native-reanimated");var useOffsetX=function useOffsetX(opts,visibleRanges){var handlerOffsetX=opts.handlerOffsetX,index=opts.index,size=opts.size,loop=opts.loop,data=opts.data,_opts$type=opts.type,type=_opts$type===void 0?'positive':_opts$type,_opts$viewCount=opts.viewCount,viewCount=_opts$viewCount===void 0?Math.round((data.length-1)/2):_opts$viewCount;var ITEM_LENGTH=data.length;var VALID_LENGTH=ITEM_LENGTH-1;var TOTAL_WIDTH=size*ITEM_LENGTH;var HALF_WIDTH=0.5*size;var positiveCount=type==='positive'?viewCount:VALID_LENGTH-viewCount;var startPos=size*index;if(index>positiveCount){startPos=(index-ITEM_LENGTH)*size;}var MAX=positiveCount*size;var MIN=-((VALID_LENGTH-positiveCount)*size);var x=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var _visibleRanges$value=visibleRanges.value,negativeRange=_visibleRanges$value.negativeRange,positiveRange=_visibleRanges$value.positiveRange;if((index<negativeRange[0]||index>negativeRange[1])&&(index<positiveRange[0]||index>positiveRange[1])){return Number.MAX_SAFE_INTEGER;}if(loop){var inputRange=[-TOTAL_WIDTH,MIN-HALF_WIDTH-startPos-Number.MIN_VALUE,MIN-HALF_WIDTH-startPos,0,MAX+HALF_WIDTH-startPos,MAX+HALF_WIDTH-startPos+Number.MIN_VALUE,TOTAL_WIDTH];var outputRange=[startPos,MAX+HALF_WIDTH-Number.MIN_VALUE,MIN-HALF_WIDTH,startPos,MAX+HALF_WIDTH,MIN-HALF_WIDTH+Number.MIN_VALUE,startPos];return(0,_reactNativeReanimated.interpolate)(handlerOffsetX.value,inputRange,outputRange,_reactNativeReanimated.Extrapolate.CLAMP);}return handlerOffsetX.value+size*index;};_f._closure={visibleRanges:visibleRanges,index:index,loop:loop,TOTAL_WIDTH:TOTAL_WIDTH,MIN:MIN,HALF_WIDTH:HALF_WIDTH,startPos:startPos,MAX:MAX,interpolate:_reactNativeReanimated.interpolate,handlerOffsetX:handlerOffsetX,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},size:size};_f.asString="function _f(){const{visibleRanges,index,loop,TOTAL_WIDTH,MIN,HALF_WIDTH,startPos,MAX,interpolate,handlerOffsetX,Extrapolate,size}=jsThis._closure;{const{negativeRange:negativeRange,positiveRange:positiveRange}=visibleRanges.value;if((index<negativeRange[0]||index>negativeRange[1])&&(index<positiveRange[0]||index>positiveRange[1])){return Number.MAX_SAFE_INTEGER;}if(loop){const inputRange=[-TOTAL_WIDTH,MIN-HALF_WIDTH-startPos-Number.MIN_VALUE,MIN-HALF_WIDTH-startPos,0,MAX+HALF_WIDTH-startPos,MAX+HALF_WIDTH-startPos+Number.MIN_VALUE,TOTAL_WIDTH];const outputRange=[startPos,MAX+HALF_WIDTH-Number.MIN_VALUE,MIN-HALF_WIDTH,startPos,MAX+HALF_WIDTH,MIN-HALF_WIDTH+Number.MIN_VALUE,startPos];return interpolate(handlerOffsetX.value,inputRange,outputRange,Extrapolate.CLAMP);}return handlerOffsetX.value+size*index;}}";_f.__workletHash=12723241758918;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOffsetX.ts (45:30)";return _f;}(),[loop,data,viewCount,type,size,visibleRanges]);return x;};exports.useOffsetX=useOffsetX;
|
|
2
2
|
//# sourceMappingURL=useOffsetX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useOffsetX.ts"],"names":["useOffsetX","opts","visibleRanges","handlerOffsetX","index","size","loop","data","type","viewCount","Math","round","length","ITEM_LENGTH","VALID_LENGTH","TOTAL_WIDTH","HALF_WIDTH","positiveCount","startPos","MAX","MIN","x","value","negativeRange","positiveRange","Number","MAX_SAFE_INTEGER","inputRange","MIN_VALUE","outputRange","Extrapolate","CLAMP","interpolate"],"mappings":"mFAAA,8DAiBO,GAAMA,CAAAA,UAAU,CAAG,QAAbA,CAAAA,UAAa,CAACC,IAAD,CAAcC,aAAd,CAAgD,CACtE,GACIC,CAAAA,cADJ,CAQIF,IARJ,CACIE,cADJ,CAEIC,KAFJ,CAQIH,IARJ,CAEIG,KAFJ,CAGIC,IAHJ,CAQIJ,IARJ,CAGII,IAHJ,CAIIC,IAJJ,CAQIL,IARJ,CAIIK,IAJJ,CAKIC,IALJ,CAQIN,IARJ,CAKIM,IALJ,YAQIN,IARJ,CAMIO,IANJ,CAMIA,IANJ,qBAMW,UANX,4BAQIP,IARJ,CAOIQ,SAPJ,CAOIA,SAPJ,0BAOgBC,IAAI,CAACC,KAAL,CAAW,CAACJ,IAAI,CAACK,MAAL,CAAc,CAAf,E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AAGH,UAAN,CAAmBE,QALJ,CAMfC,GAAG,CAAGH,UAAN,CAAmBE,QAAnB,CAA8BO,MAAM,CAACG,SANtB,CAOfb,WAPe,CAAnB,CAUA,GAAMc,CAAAA,WAAW,CAAG,CAChBX,QADgB,CAEhBC,GAAG,CAAGH,UAAN,CAAmBS,MAAM,CAACG,SAFV,CAGhBR,GAAG,CAAGJ,UAHU,CAIhBE,QAJgB,CAKhBC,GAAG,CAAGH,UALU,CAMhBI,GAAG,CAAGJ,UAAN,CAAmBS,MAAM,CAACG,SANV,CAOhBV,QAPgB,CAApB,CAUA,MAAO,uCACHf,cAAc,CAACmB,KADZ,CAEHK,UAFG,CAGHE,WAHG,CAIHC,mCAAYC,KAJT,CAAP,CAMH,CAED,MAAO5B,CAAAA,cAAc,CAACmB,KAAf,CAAuBjB,IAAI,CAAGD,KAArC,CACH,CAvCS,4BAvCRF,aAuCQ,OA3ByBE,KA2BzB,MAjCRE,IAiCQ,aAhCqLS,WAgCrL,KA/BwGK,GA+BxG,YA/B8GJ,UA+B9G,UA/B6IE,QA+B7I,KA/BsFC,GA+BtF,aA9BHa,kCA8BG,gBA3BL7B,cA2BK,oBA9BwD2B,mCAAYC,KA8BpE,OA3BkB1B,IA2BlB,
|
|
1
|
+
{"version":3,"sources":["useOffsetX.ts"],"names":["useOffsetX","opts","visibleRanges","handlerOffsetX","index","size","loop","data","type","viewCount","Math","round","length","ITEM_LENGTH","VALID_LENGTH","TOTAL_WIDTH","HALF_WIDTH","positiveCount","startPos","MAX","MIN","x","value","negativeRange","positiveRange","Number","MAX_SAFE_INTEGER","inputRange","MIN_VALUE","outputRange","Extrapolate","CLAMP","interpolate"],"mappings":"mFAAA,8DAiBO,GAAMA,CAAAA,UAAU,CAAG,QAAbA,CAAAA,UAAa,CAACC,IAAD,CAAcC,aAAd,CAAgD,CACtE,GACIC,CAAAA,cADJ,CAQIF,IARJ,CACIE,cADJ,CAEIC,KAFJ,CAQIH,IARJ,CAEIG,KAFJ,CAGI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\n interpolate,\n useDerivedValue,\n} from 'react-native-reanimated';\nimport type { IVisibleRanges } from './useVisibleRanges';\n\nexport interface IOpts {\n index: number;\n size: number;\n handlerOffsetX: Animated.SharedValue<number>;\n data: unknown[];\n type?: 'positive' | 'negative';\n viewCount?: number;\n loop?: boolean;\n}\n\nexport const useOffsetX = (opts: IOpts, visibleRanges: IVisibleRanges) => {\n const {\n handlerOffsetX,\n index,\n size,\n loop,\n data,\n type = 'positive',\n viewCount = Math.round((data.length - 1) / 2),\n } = opts;\n\n const ITEM_LENGTH = data.length;\n const VALID_LENGTH = ITEM_LENGTH - 1;\n const TOTAL_WIDTH = size * ITEM_LENGTH;\n const HALF_WIDTH = 0.5 * size;\n\n const positiveCount =\n type === 'positive' ? viewCount : VALID_LENGTH - viewCount;\n\n let startPos = size * index;\n if (index > positiveCount) {\n startPos = (index - ITEM_LENGTH) * size;\n }\n\n const MAX = positiveCount * size;\n const MIN = -((VALID_LENGTH - positiveCount) * size);\n\n const x = useDerivedValue(() => {\n const { negativeRange, positiveRange } = visibleRanges.value;\n if (\n (index < negativeRange[0] || index > negativeRange[1]) &&\n (index < positiveRange[0] || index > positiveRange[1])\n ) {\n return Number.MAX_SAFE_INTEGER;\n }\n\n if (loop) {\n const inputRange = [\n -TOTAL_WIDTH,\n MIN - HALF_WIDTH - startPos - Number.MIN_VALUE,\n MIN - HALF_WIDTH - startPos,\n 0,\n MAX + HALF_WIDTH - startPos,\n MAX + HALF_WIDTH - startPos + Number.MIN_VALUE,\n TOTAL_WIDTH,\n ];\n\n const outputRange = [\n startPos,\n MAX + HALF_WIDTH - Number.MIN_VALUE,\n MIN - HALF_WIDTH,\n startPos,\n MAX + HALF_WIDTH,\n MIN - HALF_WIDTH + Number.MIN_VALUE,\n startPos,\n ];\n\n return interpolate(\n handlerOffsetX.value,\n inputRange,\n outputRange,\n Extrapolate.CLAMP\n );\n }\n\n return handlerOffsetX.value + size * index;\n }, [loop, data, viewCount, type, size, visibleRanges]);\n\n return x;\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.useOnProgressChange=useOnProgressChange;var _reactNativeReanimated=require("react-native-reanimated");var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");function useOnProgressChange(opts){var autoFillData=opts.autoFillData,loop=opts.loop,offsetX=opts.offsetX,rawData=opts.rawData,size=opts.size,onProgressChange=opts.onProgressChange;var rawDataLength=rawData.length;(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return offsetX.value;};_f._closure={offsetX:offsetX};_f.asString="function _f(){const{offsetX}=jsThis._closure;{return offsetX.value;}}";_f.__workletHash=11091407603539;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts (23:8)";
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useOnProgressChange=useOnProgressChange;var _reactNativeReanimated=require("react-native-reanimated");var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");function useOnProgressChange(opts){var autoFillData=opts.autoFillData,loop=opts.loop,offsetX=opts.offsetX,rawData=opts.rawData,size=opts.size,onProgressChange=opts.onProgressChange;var rawDataLength=rawData.length;(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return offsetX.value;};_f._closure={offsetX:offsetX};_f.asString="function _f(){const{offsetX}=jsThis._closure;{return offsetX.value;}}";_f.__workletHash=11091407603539;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts (23:8)";return _f;}(),function(){var _f=function _f(_value){var value=(0,_computedWithAutoFillData.computedOffsetXValueWithAutoFillData)({value:_value,rawDataLength:rawDataLength,size:size,autoFillData:autoFillData,loop:loop});if(!loop){value=Math.max(-((rawDataLength-1)*size),Math.min(value,0));}var absoluteProgress=Math.abs(value/size);if(value>0){absoluteProgress=rawDataLength-absoluteProgress;}!!onProgressChange&&(0,_reactNativeReanimated.runOnJS)(onProgressChange)(value,absoluteProgress);};_f._closure={computedOffsetXValueWithAutoFillData:_computedWithAutoFillData.computedOffsetXValueWithAutoFillData,rawDataLength:rawDataLength,size:size,autoFillData:autoFillData,loop:loop,onProgressChange:onProgressChange,runOnJS:_reactNativeReanimated.runOnJS};_f.asString="function _f(_value){const{computedOffsetXValueWithAutoFillData,rawDataLength,size,autoFillData,loop,onProgressChange,runOnJS}=jsThis._closure;{let value=computedOffsetXValueWithAutoFillData({value:_value,rawDataLength:rawDataLength,size:size,autoFillData:autoFillData,loop:loop});if(!loop){value=Math.max(-((rawDataLength-1)*size),Math.min(value,0));}let absoluteProgress=Math.abs(value/size);if(value>0){absoluteProgress=rawDataLength-absoluteProgress;}!!onProgressChange&&runOnJS(onProgressChange)(value,absoluteProgress);}}";_f.__workletHash=10178584953814;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts (24:8)";return _f;}(),[loop,autoFillData,rawDataLength,onProgressChange]);}
|
|
2
2
|
//# sourceMappingURL=useOnProgressChange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useOnProgressChange.ts"],"names":["useOnProgressChange","opts","autoFillData","loop","offsetX","rawData","size","onProgressChange","rawDataLength","length","value","_value","Math","max","min","absoluteProgress","abs","computedOffsetXValueWithAutoFillData","runOnJS"],"mappings":"yGAAA,8DAIA,2EAGO,QAASA,CAAAA,mBAAT,CACHC,IADG,CAQL,CACE,GAAQC,CAAAA,YAAR,CACID,IADJ,CAAQC,YAAR,CAAsBC,IAAtB,CACIF,IADJ,CAAsBE,IAAtB,CAA4BC,OAA5B,CACIH,IADJ,CAA4BG,OAA5B,CAAqCC,OAArC,CACIJ,IADJ,CAAqCI,OAArC,CAA8CC,IAA9C,CACIL,IADJ,CAA8CK,IAA9C,CAAoDC,gBAApD,CACIN,IADJ,CAAoDM,gBAApD,CAGA,GAAMC,CAAAA,aAAa,CAAGH,OAAO,CAACI,MAA9B,CAEA,iEACI,oBAAML,CAAAA,OAAO,CAACM,KAAd,EADJ,sBApBGN,OAoBH,
|
|
1
|
+
{"version":3,"sources":["useOnProgressChange.ts"],"names":["useOnProgressChange","opts","autoFillData","loop","offsetX","rawData","size","onProgressChange","rawDataLength","length","value","_value","Math","max","min","absoluteProgress","abs","computedOffsetXValueWithAutoFillData","runOnJS"],"mappings":"yGAAA,8DAIA,2EAGO,QAASA,CAAAA,mBAAT,CACHC,IADG,CAQL,CACE,GAAQC,CAAAA,YAAR,CACID,IADJ,CAAQC,YAAR,CAAsBC,IAAtB,CACIF,IADJ,CAAsBE,IAAtB,CAA4BC,OAA5B,CACIH,IADJ,CAA4BG,OAA5B,CAAqCC,OAArC,CACIJ,IADJ,CAAqCI,OAArC,CAA8CC,IAA9C,CACIL,IADJ,CAA8CK,IAA9C,CAAoDC,gBAApD,CACIN,IADJ,CAAoDM,gBAApD,CAGA,GAAMC,CAAAA,aAAa,CAAGH,OAAO,CAACI,MAA9B,CAEA,iEACI,oBAAML,CAAAA,OAAO,CAACM,KAAd,EADJ,sBApBGN,OAoBH,0RAEKO,MAFL,CAEgB,CACR,GAAID,CAAAA,KAAK,CAAG,mEAAqC,CAC7CA,KAAK,CAAEC,MADsC,CAE7CH,aAAa,CAAbA,aAF6C,CAG7CF,IAAI,CAAJA,IAH6C,CAI7CJ,YAAY,CAAZA,YAJ6C,CAK7CC,IAAI,CAAJA,IAL6C,CAArC,CAAZ,CAQA,GAAI,CAACA,IAAL,CAAW,CACPO,KAAK,CAAGE,IAAI,CAACC,GAAL,CACJ,EAAE,CAACL,aAAa,CAAG,CAAjB,EAAsBF,IAAxB,CADI,CAEJM,IAAI,CAACE,GAAL,CAASJ,KAAT,CAAgB,CAAhB,CAFI,CAAR,CAIH,CAED,GAAIK,CAAAA,gBAAgB,CAAGH,IAAI,CAACI,GAAL,CAASN,KAAK,CAAGJ,IAAjB,CAAvB,CAEA,GAAII,KAAK,CAAG,CAAZ,CAAe,CACXK,gBAAgB,CAAGP,aAAa,CAAGO,gBAAnC,CACH,CAED,CAAC,CAACR,gBAAF,EACI,mCAAQA,gBAAR,EAA0BG,KAA1B,CAAiCK,gBAAjC,CADJ,CAEH,CA1BL,mDAnBUE,8DAmBV,eAJmBT,aAInB,MAPsCF,IAOtC,cAfAJ,YAeA,MAXGC,IAWH,kBAD4BI,gBAC5B,SADoBW,8BACpB,qsBA2BI,CAACf,IAAD,CAAOD,YAAP,CAAqBM,aAArB,CAAoCD,gBAApC,CA3BJ,EA6BH","sourcesContent":["import Animated, {\n runOnJS,\n useAnimatedReaction,\n} from 'react-native-reanimated';\nimport { computedOffsetXValueWithAutoFillData } from '@/utils/computedWithAutoFillData';\nimport type { TCarouselProps } from '../types';\n\nexport function useOnProgressChange(\n opts: {\n size: number;\n autoFillData: boolean;\n loop: boolean;\n offsetX: Animated.SharedValue<number>;\n rawData: TCarouselProps['data'];\n } & Pick<TCarouselProps, 'onProgressChange'>\n) {\n const { autoFillData, loop, offsetX, rawData, size, onProgressChange } =\n opts;\n\n const rawDataLength = rawData.length;\n\n useAnimatedReaction(\n () => offsetX.value,\n (_value) => {\n let value = computedOffsetXValueWithAutoFillData({\n value: _value,\n rawDataLength,\n size,\n autoFillData,\n loop,\n });\n\n if (!loop) {\n value = Math.max(\n -((rawDataLength - 1) * size),\n Math.min(value, 0)\n );\n }\n\n let absoluteProgress = Math.abs(value / size);\n\n if (value > 0) {\n absoluteProgress = rawDataLength - absoluteProgress;\n }\n\n !!onProgressChange &&\n runOnJS(onProgressChange)(value, absoluteProgress);\n },\n [loop, autoFillData, rawDataLength, onProgressChange]\n );\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.usePropsErrorBoundary=usePropsErrorBoundary;var _react=_interopRequireDefault(require("react"));function usePropsErrorBoundary(props){_react.default.useEffect(function(){var defaultIndex=props.defaultIndex,data=props.data;var viewCount=data.length;if(typeof defaultIndex==='number'&&viewCount>0){if(defaultIndex<0||defaultIndex>=viewCount){throw Error('DefaultIndex must be in the range of data length.');}}if(!props.mode||props.mode==='parallax'){if(!props.vertical&&!props.width){throw Error('`width` must be specified for
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.usePropsErrorBoundary=usePropsErrorBoundary;var _react=_interopRequireDefault(require("react"));function usePropsErrorBoundary(props){_react.default.useEffect(function(){var defaultIndex=props.defaultIndex,data=props.data;var viewCount=data.length;if(typeof defaultIndex==='number'&&viewCount>0){if(defaultIndex<0||defaultIndex>=viewCount){throw Error('DefaultIndex must be in the range of data length.');}}if(!props.mode||props.mode==='parallax'){if(!props.vertical&&!props.width){throw Error('`width` must be specified for horizontal carousels.');}if(props.vertical&&!props.height){throw Error('`height` must be specified for vertical carousels.');}}},[props]);}
|
|
2
2
|
//# sourceMappingURL=usePropsErrorBoundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["usePropsErrorBoundary.ts"],"names":["usePropsErrorBoundary","props","React","useEffect","defaultIndex","data","viewCount","length","Error","mode","vertical","width","height"],"mappings":"gMAAA,oDAGO,QAASA,CAAAA,qBAAT,CAA+BC,KAA/B,CAAsD,CACzDC,eAAMC,SAAN,CAAgB,UAAM,CAClB,GAAQC,CAAAA,YAAR,CAA+BH,KAA/B,CAAQG,YAAR,CAAsBC,IAAtB,CAA+BJ,KAA/B,CAAsBI,IAAtB,CAEA,GAAMC,CAAAA,SAAS,CAAGD,IAAI,CAACE,MAAvB,CACA,GAAI,MAAOH,CAAAA,YAAP,GAAwB,QAAxB,EAAoCE,SAAS,CAAG,CAApD,CAAuD,CACnD,GAAIF,YAAY,CAAG,CAAf,EAAoBA,YAAY,EAAIE,SAAxC,CAAmD,CAC/C,KAAME,CAAAA,KAAK,CACP,mDADO,CAAX,CAGH,CACJ,CAGD,GAAI,CAACP,KAAK,CAACQ,IAAP,EAAeR,KAAK,CAACQ,IAAN,GAAe,UAAlC,CAA8C,CAC1C,GAAI,CAACR,KAAK,CAACS,QAAP,EAAmB,CAACT,KAAK,CAACU,KAA9B,CAAqC,CACjC,KAAMH,CAAAA,KAAK,CACP,
|
|
1
|
+
{"version":3,"sources":["usePropsErrorBoundary.ts"],"names":["usePropsErrorBoundary","props","React","useEffect","defaultIndex","data","viewCount","length","Error","mode","vertical","width","height"],"mappings":"gMAAA,oDAGO,QAASA,CAAAA,qBAAT,CAA+BC,KAA/B,CAAsD,CACzDC,eAAMC,SAAN,CAAgB,UAAM,CAClB,GAAQC,CAAAA,YAAR,CAA+BH,KAA/B,CAAQG,YAAR,CAAsBC,IAAtB,CAA+BJ,KAA/B,CAAsBI,IAAtB,CAEA,GAAMC,CAAAA,SAAS,CAAGD,IAAI,CAACE,MAAvB,CACA,GAAI,MAAOH,CAAAA,YAAP,GAAwB,QAAxB,EAAoCE,SAAS,CAAG,CAApD,CAAuD,CACnD,GAAIF,YAAY,CAAG,CAAf,EAAoBA,YAAY,EAAIE,SAAxC,CAAmD,CAC/C,KAAME,CAAAA,KAAK,CACP,mDADO,CAAX,CAGH,CACJ,CAGD,GAAI,CAACP,KAAK,CAACQ,IAAP,EAAeR,KAAK,CAACQ,IAAN,GAAe,UAAlC,CAA8C,CAC1C,GAAI,CAACR,KAAK,CAACS,QAAP,EAAmB,CAACT,KAAK,CAACU,KAA9B,CAAqC,CACjC,KAAMH,CAAAA,KAAK,CACP,qDADO,CAAX,CAGH,CACD,GAAIP,KAAK,CAACS,QAAN,EAAkB,CAACT,KAAK,CAACW,MAA7B,CAAqC,CACjC,KAAMJ,CAAAA,KAAK,CACP,oDADO,CAAX,CAGH,CACJ,CACJ,CAzBD,CAyBG,CAACP,KAAD,CAzBH,EA0BH","sourcesContent":["import React from 'react';\nimport type { TCarouselProps } from 'src/types';\n\nexport function usePropsErrorBoundary(props: TCarouselProps) {\n React.useEffect(() => {\n const { defaultIndex, data } = props;\n\n const viewCount = data.length;\n if (typeof defaultIndex === 'number' && viewCount > 0) {\n if (defaultIndex < 0 || defaultIndex >= viewCount) {\n throw Error(\n 'DefaultIndex must be in the range of data length.'\n );\n }\n }\n\n // TODO\n if (!props.mode || props.mode === 'parallax') {\n if (!props.vertical && !props.width) {\n throw Error(\n '`width` must be specified for horizontal carousels.'\n );\n }\n if (props.vertical && !props.height) {\n throw Error(\n '`height` must be specified for vertical carousels.'\n );\n }\n }\n }, [props]);\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.useVisibleRanges=useVisibleRanges;var _reactNativeReanimated=require("react-native-reanimated");function useVisibleRanges(options){var _options$total=options.total,total=_options$total===void 0?0:_options$total,viewSize=options.viewSize,translation=options.translation,_options$windowSize=options.windowSize,_windowSize=_options$windowSize===void 0?0:_options$windowSize;var windowSize=total<=_windowSize?total:_windowSize;var ranges=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var positiveCount=Math.round(windowSize/2);var negativeCount=windowSize-positiveCount;var curIndex=Math.round(-translation.value/viewSize);curIndex=curIndex<0?curIndex%total+total:curIndex;var negativeRange=[(curIndex-negativeCount+total)%total,(curIndex-1+total)%total];var positiveRange=[(curIndex+total)%total,(curIndex+positiveCount+total)%total];if(negativeRange[0]<total&&negativeRange[0]>negativeRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}if(positiveRange[0]>positiveRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}return{negativeRange:negativeRange,positiveRange:positiveRange};};_f._closure={windowSize:windowSize,translation:translation,viewSize:viewSize,total:total};_f.asString="function _f(){const{windowSize,translation,viewSize,total}=jsThis._closure;{const positiveCount=Math.round(windowSize/2);const negativeCount=windowSize-positiveCount;let curIndex=Math.round(-translation.value/viewSize);curIndex=curIndex<0?curIndex%total+total:curIndex;const negativeRange=[(curIndex-negativeCount+total)%total,(curIndex-1+total)%total];const positiveRange=[(curIndex+total)%total,(curIndex+positiveCount+total)%total];if(negativeRange[0]<total&&negativeRange[0]>negativeRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}if(positiveRange[0]>positiveRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}return{negativeRange:negativeRange,positiveRange:positiveRange};}}";_f.__workletHash=15212293827170;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useVisibleRanges.tsx (24:35)";
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useVisibleRanges=useVisibleRanges;var _reactNativeReanimated=require("react-native-reanimated");function useVisibleRanges(options){var _options$total=options.total,total=_options$total===void 0?0:_options$total,viewSize=options.viewSize,translation=options.translation,_options$windowSize=options.windowSize,_windowSize=_options$windowSize===void 0?0:_options$windowSize;var windowSize=total<=_windowSize?total:_windowSize;var ranges=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var positiveCount=Math.round(windowSize/2);var negativeCount=windowSize-positiveCount;var curIndex=Math.round(-translation.value/viewSize);curIndex=curIndex<0?curIndex%total+total:curIndex;var negativeRange=[(curIndex-negativeCount+total)%total,(curIndex-1+total)%total];var positiveRange=[(curIndex+total)%total,(curIndex+positiveCount+total)%total];if(negativeRange[0]<total&&negativeRange[0]>negativeRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}if(positiveRange[0]>positiveRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}return{negativeRange:negativeRange,positiveRange:positiveRange};};_f._closure={windowSize:windowSize,translation:translation,viewSize:viewSize,total:total};_f.asString="function _f(){const{windowSize,translation,viewSize,total}=jsThis._closure;{const positiveCount=Math.round(windowSize/2);const negativeCount=windowSize-positiveCount;let curIndex=Math.round(-translation.value/viewSize);curIndex=curIndex<0?curIndex%total+total:curIndex;const negativeRange=[(curIndex-negativeCount+total)%total,(curIndex-1+total)%total];const positiveRange=[(curIndex+total)%total,(curIndex+positiveCount+total)%total];if(negativeRange[0]<total&&negativeRange[0]>negativeRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}if(positiveRange[0]>positiveRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}return{negativeRange:negativeRange,positiveRange:positiveRange};}}";_f.__workletHash=15212293827170;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useVisibleRanges.tsx (24:35)";return _f;}(),[total,windowSize,translation]);return ranges;}
|
|
2
2
|
//# sourceMappingURL=useVisibleRanges.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useVisibleRanges.tsx"],"names":["useVisibleRanges","options","total","viewSize","translation","windowSize","_windowSize","ranges","positiveCount","Math","round","negativeCount","curIndex","value","negativeRange","positiveRange"],"mappings":"mGACA,8DAOO,QAASA,CAAAA,gBAAT,CAA0BC,OAA1B,CAKY,CACf,mBAKIA,OALJ,CACIC,KADJ,CACIA,KADJ,yBACY,CADZ,gBAEIC,QAFJ,CAKIF,OALJ,CAEIE,QAFJ,CAGIC,WAHJ,CAKIH,OALJ,CAGIG,WAHJ,qBAKIH,OALJ,CAIII,UAJJ,CAIgBC,WAJhB,8BAI8B,CAJ9B,qBAOA,GAAMD,CAAAA,UAAU,CAAGH,KAAK,EAAII,WAAT,CAAuBJ,KAAvB,CAA+BI,WAAlD,CAEA,GAAMC,CAAAA,MAAM,CAAG,0EAAsB,CACjC,GAAMC,CAAAA,aAAa,CAAGC,IAAI,CAACC,KAAL,CAAWL,UAAU,CAAG,CAAxB,CAAtB,CACA,GAAMM,CAAAA,aAAa,CAAGN,UAAU,CAAGG,aAAnC,CACA,GAAII,CAAAA,QAAQ,CAAGH,IAAI,CAACC,KAAL,CAAW,CAACN,WAAW,CAACS,KAAb,CAAqBV,QAAhC,CAAf,CACAS,QAAQ,CAAGA,QAAQ,CAAG,CAAX,CAAgBA,QAAQ,CAAGV,KAAZ,CAAqBA,KAApC,CAA4CU,QAAvD,CACA,GAAME,CAAAA,aAAa,CAAG,CAClB,CAACF,QAAQ,CAAGD,aAAX,CAA2BT,KAA5B,EAAqCA,KADnB,CAElB,CAACU,QAAQ,CAAG,CAAX,CAAeV,KAAhB,EAAyBA,KAFP,CAAtB,CAIA,GAAMa,CAAAA,aAAa,CAAG,CAClB,CAACH,QAAQ,CAAGV,KAAZ,EAAqBA,KADH,CAElB,CAACU,QAAQ,CAAGJ,aAAX,CAA2BN,KAA5B,EAAqCA,KAFnB,CAAtB,CAIA,GAAIY,aAAa,CAAC,CAAD,CAAb,CAAmBZ,KAAnB,EAA4BY,aAAa,CAAC,CAAD,CAAb,CAAmBA,aAAa,CAAC,CAAD,CAAhE,CAAqE,CACjEA,aAAa,CAAC,CAAD,CAAb,CAAmBZ,KAAK,CAAG,CAA3B,CACAa,aAAa,CAAC,CAAD,CAAb,CAAmB,CAAnB,CACH,CACD,GAAIA,aAAa,CAAC,CAAD,CAAb,CAAmBA,aAAa,CAAC,CAAD,CAApC,CAAyC,CACrCD,aAAa,CAAC,CAAD,CAAb,CAAmBZ,KAAK,CAAG,CAA3B,CACAa,aAAa,CAAC,CAAD,CAAb,CAAmB,CAAnB,CACH,CACD,MAAO,CAAED,aAAa,CAAbA,aAAF,CAAiBC,aAAa,CAAbA,aAAjB,CAAP,CACH,CAtBc,yBApBKV,UAoBL,aAnBUD,WAmBV,UAnB8BD,QAmB9B,OARID,KAQJ,
|
|
1
|
+
{"version":3,"sources":["useVisibleRanges.tsx"],"names":["useVisibleRanges","options","total","viewSize","translation","windowSize","_windowSize","ranges","positiveCount","Math","round","negativeCount","curIndex","value","negativeRange","positiveRange"],"mappings":"mGACA,8DAOO,QAASA,CAAAA,gBAAT,CAA0BC,OAA1B,CAKY,CACf,mBAKIA,OALJ,CACIC,KADJ,CACIA,KADJ,yBACY,CADZ,gBAEIC,QAFJ,CAKIF,OALJ,CAEIE,QAFJ,CAGIC,WAHJ,CAKIH,OALJ,CAGIG,WAHJ,qBAKIH,OALJ,CAIII,UAJJ,CAIgBC,WAJhB,8BAI8B,CAJ9B,qBAOA,GAAMD,CAAAA,UAAU,CAAGH,KAAK,EAAII,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tBc,yBApBKV,UAoBL,aAnBUD,WAmBV,UAnB8BD,QAmB9B,OARID,KAQJ,y2BAsBZ,CAACA,KAAD,CAAQG,UAAR,CAAoBD,WAApB,CAtBY,CAAf,CAwBA,MAAOG,CAAAA,MAAP,CACH","sourcesContent":["import type Animated from 'react-native-reanimated';\nimport { useDerivedValue } from 'react-native-reanimated';\n\nexport type IVisibleRanges = Animated.SharedValue<{\n negativeRange: number[];\n positiveRange: number[];\n}>;\n\nexport function useVisibleRanges(options: {\n total: number;\n viewSize: number;\n windowSize?: number;\n translation: Animated.SharedValue<number>;\n}): IVisibleRanges {\n const {\n total = 0,\n viewSize,\n translation,\n windowSize: _windowSize = 0,\n } = options;\n\n const windowSize = total <= _windowSize ? total : _windowSize;\n\n const ranges = useDerivedValue(() => {\n const positiveCount = Math.round(windowSize / 2);\n const negativeCount = windowSize - positiveCount;\n let curIndex = Math.round(-translation.value / viewSize);\n curIndex = curIndex < 0 ? (curIndex % total) + total : curIndex;\n const negativeRange = [\n (curIndex - negativeCount + total) % total,\n (curIndex - 1 + total) % total,\n ];\n const positiveRange = [\n (curIndex + total) % total,\n (curIndex + positiveCount + total) % total,\n ];\n if (negativeRange[0] < total && negativeRange[0] > negativeRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n if (positiveRange[0] > positiveRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n return { negativeRange, positiveRange };\n }, [total, windowSize, translation]);\n\n return ranges;\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.BaseLayout=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useCheckMounted=require("../hooks/useCheckMounted");var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _store=require("../store");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var BaseLayout=function BaseLayout(props){var mounted=(0,_useCheckMounted.useCheckMounted)();var handlerOffsetX=props.handlerOffsetX,index=props.index,children=props.children,visibleRanges=props.visibleRanges,animationStyle=props.animationStyle;var context=_react.default.useContext(_store.CTX);var _context$props=context.props,loop=_context$props.loop,data=_context$props.data,width=_context$props.width,height=_context$props.height,vertical=_context$props.vertical,customConfig=_context$props.customConfig,mode=_context$props.mode,modeConfig=_context$props.modeConfig;var size=vertical?height:width;var _React$useState=_react.default.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),shouldUpdate=_React$useState2[0],setShouldUpdate=_React$useState2[1];var offsetXConfig=_objectSpread({handlerOffsetX:handlerOffsetX,index:index,size:size,data:data,loop:loop},typeof customConfig==='function'?customConfig():{});if(mode==='horizontal-stack'){var _ref=modeConfig,snapDirection=_ref.snapDirection,showLength=_ref.showLength;offsetXConfig={handlerOffsetX:handlerOffsetX,index:index,size:size,data:data,loop:loop,type:snapDirection==='right'?'negative':'positive',viewCount:showLength};}var x=(0,_useOffsetX.useOffsetX)(offsetXConfig,visibleRanges);var animationValue=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){return x.value/size;};_f._closure={x:x,size:size};_f.asString="function _f(){const{x,size}=jsThis._closure;{return x.value/size;}}";_f.__workletHash=9077192607952;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (71:43)";
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.BaseLayout=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useCheckMounted=require("../hooks/useCheckMounted");var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _store=require("../store");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var BaseLayout=function BaseLayout(props){var mounted=(0,_useCheckMounted.useCheckMounted)();var handlerOffsetX=props.handlerOffsetX,index=props.index,children=props.children,visibleRanges=props.visibleRanges,animationStyle=props.animationStyle;var context=_react.default.useContext(_store.CTX);var _context$props=context.props,loop=_context$props.loop,data=_context$props.data,width=_context$props.width,height=_context$props.height,vertical=_context$props.vertical,customConfig=_context$props.customConfig,mode=_context$props.mode,modeConfig=_context$props.modeConfig;var size=vertical?height:width;var _React$useState=_react.default.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),shouldUpdate=_React$useState2[0],setShouldUpdate=_React$useState2[1];var offsetXConfig=_objectSpread({handlerOffsetX:handlerOffsetX,index:index,size:size,data:data,loop:loop},typeof customConfig==='function'?customConfig():{});if(mode==='horizontal-stack'){var _ref=modeConfig,snapDirection=_ref.snapDirection,showLength=_ref.showLength;offsetXConfig={handlerOffsetX:handlerOffsetX,index:index,size:size,data:data,loop:loop,type:snapDirection==='right'?'negative':'positive',viewCount:showLength};}var x=(0,_useOffsetX.useOffsetX)(offsetXConfig,visibleRanges);var animationValue=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){return x.value/size;};_f._closure={x:x,size:size};_f.asString="function _f(){const{x,size}=jsThis._closure;{return x.value/size;}}";_f.__workletHash=9077192607952;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (71:43)";return _f;}(),[x,size]);var animatedStyle=(0,_reactNativeReanimated.useAnimatedStyle)(function(){var _f=function _f(){return animationStyle(x.value/size);};_f._closure={animationStyle:animationStyle,x:x,size:size};_f.asString="function _f(){const{animationStyle,x,size}=jsThis._closure;{return animationStyle(x.value/size);}}";_f.__workletHash=3916054905053;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (74:8)";_f.__optimalization=2;return _f;}(),[animationStyle]);var updateView=_react.default.useCallback(function(negativeRange,positiveRange){mounted.current&&setShouldUpdate(index>=negativeRange[0]&&index<=negativeRange[1]||index>=positiveRange[0]&&index<=positiveRange[1]);},[index,mounted]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return visibleRanges.value;};_f._closure={visibleRanges:visibleRanges};_f.asString="function _f(){const{visibleRanges}=jsThis._closure;{return visibleRanges.value;}}";_f.__workletHash=15231519758579;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (90:8)";return _f;}(),function(){var _f=function _f(){(0,_reactNativeReanimated.runOnJS)(updateView)(visibleRanges.value.negativeRange,visibleRanges.value.positiveRange);};_f._closure={runOnJS:_reactNativeReanimated.runOnJS,updateView:updateView,visibleRanges:visibleRanges};_f.asString="function _f(){const{runOnJS,updateView,visibleRanges}=jsThis._closure;{runOnJS(updateView)(visibleRanges.value.negativeRange,visibleRanges.value.positiveRange);}}";_f.__workletHash=6352504350554;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (91:8)";return _f;}(),[visibleRanges.value]);return _react.default.createElement(_reactNativeReanimated.default.View,{style:[{width:width||'100%',height:height||'100%',position:'absolute'},animatedStyle],__self:_this,__source:{fileName:_jsxFileName,lineNumber:101,columnNumber:9}},_react.default.createElement(_LazyView.LazyView,{shouldUpdate:shouldUpdate,__self:_this,__source:{fileName:_jsxFileName,lineNumber:111,columnNumber:13}},children({animationValue:animationValue})));};exports.BaseLayout=BaseLayout;
|
|
2
2
|
//# sourceMappingURL=BaseLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["BaseLayout.tsx"],"names":["BaseLayout","props","mounted","handlerOffsetX","index","children","visibleRanges","animationStyle","context","React","useContext","CTX","loop","data","width","height","vertical","customConfig","mode","modeConfig","size","useState","shouldUpdate","setShouldUpdate","offsetXConfig","snapDirection","showLength","type","viewCount","x","animationValue","value","animatedStyle","updateView","useCallback","negativeRange","positiveRange","current","runOnJS","position"],"mappings":"gWAAA,oDAEA,uFAOA,yDACA,+CAEA,qCACA,+B,q4DAKO,GAAMA,CAAAA,UAQX,CAAG,QARQA,CAAAA,UAQR,CAACC,KAAD,CAAW,CACZ,GAAMC,CAAAA,OAAO,CAAG,sCAAhB,CACA,GAAQC,CAAAA,cAAR,CACIF,KADJ,CAAQE,cAAR,CAAw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CAAEF,UAPC,CAAhB,CASH,CAED,GAAMG,CAAAA,CAAC,CAAG,2BAAWL,aAAX,CAA0BlB,aAA1B,CAAV,CACA,GAAMwB,CAAAA,cAAc,CAAG,6DAAgB,oBAAMD,CAAAA,CAAC,CAACE,KAAF,CAAUX,IAAhB,EAAhB,gBArEpBS,CAqEoB,MArEVT,IAqEU,
|
|
1
|
+
{"version":3,"sources":["BaseLayout.tsx"],"names":["BaseLayout","props","mounted","handlerOffsetX","index","children","visibleRanges","animationStyle","context","React","useContext","CTX","loop","data","width","height","vertical","customConfig","mode","modeConfig","size","useState","shouldUpdate","setShouldUpdate","offsetXConfig","snapDirection","showLength","type","viewCount","x","animationValue","value","animatedStyle","updateView","useCallback","negativeRange","positiveRange","current","runOnJS","position"],"mappings":"gWAAA,oDAEA,uFAOA,yDACA,+CAEA,qCACA,+B,q4DAKO,GAAMA,CAAAA,UAQX,CAAG,QARQA,CAAAA,UAQR,CAACC,KAAD,CAAW,CACZ,GAAMC,CAAAA,OAAO,CAAG,sCAAhB,CACA,GAAQC,CAAAA,cAAR,CACIF,KADJ,CAAQE,cAAR,CAAwBC,KAAxB,CACIH,KADJ,CAAwBG,KAAxB,CAA+BC,QAA/B,CACIJ,KADJ,CAA+BI,QAA/B,CAAyCC,aAAzC,CACIL,KADJ,CAAyCK,aAAzC,CAAwDC,cAAxD,CACIN,KADJ,CAAwDM,cAAxD,CAGA,GAAMC,CAAAA,OAAO,CAAGC,eAAMC,UAAN,CAAiBC,UAAjB,CAAhB,CACA,mBAWIH,OAXJ,CACIP,KADJ,CAEQW,IAFR,gBAEQA,IAFR,CAGQC,IAHR,gBAGQA,IAHR,CAIQC,KAJR,gBAIQA,KAJR,CAKQC,MALR,gBAKQA,MALR,CAMQC,QANR,gBAMQA,QANR,CAOQC,YAPR,gBAOQA,YAPR,CAQQC,IARR,gBAQQA,IARR,CASQC,UATR,gBASQA,UATR,CAYA,GAAMC,CAAAA,IAAI,CAAGJ,QAAQ,CAAGD,MAAH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AA0BC,aAA1B,CAAsD,CAClDlC,OAAO,CAACmC,OAAR,EACId,eAAe,CACVnB,KAAK,EAAI+B,aAAa,CAAC,CAAD,CAAtB,EAA6B/B,KAAK,EAAI+B,aAAa,CAAC,CAAD,CAApD,EACK/B,KAAK,EAAIgC,aAAa,CAAC,CAAD,CAAtB,EAA6BhC,KAAK,EAAIgC,aAAa,CAAC,CAAD,CAF7C,CADnB,CAKH,CAPc,CAQf,CAAChC,KAAD,CAAQF,OAAR,CARe,CAAnB,CAWA,iEACI,oBAAMI,CAAAA,aAAa,CAACyB,KAApB,EADJ,4BAvFGzB,aAuFH,iSAEU,CACF,mCAAQ2B,UAAR,EACI3B,aAAa,CAACyB,KAAd,CAAoBI,aADxB,CAEI7B,aAAa,CAACyB,KAAd,CAAoBK,aAFxB,EAIH,CAPL,sBAtFFE,8BAsFE,YAtFML,UAsFN,eAtFqD3B,aAsFrD,kVAQI,CAACA,aAAa,CAACyB,KAAf,CARJ,EAWA,MACI,8BAAC,8BAAD,CAAU,IAAV,EACI,KAAK,CAAE,CACH,CACIjB,KAAK,CAAEA,KAAK,EAAI,MADpB,CAEIC,MAAM,CAAEA,MAAM,EAAI,MAFtB,CAGIwB,QAAQ,CAAE,UAHd,CADG,CAMHP,aANG,CADX,8EAUI,6BAAC,kBAAD,EAAU,YAAY,CAAEV,YAAxB,+EACKjB,QAAQ,CAAC,CAAEyB,cAAc,CAAdA,cAAF,CAAD,CADb,CAVJ,CADJ,CAgBH,CAjGM,C","sourcesContent":["import React from 'react';\nimport type { ViewStyle } from 'react-native';\nimport Animated, {\n AnimatedStyleProp,\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n useDerivedValue,\n} from 'react-native-reanimated';\nimport { useCheckMounted } from 'src/hooks/useCheckMounted';\nimport { IOpts, useOffsetX } from '../hooks/useOffsetX';\nimport type { IVisibleRanges } from '../hooks/useVisibleRanges';\nimport { LazyView } from '../LazyView';\nimport { CTX } from '../store';\nimport type { ILayoutConfig } from './stack';\n\nexport type TAnimationStyle = (value: number) => AnimatedStyleProp<ViewStyle>;\n\nexport const BaseLayout: React.FC<{\n index: number;\n handlerOffsetX: Animated.SharedValue<number>;\n visibleRanges: IVisibleRanges;\n animationStyle: TAnimationStyle;\n children: (ctx: {\n animationValue: Animated.SharedValue<number>;\n }) => React.ReactElement;\n}> = (props) => {\n const mounted = useCheckMounted();\n const { handlerOffsetX, index, children, visibleRanges, animationStyle } =\n props;\n\n const context = React.useContext(CTX);\n const {\n props: {\n loop,\n data,\n width,\n height,\n vertical,\n customConfig,\n mode,\n modeConfig,\n },\n } = context;\n const size = vertical ? height : width;\n const [shouldUpdate, setShouldUpdate] = React.useState(false);\n let offsetXConfig: IOpts = {\n handlerOffsetX,\n index,\n size,\n data,\n loop,\n ...(typeof customConfig === 'function' ? customConfig() : {}),\n };\n\n if (mode === 'horizontal-stack') {\n const { snapDirection, showLength } = modeConfig as ILayoutConfig;\n\n offsetXConfig = {\n handlerOffsetX,\n index,\n size,\n data,\n loop,\n type: snapDirection === 'right' ? 'negative' : 'positive',\n viewCount: showLength,\n };\n }\n\n const x = useOffsetX(offsetXConfig, visibleRanges);\n const animationValue = useDerivedValue(() => x.value / size, [x, size]);\n const animatedStyle = useAnimatedStyle(\n // @ts-ignore\n () => animationStyle(x.value / size),\n [animationStyle]\n );\n\n const updateView = React.useCallback(\n (negativeRange: number[], positiveRange: number[]) => {\n mounted.current &&\n setShouldUpdate(\n (index >= negativeRange[0] && index <= negativeRange[1]) ||\n (index >= positiveRange[0] && index <= positiveRange[1])\n );\n },\n [index, mounted]\n );\n\n useAnimatedReaction(\n () => visibleRanges.value,\n () => {\n runOnJS(updateView)(\n visibleRanges.value.negativeRange,\n visibleRanges.value.positiveRange\n );\n },\n [visibleRanges.value]\n );\n\n return (\n <Animated.View\n style={[\n {\n width: width || '100%',\n height: height || '100%',\n position: 'absolute',\n },\n animatedStyle,\n ]}\n >\n <LazyView shouldUpdate={shouldUpdate}>\n {children({ animationValue })}\n </LazyView>\n </Animated.View>\n );\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ParallaxLayout=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var ParallaxLayout=function ParallaxLayout(props){var handlerOffsetX=props.handlerOffsetX,_props$parallaxScroll=props.parallaxScrollingOffset,parallaxScrollingOffset=_props$parallaxScroll===void 0?100:_props$parallaxScroll,_props$parallaxScroll2=props.parallaxScrollingScale,parallaxScrollingScale=_props$parallaxScroll2===void 0?0.8:_props$parallaxScroll2,_props$parallaxAdjace=props.parallaxAdjacentItemScale,parallaxAdjacentItemScale=_props$parallaxAdjace===void 0?Math.pow(parallaxScrollingScale,2):_props$parallaxAdjace,index=props.index,width=props.width,height=props.height,loop=props.loop,data=props.data,children=props.children,visibleRanges=props.visibleRanges,vertical=props.vertical;var _React$useState=_react.default.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),shouldUpdate=_React$useState2[0],setShouldUpdate=_React$useState2[1];var size=props.vertical?props.height:props.width;var x=(0,_useOffsetX.useOffsetX)({handlerOffsetX:handlerOffsetX,index:index,size:size,data:data,loop:loop},visibleRanges);var offsetXStyle=(0,_reactNativeReanimated.useAnimatedStyle)(function(){var _f=function _f(){var value=x.value/size;var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset],_reactNativeReanimated.Extrapolate.EXTEND);var zIndex=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[0,size,0],_reactNativeReanimated.Extrapolate.CLAMP);var scale=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],_reactNativeReanimated.Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};};_f._closure={x:x,size:size,interpolate:_reactNativeReanimated.interpolate,parallaxScrollingOffset:parallaxScrollingOffset,Extrapolate:{EXTEND:_reactNativeReanimated.Extrapolate.EXTEND,CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},parallaxAdjacentItemScale:parallaxAdjacentItemScale,parallaxScrollingScale:parallaxScrollingScale,vertical:vertical};_f.asString="function _f(){const{x,size,interpolate,parallaxScrollingOffset,Extrapolate,parallaxAdjacentItemScale,parallaxScrollingScale,vertical}=jsThis._closure;{const value=x.value/size;const translate=interpolate(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset],Extrapolate.EXTEND);const zIndex=interpolate(value,[-1,0,1],[0,size,0],Extrapolate.CLAMP);const scale=interpolate(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};}}";_f.__workletHash=10412925648231;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (56:42)";_f.__optimalization=3;
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ParallaxLayout=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var ParallaxLayout=function ParallaxLayout(props){var handlerOffsetX=props.handlerOffsetX,_props$parallaxScroll=props.parallaxScrollingOffset,parallaxScrollingOffset=_props$parallaxScroll===void 0?100:_props$parallaxScroll,_props$parallaxScroll2=props.parallaxScrollingScale,parallaxScrollingScale=_props$parallaxScroll2===void 0?0.8:_props$parallaxScroll2,_props$parallaxAdjace=props.parallaxAdjacentItemScale,parallaxAdjacentItemScale=_props$parallaxAdjace===void 0?Math.pow(parallaxScrollingScale,2):_props$parallaxAdjace,index=props.index,width=props.width,height=props.height,loop=props.loop,data=props.data,children=props.children,visibleRanges=props.visibleRanges,vertical=props.vertical;var _React$useState=_react.default.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),shouldUpdate=_React$useState2[0],setShouldUpdate=_React$useState2[1];var size=props.vertical?props.height:props.width;var x=(0,_useOffsetX.useOffsetX)({handlerOffsetX:handlerOffsetX,index:index,size:size,data:data,loop:loop},visibleRanges);var offsetXStyle=(0,_reactNativeReanimated.useAnimatedStyle)(function(){var _f=function _f(){var value=x.value/size;var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset],_reactNativeReanimated.Extrapolate.EXTEND);var zIndex=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[0,size,0],_reactNativeReanimated.Extrapolate.CLAMP);var scale=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],_reactNativeReanimated.Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};};_f._closure={x:x,size:size,interpolate:_reactNativeReanimated.interpolate,parallaxScrollingOffset:parallaxScrollingOffset,Extrapolate:{EXTEND:_reactNativeReanimated.Extrapolate.EXTEND,CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},parallaxAdjacentItemScale:parallaxAdjacentItemScale,parallaxScrollingScale:parallaxScrollingScale,vertical:vertical};_f.asString="function _f(){const{x,size,interpolate,parallaxScrollingOffset,Extrapolate,parallaxAdjacentItemScale,parallaxScrollingScale,vertical}=jsThis._closure;{const value=x.value/size;const translate=interpolate(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset],Extrapolate.EXTEND);const zIndex=interpolate(value,[-1,0,1],[0,size,0],Extrapolate.CLAMP);const scale=interpolate(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};}}";_f.__workletHash=10412925648231;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (56:42)";_f.__optimalization=3;return _f;}(),[loop,vertical,parallaxScrollingOffset]);var updateView=_react.default.useCallback(function(negativeRange,positiveRange){setShouldUpdate(index>=negativeRange[0]&&index<=negativeRange[1]||index>=positiveRange[0]&&index<=positiveRange[1]);},[index]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return visibleRanges.value;};_f._closure={visibleRanges:visibleRanges};_f.asString="function _f(){const{visibleRanges}=jsThis._closure;{return visibleRanges.value;}}";_f.__workletHash=15231519758579;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (116:8)";return _f;}(),function(){var _f=function _f(){(0,_reactNativeReanimated.runOnJS)(updateView)(visibleRanges.value.negativeRange,visibleRanges.value.positiveRange);};_f._closure={runOnJS:_reactNativeReanimated.runOnJS,updateView:updateView,visibleRanges:visibleRanges};_f.asString="function _f(){const{runOnJS,updateView,visibleRanges}=jsThis._closure;{runOnJS(updateView)(visibleRanges.value.negativeRange,visibleRanges.value.positiveRange);}}";_f.__workletHash=6352504350554;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (117:8)";return _f;}(),[visibleRanges.value]);return _react.default.createElement(_reactNativeReanimated.default.View,{style:[{width:width||'100%',height:height||'100%',position:'absolute'},offsetXStyle],__self:_this,__source:{fileName:_jsxFileName,lineNumber:127,columnNumber:9}},_react.default.createElement(_LazyView.LazyView,{shouldUpdate:shouldUpdate,__self:_this,__source:{fileName:_jsxFileName,lineNumber:137,columnNumber:13}},children));};exports.ParallaxLayout=ParallaxLayout;
|
|
2
2
|
//# sourceMappingURL=ParallaxLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ParallaxLayout.tsx"],"names":["ParallaxLayout","props","handlerOffsetX","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","Math","pow","index","width","height","loop","data","children","visibleRanges","vertical","React","useState","shouldUpdate","setShouldUpdate","size","x","offsetXStyle","value","translate","Extrapolate","EXTEND","zIndex","CLAMP","scale","transform","translateY","translateX","interpolate","updateView","useCallback","negativeRange","positiveRange","runOnJS","position"],"mappings":"sQAAA,oDACA,uFAQA,+CAEA,qC,unCAGO,GAAMA,CAAAA,cAUZ,CAAG,QAVSA,CAAAA,cAUT,CAACC,KAAD,CAAW,CACX,GACIC,CAAAA,cADJ,CAaID,KAbJ,CACIC,cADJ,uBAaID,KAbJ,CAEIE,uBAFJ,CAEIA,uBAFJ,gCAE8B,GAF9B,8CAaIF,KAbJ,CAGIG,sBAHJ,CAGIA,sBAHJ,iCAG6B,GAH7B,8CAaIH,KAbJ,CAIII,yBAJJ,CAIIA,yBAJJ,gCAIgCC,IAAI,CAACC,GAAL,CAASH,sBAAT,CAAiC,CAAjC,CAJhC,uBAKII,KALJ,CAaIP,KAbJ,CAKIO,KALJ,CAMIC,KANJ,CAaIR,KAbJ,CAMIQ,KANJ,CAOIC,MAPJ,CAaIT,KAbJ,CAOIS,MAPJ,CAQIC,IARJ,CAaIV,KAbJ,CAQIU,IARJ,CASIC,IATJ,CAaIX,KAbJ,CASIW,IATJ,CAUIC,QAVJ,CAaIZ,KAbJ,CAUIY,QAVJ,CAWIC,aAXJ,CAaIb,KAbJ,CAWIa,aAXJ,CAYIC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K,KAAK,CAALA,KADJ,CARO,CADR,CAaHF,MAAM,CAANA,MAbG,CAAP,CAeH,CA/CoB,gBArDTN,CAqDS,MAnD2BD,IAmD3B,aAlDTa,kCAkDS,yBApDsE9B,uBAoDtE,qBApDgGsB,mCAAYC,MAoD5G,OAlDsGD,mCAAYG,KAkDlH,4BAlD0EvB,yBAkD1E,wBAlDkDD,sBAkDlD,UAhDTW,QAgDS,
|
|
1
|
+
{"version":3,"sources":["ParallaxLayout.tsx"],"names":["ParallaxLayout","props","handlerOffsetX","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","Math","pow","index","width","height","loop","data","children","visibleRanges","vertical","React","useState","shouldUpdate","setShouldUpdate","size","x","offsetXStyle","value","translate","Extrapolate","EXTEND","zIndex","CLAMP","scale","transform","translateY","translateX","interpolate","updateView","useCallback","negativeRange","positiveRange","runOnJS","position"],"mappings":"sQAAA,oDACA,uFAQA,+CAEA,qC,unCAGO,GAAMA,CAAAA,cAUZ,CAAG,QAVSA,CAAAA,cAUT,CAACC,KAAD,CAAW,CACX,GACIC,CAAAA,cADJ,CAaID,KAbJ,CACIC,cADJ,uBAaID,KAbJ,CAEIE,uBAFJ,CAEIA,uBAFJ,gCAE8B,GAF9B,8CAaIF,KAbJ,CAGIG,sBAHJ,CAGIA,sBAHJ,iCAG6B,GAH7B,8CAaIH,KAbJ,CAIII,yBAJJ,CAIIA,yBAJJ,gCAIgCC,IAAI,CAACC,GAAL,CAASH,sBAAT,CAAiC,CAAjC,CAJhC,uBAKII,KALJ,CAaIP,KAbJ,CAKIO,KALJ,CAMIC,KANJ,CAaIR,KAbJ,CAMIQ,KANJ,CAOIC,MAPJ,CAaIT,KAbJ,CAOIS,MAPJ,CAQIC,IARJ,CAaIV,KAbJ,CAQIU,IARJ,CASIC,IATJ,CAaIX,KAbJ,CASIW,IATJ,CAUIC,QAVJ,CAaIZ,KAbJ,CAUIY,QAVJ,CAWIC,aAXJ,CAaIb,KAbJ,CAWIa,aAXJ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,CA7HM,C","sourcesContent":["import React from 'react';\nimport Animated, {\n Extrapolate,\n interpolate,\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n} from 'react-native-reanimated';\nimport type { ComputedDirectionTypes } from 'src/types';\nimport { useOffsetX } from '../hooks/useOffsetX';\nimport type { IVisibleRanges } from '../hooks/useVisibleRanges';\nimport { LazyView } from '../LazyView';\nimport type { ILayoutConfig } from './parallax';\n\nexport const ParallaxLayout: React.FC<\n ComputedDirectionTypes<\n {\n loop?: boolean;\n handlerOffsetX: Animated.SharedValue<number>;\n index: number;\n data: unknown[];\n visibleRanges: IVisibleRanges;\n } & ILayoutConfig\n >\n> = (props) => {\n const {\n handlerOffsetX,\n parallaxScrollingOffset = 100,\n parallaxScrollingScale = 0.8,\n parallaxAdjacentItemScale = Math.pow(parallaxScrollingScale, 2),\n index,\n width,\n height,\n loop,\n data,\n children,\n visibleRanges,\n vertical,\n } = props;\n\n const [shouldUpdate, setShouldUpdate] = React.useState(false);\n\n const size = props.vertical ? props.height : props.width;\n\n const x = useOffsetX(\n {\n handlerOffsetX,\n index,\n size,\n data,\n loop,\n },\n visibleRanges\n );\n\n const offsetXStyle = useAnimatedStyle(() => {\n const value = x.value / size;\n\n const translate = interpolate(\n value,\n [-1, 0, 1],\n [\n -size + parallaxScrollingOffset,\n 0,\n size - parallaxScrollingOffset,\n ],\n Extrapolate.EXTEND\n );\n\n const zIndex = interpolate(\n value,\n [-1, 0, 1],\n [0, size, 0],\n Extrapolate.CLAMP\n );\n\n const scale = interpolate(\n value,\n [-1, 0, 1],\n [\n parallaxAdjacentItemScale,\n parallaxScrollingScale,\n parallaxAdjacentItemScale,\n ],\n Extrapolate.CLAMP\n );\n\n return {\n transform: [\n vertical\n ? {\n translateY: translate,\n }\n : {\n translateX: translate,\n },\n {\n scale,\n },\n ],\n zIndex,\n };\n }, [loop, vertical, parallaxScrollingOffset]);\n\n const updateView = React.useCallback(\n (negativeRange: number[], positiveRange: number[]) => {\n setShouldUpdate(\n (index >= negativeRange[0] && index <= negativeRange[1]) ||\n (index >= positiveRange[0] && index <= positiveRange[1])\n );\n },\n [index]\n );\n\n useAnimatedReaction(\n () => visibleRanges.value,\n () => {\n runOnJS(updateView)(\n visibleRanges.value.negativeRange,\n visibleRanges.value.positiveRange\n );\n },\n [visibleRanges.value]\n );\n\n return (\n <Animated.View\n style={[\n {\n width: width || '100%',\n height: height || '100%',\n position: 'absolute',\n },\n offsetXStyle,\n ]}\n >\n <LazyView shouldUpdate={shouldUpdate}>{children}</LazyView>\n </Animated.View>\n );\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.normalLayout=normalLayout;var _reactNativeReanimated=require("react-native-reanimated");function normalLayout(opts){var size=opts.size,vertical=opts.vertical;return function(){var _f=function _f(value){var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size,0,size]);return{transform:[vertical?{translateY:translate}:{translateX:translate}]};};_f._closure={interpolate:_reactNativeReanimated.interpolate,size:size,vertical:vertical};_f.asString="function _f(value){const{interpolate,size,vertical}=jsThis._closure;{const translate=interpolate(value,[-1,0,1],[-size,0,size]);return{transform:[vertical?{translateY:translate}:{translateX:translate}]};}}";_f.__workletHash=10942319418565;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/normal.ts (6:11)";
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.normalLayout=normalLayout;var _reactNativeReanimated=require("react-native-reanimated");function normalLayout(opts){var size=opts.size,vertical=opts.vertical;return function(){var _f=function _f(value){var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size,0,size]);return{transform:[vertical?{translateY:translate}:{translateX:translate}]};};_f._closure={interpolate:_reactNativeReanimated.interpolate,size:size,vertical:vertical};_f.asString="function _f(value){const{interpolate,size,vertical}=jsThis._closure;{const translate=interpolate(value,[-1,0,1],[-size,0,size]);return{transform:[vertical?{translateY:translate}:{translateX:translate}]};}}";_f.__workletHash=10942319418565;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/normal.ts (6:11)";return _f;}();}
|
|
2
2
|
//# sourceMappingURL=normal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["normal.ts"],"names":["normalLayout","opts","size","vertical","value","translate","transform","translateY","translateX","interpolate"],"mappings":"2FAAA,8DAEO,QAASA,CAAAA,YAAT,CAAsBC,IAAtB,CAAiE,CACpE,GAAQC,CAAAA,IAAR,CAA2BD,IAA3B,CAAQC,IAAR,CAAcC,QAAd,CAA2BF,IAA3B,CAAcE,QAAd,CAEA,qCAAQC,KAAR,CAA0B,CAEtB,GAAMC,CAAAA,SAAS,CAAG,uCAAYD,KAAZ,CAAmB,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAAnB,CAA+B,CAAC,CAACF,IAAF,CAAQ,CAAR,CAAWA,IAAX,CAA/B,CAAlB,CAEA,MAAO,CACHI,SAAS,CAAE,CACPH,QAAQ,CACF,CACII,UAAU,CAAEF,SADhB,CADE,CAIF,CACIG,UAAU,CAAEH,SADhB,CALC,CADR,CAAP,CAWH,CAfD,0BAHgBI,kCAGhB,MAH0DP,IAG1D,UADYC,QACZ,
|
|
1
|
+
{"version":3,"sources":["normal.ts"],"names":["normalLayout","opts","size","vertical","value","translate","transform","translateY","translateX","interpolate"],"mappings":"2FAAA,8DAEO,QAASA,CAAAA,YAAT,CAAsBC,IAAtB,CAAiE,CACpE,GAAQC,CAAAA,IAAR,CAA2BD,IAA3B,CAAQC,IAAR,CAAcC,QAAd,CAA2BF,IAA3B,CAAcE,QAAd,CAEA,qCAAQC,KAAR,CAA0B,CAEtB,GAAMC,CAAAA,SAAS,CAAG,uCAAYD,KAAZ,CAAmB,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAAnB,CAA+B,CAAC,CAACF,IAAF,CAAQ,CAAR,CAAWA,IAAX,CAA/B,CAAlB,CAEA,MAAO,CACHI,SAAS,CAAE,CACPH,QAAQ,CACF,CACII,UAAU,CAAEF,SADhB,CADE,CAIF,CACIG,UAAU,CAAEH,SADhB,CALC,CADR,CAAP,CAWH,CAfD,0BAHgBI,kCAGhB,MAH0DP,IAG1D,UADYC,QACZ,yXAgBH","sourcesContent":["import { interpolate } from 'react-native-reanimated';\n\nexport function normalLayout(opts: { size: number; vertical: boolean }) {\n const { size, vertical } = opts;\n\n return (value: number) => {\n 'worklet';\n const translate = interpolate(value, [-1, 0, 1], [-size, 0, size]);\n\n return {\n transform: [\n vertical\n ? {\n translateY: translate,\n }\n : {\n translateX: translate,\n },\n ],\n };\n };\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.parallaxLayout=parallaxLayout;var _reactNativeReanimated=require("react-native-reanimated");function parallaxLayout(baseConfig){var modeConfig=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var size=baseConfig.size,vertical=baseConfig.vertical;var _modeConfig$parallaxS=modeConfig.parallaxScrollingOffset,parallaxScrollingOffset=_modeConfig$parallaxS===void 0?100:_modeConfig$parallaxS,_modeConfig$parallaxS2=modeConfig.parallaxScrollingScale,parallaxScrollingScale=_modeConfig$parallaxS2===void 0?0.8:_modeConfig$parallaxS2,_modeConfig$parallaxA=modeConfig.parallaxAdjacentItemScale,parallaxAdjacentItemScale=_modeConfig$parallaxA===void 0?Math.pow(parallaxScrollingScale,2):_modeConfig$parallaxA;return function(){var _f=function _f(value){var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset]);var zIndex=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[0,size,0],_reactNativeReanimated.Extrapolate.CLAMP);var scale=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],_reactNativeReanimated.Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};};_f._closure={interpolate:_reactNativeReanimated.interpolate,size:size,parallaxScrollingOffset:parallaxScrollingOffset,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},parallaxAdjacentItemScale:parallaxAdjacentItemScale,parallaxScrollingScale:parallaxScrollingScale,vertical:vertical};_f.asString="function _f(value){const{interpolate,size,parallaxScrollingOffset,Extrapolate,parallaxAdjacentItemScale,parallaxScrollingScale,vertical}=jsThis._closure;{const translate=interpolate(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset]);const zIndex=interpolate(value,[-1,0,1],[0,size,0],Extrapolate.CLAMP);const scale=interpolate(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};}}";_f.__workletHash=942233491674;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/parallax.ts (46:11)";
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.parallaxLayout=parallaxLayout;var _reactNativeReanimated=require("react-native-reanimated");function parallaxLayout(baseConfig){var modeConfig=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var size=baseConfig.size,vertical=baseConfig.vertical;var _modeConfig$parallaxS=modeConfig.parallaxScrollingOffset,parallaxScrollingOffset=_modeConfig$parallaxS===void 0?100:_modeConfig$parallaxS,_modeConfig$parallaxS2=modeConfig.parallaxScrollingScale,parallaxScrollingScale=_modeConfig$parallaxS2===void 0?0.8:_modeConfig$parallaxS2,_modeConfig$parallaxA=modeConfig.parallaxAdjacentItemScale,parallaxAdjacentItemScale=_modeConfig$parallaxA===void 0?Math.pow(parallaxScrollingScale,2):_modeConfig$parallaxA;return function(){var _f=function _f(value){var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset]);var zIndex=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[0,size,0],_reactNativeReanimated.Extrapolate.CLAMP);var scale=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],_reactNativeReanimated.Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};};_f._closure={interpolate:_reactNativeReanimated.interpolate,size:size,parallaxScrollingOffset:parallaxScrollingOffset,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},parallaxAdjacentItemScale:parallaxAdjacentItemScale,parallaxScrollingScale:parallaxScrollingScale,vertical:vertical};_f.asString="function _f(value){const{interpolate,size,parallaxScrollingOffset,Extrapolate,parallaxAdjacentItemScale,parallaxScrollingScale,vertical}=jsThis._closure;{const translate=interpolate(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset]);const zIndex=interpolate(value,[-1,0,1],[0,size,0],Extrapolate.CLAMP);const scale=interpolate(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};}}";_f.__workletHash=942233491674;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/parallax.ts (46:11)";return _f;}();}
|
|
2
2
|
//# sourceMappingURL=parallax.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["parallax.ts"],"names":["parallaxLayout","baseConfig","modeConfig","size","vertical","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","Math","pow","value","translate","zIndex","Extrapolate","CLAMP","scale","transform","translateY","translateX","interpolate"],"mappings":"+FAAA,8DAkCO,QAASA,CAAAA,cAAT,CACHC,UADG,CAGL,IADEC,CAAAA,UACF,2DAD8B,EAC9B,CACE,GAAQC,CAAAA,IAA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CZ,
|
|
1
|
+
{"version":3,"sources":["parallax.ts"],"names":["parallaxLayout","baseConfig","modeConfig","size","vertical","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","Math","pow","value","translate","zIndex","Extrapolate","CLAMP","scale","transform","translateY","translateX","interpolate"],"mappings":"+FAAA,8DAkCO,QAASA,CAAAA,cAAT,CACHC,UADG,CAGL,IADEC,CAAAA,UACF,2DAD8B,EAC9B,CACE,GAAQC,CAAAA,IAAR,CAA2BF,UAA3B,CAAQE,IAAR,CAAcC,QAAd,CAA2BH,UAA3B,CAAcG,QAAd,CACA,0BAIIF,UAJJ,CACIG,uBADJ,CACIA,uBADJ,gCAC8B,GAD9B,8CAIIH,UAJJ,CAEII,sBAFJ,CAEIA,sBAFJ,iCAE6B,GAF7B,8CAIIJ,UAJJ,CAGIK,yBAHJ,CAGIA,yBAHJ,gCAGgCC,IAAI,CAACC,GAAL,CAASH,sBAAT,CAAiC,CAAjC,CAHhC,uBAMA,qCAAQI,KAAR,CAA0B,CAEtB,GAAMC,CAAAA,SAAS,CAAG,uCACdD,KADc,CAEd,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAFc,CAGd,CAAC,CAACP,IAAD,CAAQE,uBAAT,CAAkC,CAAlC,CAAqCF,IAAI,CAAGE,uBAA5C,CAHc,CAAlB,CAMA,GAAMO,CAAAA,MAAM,CAAG,uCACXF,KADW,CAEX,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAFW,CAGX,CAAC,CAAD,CAAIP,IAAJ,CAAU,CAAV,CAHW,CAIXU,mCAAYC,KAJD,CAAf,CAOA,GAAMC,CAAAA,KAAK,CAAG,uCACVL,KADU,CAEV,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAFU,CAGV,CACIH,yBADJ,CAEID,sBAFJ,CAGIC,yBAHJ,CAHU,CAQVM,mCAAYC,KARF,CAAd,CAWA,MAAO,CACHE,SAAS,CAAE,CACPZ,QAAQ,CACF,CACIa,UAAU,CAAEN,SADhB,CADE,CAIF,CACIO,UAAU,CAAEP,SADhB,CALC,CAQP,CACII,KAAK,CAALA,KADJ,CARO,CADR,CAaHH,MAAM,CAANA,MAbG,CAAP,CAeH,CAzCD,0BAzCYO,kCAyCZ,MA1CgDhB,IA0ChD,yBA3C2FE,uBA2C3F,oBAzC2HQ,mCAAYC,KAyCvI,4BAzC+FP,yBAyC/F,wBAzCuED,sBAyCvE,UAvCYF,QAuCZ,wuBA0CH","sourcesContent":["import { Extrapolate, interpolate } from 'react-native-reanimated';\nimport type { ComputedDirectionTypes } from '../types';\n\ntype TBaseConfig = {\n size: number;\n vertical: boolean;\n};\n\nexport interface ILayoutConfig {\n /**\n * control prev/next item offset.\n * @default 100\n */\n parallaxScrollingOffset?: number;\n /**\n * control prev/current/next item offset.\n * @default 0.8\n */\n parallaxScrollingScale?: number;\n /**\n * control prev/next item offset.\n * @default Math.pow(parallaxScrollingScale, 2)\n */\n parallaxAdjacentItemScale?: number;\n}\n\nexport type TParallaxModeProps = ComputedDirectionTypes<{\n /**\n * Carousel Animated transitions.\n */\n mode?: 'parallax';\n modeConfig?: ILayoutConfig;\n}>;\n\nexport function parallaxLayout(\n baseConfig: TBaseConfig,\n modeConfig: ILayoutConfig = {}\n) {\n const { size, vertical } = baseConfig;\n const {\n parallaxScrollingOffset = 100,\n parallaxScrollingScale = 0.8,\n parallaxAdjacentItemScale = Math.pow(parallaxScrollingScale, 2),\n } = modeConfig;\n\n return (value: number) => {\n 'worklet';\n const translate = interpolate(\n value,\n [-1, 0, 1],\n [-size + parallaxScrollingOffset, 0, size - parallaxScrollingOffset]\n );\n\n const zIndex = interpolate(\n value,\n [-1, 0, 1],\n [0, size, 0],\n Extrapolate.CLAMP\n );\n\n const scale = interpolate(\n value,\n [-1, 0, 1],\n [\n parallaxAdjacentItemScale,\n parallaxScrollingScale,\n parallaxAdjacentItemScale,\n ],\n Extrapolate.CLAMP\n );\n\n return {\n transform: [\n vertical\n ? {\n translateY: translate,\n }\n : {\n translateX: translate,\n },\n {\n scale,\n },\n ],\n zIndex,\n };\n };\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.horizontalStackLayout=horizontalStackLayout;exports.useHorizontalStackLayout=useHorizontalStackLayout;exports.verticalStackLayout=verticalStackLayout;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=require("react");var _reactNative=require("react-native");var _reactNativeReanimated=require("react-native-reanimated");function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var screen=_reactNative.Dimensions.get('window');function horizontalStackLayout(){var modeConfig=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(){var _f=function _f(_value){var showLength=modeConfig.showLength,_modeConfig$snapDirec=modeConfig.snapDirection,snapDirection=_modeConfig$snapDirec===void 0?'left':_modeConfig$snapDirec,_modeConfig$moveSize=modeConfig.moveSize,moveSize=_modeConfig$moveSize===void 0?screen.width:_modeConfig$moveSize,_modeConfig$stackInte=modeConfig.stackInterval,stackInterval=_modeConfig$stackInte===void 0?18:_modeConfig$stackInte,_modeConfig$scaleInte=modeConfig.scaleInterval,scaleInterval=_modeConfig$scaleInte===void 0?0.04:_modeConfig$scaleInte,_modeConfig$opacityIn=modeConfig.opacityInterval,opacityInterval=_modeConfig$opacityIn===void 0?0.1:_modeConfig$opacityIn,_modeConfig$rotateZDe=modeConfig.rotateZDeg,rotateZDeg=_modeConfig$rotateZDe===void 0?30:_modeConfig$rotateZDe;var transform=[];var _getCommonVariables=getCommonVariables({showLength:showLength,value:_value,snapDirection:snapDirection}),validLength=_getCommonVariables.validLength,value=_getCommonVariables.value,inputRange=_getCommonVariables.inputRange;var _getCommonStyles=getCommonStyles({validLength:validLength,value:value,opacityInterval:opacityInterval,snapDirection:snapDirection}),zIndex=_getCommonStyles.zIndex,opacity=_getCommonStyles.opacity;var styles={transform:transform,zIndex:zIndex,opacity:opacity};var translateX;var scale;var rotateZ;if(snapDirection==='left'){translateX=(0,_reactNativeReanimated.interpolate)(value,inputRange,[-moveSize,0,validLength*stackInterval],_reactNativeReanimated.Extrapolate.CLAMP);scale=(0,_reactNativeReanimated.interpolate)(value,inputRange,[1,1,1-validLength*scaleInterval],_reactNativeReanimated.Extrapolate.CLAMP);rotateZ=(0,_reactNativeReanimated.interpolate)(value,inputRange,[-rotateZDeg,0,0],_reactNativeReanimated.Extrapolate.CLAMP)+"deg";}else if(snapDirection==='right'){translateX=(0,_reactNativeReanimated.interpolate)(value,inputRange,[-validLength*stackInterval,0,moveSize],_reactNativeReanimated.Extrapolate.CLAMP);scale=(0,_reactNativeReanimated.interpolate)(value,inputRange,[1-validLength*scaleInterval,1,1],_reactNativeReanimated.Extrapolate.CLAMP);rotateZ=(0,_reactNativeReanimated.interpolate)(value,inputRange,[0,0,rotateZDeg],_reactNativeReanimated.Extrapolate.CLAMP)+"deg";}transform.push({translateX:translateX},{scale:scale},{rotateZ:rotateZ});return styles;};_f._closure={screen:{width:screen.width},modeConfig:modeConfig,getCommonVariables:getCommonVariables,getCommonStyles:getCommonStyles,interpolate:_reactNativeReanimated.interpolate,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP}};_f.asString="function _f(_value){const{screen,modeConfig,getCommonVariables,getCommonStyles,interpolate,Extrapolate}=jsThis._closure;{const{showLength:showLength,snapDirection='left',moveSize=screen.width,stackInterval=18,scaleInterval=0.04,opacityInterval=0.1,rotateZDeg=30}=modeConfig;const transform=[];const{validLength:validLength,value:value,inputRange:inputRange}=getCommonVariables({showLength:showLength,value:_value,snapDirection:snapDirection});const{zIndex:zIndex,opacity:opacity}=getCommonStyles({validLength:validLength,value:value,opacityInterval:opacityInterval,snapDirection:snapDirection});const styles={transform:transform,zIndex:zIndex,opacity:opacity};let translateX;let scale;let rotateZ;if(snapDirection==='left'){translateX=interpolate(value,inputRange,[-moveSize,0,validLength*stackInterval],Extrapolate.CLAMP);scale=interpolate(value,inputRange,[1,1,1-validLength*scaleInterval],Extrapolate.CLAMP);rotateZ=interpolate(value,inputRange,[-rotateZDeg,0,0],Extrapolate.CLAMP)+\"deg\";}else if(snapDirection==='right'){translateX=interpolate(value,inputRange,[-validLength*stackInterval,0,moveSize],Extrapolate.CLAMP);scale=interpolate(value,inputRange,[1-validLength*scaleInterval,1,1],Extrapolate.CLAMP);rotateZ=interpolate(value,inputRange,[0,0,rotateZDeg],Extrapolate.CLAMP)+\"deg\";}transform.push({translateX:translateX},{scale:scale},{rotateZ:rotateZ});return styles;}}";_f.__workletHash=3265668150098;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/stack.ts (37:11)";global.__reanimatedWorkletInit(_f);return _f;}();}function useHorizontalStackLayout(){var customAnimationConfig=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var customConfig=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var config=(0,_react.useMemo)(function(){return _objectSpread({type:customAnimationConfig.snapDirection==='right'?'negative':'positive',viewCount:customAnimationConfig.showLength},customConfig);},[customAnimationConfig,customConfig]);return{layout:horizontalStackLayout(customAnimationConfig),config:config};}function verticalStackLayout(){var modeConfig=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(){var _f=function _f(_value){var showLength=modeConfig.showLength,_modeConfig$snapDirec2=modeConfig.snapDirection,snapDirection=_modeConfig$snapDirec2===void 0?'left':_modeConfig$snapDirec2,_modeConfig$moveSize2=modeConfig.moveSize,moveSize=_modeConfig$moveSize2===void 0?screen.width:_modeConfig$moveSize2,_modeConfig$stackInte2=modeConfig.stackInterval,stackInterval=_modeConfig$stackInte2===void 0?18:_modeConfig$stackInte2,_modeConfig$scaleInte2=modeConfig.scaleInterval,scaleInterval=_modeConfig$scaleInte2===void 0?0.04:_modeConfig$scaleInte2,_modeConfig$opacityIn2=modeConfig.opacityInterval,opacityInterval=_modeConfig$opacityIn2===void 0?0.1:_modeConfig$opacityIn2,_modeConfig$rotateZDe2=modeConfig.rotateZDeg,rotateZDeg=_modeConfig$rotateZDe2===void 0?30:_modeConfig$rotateZDe2;var transform=[];var _getCommonVariables2=getCommonVariables({showLength:showLength,value:_value,snapDirection:snapDirection}),validLength=_getCommonVariables2.validLength,value=_getCommonVariables2.value,inputRange=_getCommonVariables2.inputRange;var _getCommonStyles2=getCommonStyles({validLength:validLength,value:value,opacityInterval:opacityInterval,snapDirection:snapDirection}),zIndex=_getCommonStyles2.zIndex,opacity=_getCommonStyles2.opacity;var styles={transform:transform,zIndex:zIndex,opacity:opacity};var translateX;var scale;var rotateZ;var translateY;if(snapDirection==='left'){translateX=(0,_reactNativeReanimated.interpolate)(value,inputRange,[-moveSize,0,0],_reactNativeReanimated.Extrapolate.CLAMP);scale=(0,_reactNativeReanimated.interpolate)(value,inputRange,[1,1,1-validLength*scaleInterval],_reactNativeReanimated.Extrapolate.CLAMP);rotateZ=(0,_reactNativeReanimated.interpolate)(value,inputRange,[-rotateZDeg,0,0],_reactNativeReanimated.Extrapolate.CLAMP)+"deg";translateY=(0,_reactNativeReanimated.interpolate)(value,inputRange,[0,0,validLength*stackInterval],_reactNativeReanimated.Extrapolate.CLAMP);}else if(snapDirection==='right'){translateX=(0,_reactNativeReanimated.interpolate)(value,inputRange,[0,0,moveSize],_reactNativeReanimated.Extrapolate.CLAMP);scale=(0,_reactNativeReanimated.interpolate)(value,inputRange,[1-validLength*scaleInterval,1,1],_reactNativeReanimated.Extrapolate.CLAMP);rotateZ=(0,_reactNativeReanimated.interpolate)(value,inputRange,[0,0,rotateZDeg],_reactNativeReanimated.Extrapolate.CLAMP)+"deg";translateY=(0,_reactNativeReanimated.interpolate)(value,inputRange,[validLength*stackInterval,0,0],_reactNativeReanimated.Extrapolate.CLAMP);}transform.push({translateX:translateX},{scale:scale},{rotateZ:rotateZ},{translateY:translateY});return styles;};_f._closure={screen:{width:screen.width},modeConfig:modeConfig,getCommonVariables:getCommonVariables,getCommonStyles:getCommonStyles,interpolate:_reactNativeReanimated.interpolate,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP}};_f.asString="function _f(_value){const{screen,modeConfig,getCommonVariables,getCommonStyles,interpolate,Extrapolate}=jsThis._closure;{const{showLength:showLength,snapDirection='left',moveSize=screen.width,stackInterval=18,scaleInterval=0.04,opacityInterval=0.1,rotateZDeg=30}=modeConfig;const transform=[];const{validLength:validLength,value:value,inputRange:inputRange}=getCommonVariables({showLength:showLength,value:_value,snapDirection:snapDirection});const{zIndex:zIndex,opacity:opacity}=getCommonStyles({validLength:validLength,value:value,opacityInterval:opacityInterval,snapDirection:snapDirection});const styles={transform:transform,zIndex:zIndex,opacity:opacity};let translateX;let scale;let rotateZ;let translateY;if(snapDirection==='left'){translateX=interpolate(value,inputRange,[-moveSize,0,0],Extrapolate.CLAMP);scale=interpolate(value,inputRange,[1,1,1-validLength*scaleInterval],Extrapolate.CLAMP);rotateZ=interpolate(value,inputRange,[-rotateZDeg,0,0],Extrapolate.CLAMP)+\"deg\";translateY=interpolate(value,inputRange,[0,0,validLength*stackInterval],Extrapolate.CLAMP);}else if(snapDirection==='right'){translateX=interpolate(value,inputRange,[0,0,moveSize],Extrapolate.CLAMP);scale=interpolate(value,inputRange,[1-validLength*scaleInterval,1,1],Extrapolate.CLAMP);rotateZ=interpolate(value,inputRange,[0,0,rotateZDeg],Extrapolate.CLAMP)+\"deg\";translateY=interpolate(value,inputRange,[validLength*stackInterval,0,0],Extrapolate.CLAMP);}transform.push({translateX:translateX},{scale:scale},{rotateZ:rotateZ},{translateY:translateY});return styles;}}";_f.__workletHash=2365281434390;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/stack.ts (152:11)";global.__reanimatedWorkletInit(_f);return _f;}();}var getCommonVariables=function(){var _f=function _f(opts){var showLength=opts.showLength,_value=opts.value,snapDirection=opts.snapDirection;function easeInOutCubic(v){return v<0.5?4*v*v*v:1-Math.pow(-2*v+2,3)/2;}var page=Math.floor(Math.abs(_value));var diff=Math.abs(_value)%1;var value=_value<0?-(page+easeInOutCubic(diff)):page+easeInOutCubic(diff);var validLength=showLength-1;var inputRange;if(snapDirection==='left'){inputRange=[-1,0,validLength];}else if(snapDirection==='right'){inputRange=[-validLength,0,1];}else{throw Error('snapDirection must be set to either left or right');}return{inputRange:inputRange,validLength:validLength,value:value};};_f._closure={};_f.asString="function getCommonVariables(opts){const{showLength:showLength,value:_value,snapDirection:snapDirection}=opts;function easeInOutCubic(v){return v<0.5?4*v*v*v:1-Math.pow(-2*v+2,3)/2;}const page=Math.floor(Math.abs(_value));const diff=Math.abs(_value)%1;const value=_value<0?-(page+easeInOutCubic(diff)):page+easeInOutCubic(diff);const validLength=showLength-1;let inputRange;if(snapDirection==='left'){inputRange=[-1,0,validLength];}else if(snapDirection==='right'){inputRange=[-validLength,0,1];}else{throw Error('snapDirection must be set to either left or right');}return{inputRange:inputRange,validLength:validLength,value:value};}";_f.__workletHash=3893657980264;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/stack.ts (259:0)";global.__reanimatedWorkletInit(_f);return _f;}();var getCommonStyles=function(){var _f=function _f(opts){var snapDirection=opts.snapDirection,validLength=opts.validLength,value=opts.value,opacityInterval=opts.opacityInterval;var zIndex;var opacity;if(snapDirection==='left'){zIndex=Math.floor((0,_reactNativeReanimated.interpolate)(value,[-1.5,-1,-1+Number.MIN_VALUE,0,validLength],[Number.MIN_VALUE,validLength,validLength,validLength-1,-1])*10000)/100;opacity=(0,_reactNativeReanimated.interpolate)(value,[-1,0,validLength-1,validLength],[0.25,1,1-(validLength-1)*opacityInterval,0.25]);}else if(snapDirection==='right'){zIndex=Math.floor((0,_reactNativeReanimated.interpolate)(value,[-validLength,0,1-Number.MIN_VALUE,1,1.5],[1,validLength-1,validLength,validLength,Number.MIN_VALUE])*10000)/100;opacity=(0,_reactNativeReanimated.interpolate)(value,[-validLength,1-validLength,0,1],[0.25,1-(validLength-1)*opacityInterval,1,0.25]);}else{throw Error('snapDirection must be set to either left or right');}return{zIndex:zIndex,opacity:opacity};};_f._closure={interpolate:_reactNativeReanimated.interpolate};_f.asString="function getCommonStyles(opts){const{interpolate}=jsThis._closure;{const{snapDirection:snapDirection,validLength:validLength,value:value,opacityInterval:opacityInterval}=opts;let zIndex;let opacity;if(snapDirection==='left'){zIndex=Math.floor(interpolate(value,[-1.5,-1,-1+Number.MIN_VALUE,0,validLength],[Number.MIN_VALUE,validLength,validLength,validLength-1,-1])*10000)/100;opacity=interpolate(value,[-1,0,validLength-1,validLength],[0.25,1,1-(validLength-1)*opacityInterval,0.25]);}else if(snapDirection==='right'){zIndex=Math.floor(interpolate(value,[-validLength,0,1-Number.MIN_VALUE,1,1.5],[1,validLength-1,validLength,validLength,Number.MIN_VALUE])*10000)/100;opacity=interpolate(value,[-validLength,1-validLength,0,1],[0.25,1-(validLength-1)*opacityInterval,1,0.25]);}else{throw Error('snapDirection must be set to either left or right');}return{zIndex:zIndex,opacity:opacity};}}";_f.__workletHash=16145327689090;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/stack.ts (295:0)";global.__reanimatedWorkletInit(_f);return _f;}();
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.horizontalStackLayout=horizontalStackLayout;exports.useHorizontalStackLayout=useHorizontalStackLayout;exports.verticalStackLayout=verticalStackLayout;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=require("react");var _reactNative=require("react-native");var _reactNativeReanimated=require("react-native-reanimated");function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var screen=_reactNative.Dimensions.get('window');function horizontalStackLayout(){var modeConfig=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(){var _f=function _f(_value){var showLength=modeConfig.showLength,_modeConfig$snapDirec=modeConfig.snapDirection,snapDirection=_modeConfig$snapDirec===void 0?'left':_modeConfig$snapDirec,_modeConfig$moveSize=modeConfig.moveSize,moveSize=_modeConfig$moveSize===void 0?screen.width:_modeConfig$moveSize,_modeConfig$stackInte=modeConfig.stackInterval,stackInterval=_modeConfig$stackInte===void 0?18:_modeConfig$stackInte,_modeConfig$scaleInte=modeConfig.scaleInterval,scaleInterval=_modeConfig$scaleInte===void 0?0.04:_modeConfig$scaleInte,_modeConfig$opacityIn=modeConfig.opacityInterval,opacityInterval=_modeConfig$opacityIn===void 0?0.1:_modeConfig$opacityIn,_modeConfig$rotateZDe=modeConfig.rotateZDeg,rotateZDeg=_modeConfig$rotateZDe===void 0?30:_modeConfig$rotateZDe;var transform=[];var _getCommonVariables=getCommonVariables({showLength:showLength,value:_value,snapDirection:snapDirection}),validLength=_getCommonVariables.validLength,value=_getCommonVariables.value,inputRange=_getCommonVariables.inputRange;var _getCommonStyles=getCommonStyles({validLength:validLength,value:value,opacityInterval:opacityInterval,snapDirection:snapDirection}),zIndex=_getCommonStyles.zIndex,opacity=_getCommonStyles.opacity;var styles={transform:transform,zIndex:zIndex,opacity:opacity};var translateX;var scale;var rotateZ;if(snapDirection==='left'){translateX=(0,_reactNativeReanimated.interpolate)(value,inputRange,[-moveSize,0,validLength*stackInterval],_reactNativeReanimated.Extrapolate.CLAMP);scale=(0,_reactNativeReanimated.interpolate)(value,inputRange,[1,1,1-validLength*scaleInterval],_reactNativeReanimated.Extrapolate.CLAMP);rotateZ=(0,_reactNativeReanimated.interpolate)(value,inputRange,[-rotateZDeg,0,0],_reactNativeReanimated.Extrapolate.CLAMP)+"deg";}else if(snapDirection==='right'){translateX=(0,_reactNativeReanimated.interpolate)(value,inputRange,[-validLength*stackInterval,0,moveSize],_reactNativeReanimated.Extrapolate.CLAMP);scale=(0,_reactNativeReanimated.interpolate)(value,inputRange,[1-validLength*scaleInterval,1,1],_reactNativeReanimated.Extrapolate.CLAMP);rotateZ=(0,_reactNativeReanimated.interpolate)(value,inputRange,[0,0,rotateZDeg],_reactNativeReanimated.Extrapolate.CLAMP)+"deg";}transform.push({translateX:translateX},{scale:scale},{rotateZ:rotateZ});return styles;};_f._closure={screen:{width:screen.width},modeConfig:modeConfig,getCommonVariables:getCommonVariables,getCommonStyles:getCommonStyles,interpolate:_reactNativeReanimated.interpolate,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP}};_f.asString="function _f(_value){const{screen,modeConfig,getCommonVariables,getCommonStyles,interpolate,Extrapolate}=jsThis._closure;{const{showLength:showLength,snapDirection='left',moveSize=screen.width,stackInterval=18,scaleInterval=0.04,opacityInterval=0.1,rotateZDeg=30}=modeConfig;const transform=[];const{validLength:validLength,value:value,inputRange:inputRange}=getCommonVariables({showLength:showLength,value:_value,snapDirection:snapDirection});const{zIndex:zIndex,opacity:opacity}=getCommonStyles({validLength:validLength,value:value,opacityInterval:opacityInterval,snapDirection:snapDirection});const styles={transform:transform,zIndex:zIndex,opacity:opacity};let translateX;let scale;let rotateZ;if(snapDirection==='left'){translateX=interpolate(value,inputRange,[-moveSize,0,validLength*stackInterval],Extrapolate.CLAMP);scale=interpolate(value,inputRange,[1,1,1-validLength*scaleInterval],Extrapolate.CLAMP);rotateZ=interpolate(value,inputRange,[-rotateZDeg,0,0],Extrapolate.CLAMP)+\"deg\";}else if(snapDirection==='right'){translateX=interpolate(value,inputRange,[-validLength*stackInterval,0,moveSize],Extrapolate.CLAMP);scale=interpolate(value,inputRange,[1-validLength*scaleInterval,1,1],Extrapolate.CLAMP);rotateZ=interpolate(value,inputRange,[0,0,rotateZDeg],Extrapolate.CLAMP)+\"deg\";}transform.push({translateX:translateX},{scale:scale},{rotateZ:rotateZ});return styles;}}";_f.__workletHash=3265668150098;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/stack.ts (37:11)";return _f;}();}function useHorizontalStackLayout(){var customAnimationConfig=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var customConfig=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var config=(0,_react.useMemo)(function(){return _objectSpread({type:customAnimationConfig.snapDirection==='right'?'negative':'positive',viewCount:customAnimationConfig.showLength},customConfig);},[customAnimationConfig,customConfig]);return{layout:horizontalStackLayout(customAnimationConfig),config:config};}function verticalStackLayout(){var modeConfig=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(){var _f=function _f(_value){var showLength=modeConfig.showLength,_modeConfig$snapDirec2=modeConfig.snapDirection,snapDirection=_modeConfig$snapDirec2===void 0?'left':_modeConfig$snapDirec2,_modeConfig$moveSize2=modeConfig.moveSize,moveSize=_modeConfig$moveSize2===void 0?screen.width:_modeConfig$moveSize2,_modeConfig$stackInte2=modeConfig.stackInterval,stackInterval=_modeConfig$stackInte2===void 0?18:_modeConfig$stackInte2,_modeConfig$scaleInte2=modeConfig.scaleInterval,scaleInterval=_modeConfig$scaleInte2===void 0?0.04:_modeConfig$scaleInte2,_modeConfig$opacityIn2=modeConfig.opacityInterval,opacityInterval=_modeConfig$opacityIn2===void 0?0.1:_modeConfig$opacityIn2,_modeConfig$rotateZDe2=modeConfig.rotateZDeg,rotateZDeg=_modeConfig$rotateZDe2===void 0?30:_modeConfig$rotateZDe2;var transform=[];var _getCommonVariables2=getCommonVariables({showLength:showLength,value:_value,snapDirection:snapDirection}),validLength=_getCommonVariables2.validLength,value=_getCommonVariables2.value,inputRange=_getCommonVariables2.inputRange;var _getCommonStyles2=getCommonStyles({validLength:validLength,value:value,opacityInterval:opacityInterval,snapDirection:snapDirection}),zIndex=_getCommonStyles2.zIndex,opacity=_getCommonStyles2.opacity;var styles={transform:transform,zIndex:zIndex,opacity:opacity};var translateX;var scale;var rotateZ;var translateY;if(snapDirection==='left'){translateX=(0,_reactNativeReanimated.interpolate)(value,inputRange,[-moveSize,0,0],_reactNativeReanimated.Extrapolate.CLAMP);scale=(0,_reactNativeReanimated.interpolate)(value,inputRange,[1,1,1-validLength*scaleInterval],_reactNativeReanimated.Extrapolate.CLAMP);rotateZ=(0,_reactNativeReanimated.interpolate)(value,inputRange,[-rotateZDeg,0,0],_reactNativeReanimated.Extrapolate.CLAMP)+"deg";translateY=(0,_reactNativeReanimated.interpolate)(value,inputRange,[0,0,validLength*stackInterval],_reactNativeReanimated.Extrapolate.CLAMP);}else if(snapDirection==='right'){translateX=(0,_reactNativeReanimated.interpolate)(value,inputRange,[0,0,moveSize],_reactNativeReanimated.Extrapolate.CLAMP);scale=(0,_reactNativeReanimated.interpolate)(value,inputRange,[1-validLength*scaleInterval,1,1],_reactNativeReanimated.Extrapolate.CLAMP);rotateZ=(0,_reactNativeReanimated.interpolate)(value,inputRange,[0,0,rotateZDeg],_reactNativeReanimated.Extrapolate.CLAMP)+"deg";translateY=(0,_reactNativeReanimated.interpolate)(value,inputRange,[validLength*stackInterval,0,0],_reactNativeReanimated.Extrapolate.CLAMP);}transform.push({translateX:translateX},{scale:scale},{rotateZ:rotateZ},{translateY:translateY});return styles;};_f._closure={screen:{width:screen.width},modeConfig:modeConfig,getCommonVariables:getCommonVariables,getCommonStyles:getCommonStyles,interpolate:_reactNativeReanimated.interpolate,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP}};_f.asString="function _f(_value){const{screen,modeConfig,getCommonVariables,getCommonStyles,interpolate,Extrapolate}=jsThis._closure;{const{showLength:showLength,snapDirection='left',moveSize=screen.width,stackInterval=18,scaleInterval=0.04,opacityInterval=0.1,rotateZDeg=30}=modeConfig;const transform=[];const{validLength:validLength,value:value,inputRange:inputRange}=getCommonVariables({showLength:showLength,value:_value,snapDirection:snapDirection});const{zIndex:zIndex,opacity:opacity}=getCommonStyles({validLength:validLength,value:value,opacityInterval:opacityInterval,snapDirection:snapDirection});const styles={transform:transform,zIndex:zIndex,opacity:opacity};let translateX;let scale;let rotateZ;let translateY;if(snapDirection==='left'){translateX=interpolate(value,inputRange,[-moveSize,0,0],Extrapolate.CLAMP);scale=interpolate(value,inputRange,[1,1,1-validLength*scaleInterval],Extrapolate.CLAMP);rotateZ=interpolate(value,inputRange,[-rotateZDeg,0,0],Extrapolate.CLAMP)+\"deg\";translateY=interpolate(value,inputRange,[0,0,validLength*stackInterval],Extrapolate.CLAMP);}else if(snapDirection==='right'){translateX=interpolate(value,inputRange,[0,0,moveSize],Extrapolate.CLAMP);scale=interpolate(value,inputRange,[1-validLength*scaleInterval,1,1],Extrapolate.CLAMP);rotateZ=interpolate(value,inputRange,[0,0,rotateZDeg],Extrapolate.CLAMP)+\"deg\";translateY=interpolate(value,inputRange,[validLength*stackInterval,0,0],Extrapolate.CLAMP);}transform.push({translateX:translateX},{scale:scale},{rotateZ:rotateZ},{translateY:translateY});return styles;}}";_f.__workletHash=2365281434390;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/stack.ts (152:11)";return _f;}();}var getCommonVariables=function(){var _f=function _f(opts){var showLength=opts.showLength,_value=opts.value,snapDirection=opts.snapDirection;function easeInOutCubic(v){return v<0.5?4*v*v*v:1-Math.pow(-2*v+2,3)/2;}var page=Math.floor(Math.abs(_value));var diff=Math.abs(_value)%1;var value=_value<0?-(page+easeInOutCubic(diff)):page+easeInOutCubic(diff);var validLength=showLength-1;var inputRange;if(snapDirection==='left'){inputRange=[-1,0,validLength];}else if(snapDirection==='right'){inputRange=[-validLength,0,1];}else{throw Error('snapDirection must be set to either left or right');}return{inputRange:inputRange,validLength:validLength,value:value};};_f._closure={};_f.asString="function getCommonVariables(opts){const{showLength:showLength,value:_value,snapDirection:snapDirection}=opts;function easeInOutCubic(v){return v<0.5?4*v*v*v:1-Math.pow(-2*v+2,3)/2;}const page=Math.floor(Math.abs(_value));const diff=Math.abs(_value)%1;const value=_value<0?-(page+easeInOutCubic(diff)):page+easeInOutCubic(diff);const validLength=showLength-1;let inputRange;if(snapDirection==='left'){inputRange=[-1,0,validLength];}else if(snapDirection==='right'){inputRange=[-validLength,0,1];}else{throw Error('snapDirection must be set to either left or right');}return{inputRange:inputRange,validLength:validLength,value:value};}";_f.__workletHash=3893657980264;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/stack.ts (259:0)";return _f;}();var getCommonStyles=function(){var _f=function _f(opts){var snapDirection=opts.snapDirection,validLength=opts.validLength,value=opts.value,opacityInterval=opts.opacityInterval;var zIndex;var opacity;if(snapDirection==='left'){zIndex=Math.floor((0,_reactNativeReanimated.interpolate)(value,[-1.5,-1,-1+Number.MIN_VALUE,0,validLength],[Number.MIN_VALUE,validLength,validLength,validLength-1,-1])*10000)/100;opacity=(0,_reactNativeReanimated.interpolate)(value,[-1,0,validLength-1,validLength],[0.25,1,1-(validLength-1)*opacityInterval,0.25]);}else if(snapDirection==='right'){zIndex=Math.floor((0,_reactNativeReanimated.interpolate)(value,[-validLength,0,1-Number.MIN_VALUE,1,1.5],[1,validLength-1,validLength,validLength,Number.MIN_VALUE])*10000)/100;opacity=(0,_reactNativeReanimated.interpolate)(value,[-validLength,1-validLength,0,1],[0.25,1-(validLength-1)*opacityInterval,1,0.25]);}else{throw Error('snapDirection must be set to either left or right');}return{zIndex:zIndex,opacity:opacity};};_f._closure={interpolate:_reactNativeReanimated.interpolate};_f.asString="function getCommonStyles(opts){const{interpolate}=jsThis._closure;{const{snapDirection:snapDirection,validLength:validLength,value:value,opacityInterval:opacityInterval}=opts;let zIndex;let opacity;if(snapDirection==='left'){zIndex=Math.floor(interpolate(value,[-1.5,-1,-1+Number.MIN_VALUE,0,validLength],[Number.MIN_VALUE,validLength,validLength,validLength-1,-1])*10000)/100;opacity=interpolate(value,[-1,0,validLength-1,validLength],[0.25,1,1-(validLength-1)*opacityInterval,0.25]);}else if(snapDirection==='right'){zIndex=Math.floor(interpolate(value,[-validLength,0,1-Number.MIN_VALUE,1,1.5],[1,validLength-1,validLength,validLength,Number.MIN_VALUE])*10000)/100;opacity=interpolate(value,[-validLength,1-validLength,0,1],[0.25,1-(validLength-1)*opacityInterval,1,0.25]);}else{throw Error('snapDirection must be set to either left or right');}return{zIndex:zIndex,opacity:opacity};}}";_f.__workletHash=16145327689090;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/stack.ts (295:0)";return _f;}();
|
|
2
2
|
//# sourceMappingURL=stack.js.map
|