react-native-reanimated-carousel 3.1.5 → 3.3.0

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.
Files changed (56) hide show
  1. package/README.md +9 -0
  2. package/README.zh-CN.md +38 -30
  3. package/lib/commonjs/Carousel.js +1 -1
  4. package/lib/commonjs/Carousel.js.map +1 -1
  5. package/lib/commonjs/ScrollViewGesture.js +1 -1
  6. package/lib/commonjs/ScrollViewGesture.js.map +1 -1
  7. package/lib/commonjs/hooks/computeNewIndexWhenDataChanges.js +1 -1
  8. package/lib/commonjs/hooks/computeNewIndexWhenDataChanges.js.map +1 -1
  9. package/lib/commonjs/hooks/index.test.js +1 -1
  10. package/lib/commonjs/hooks/index.test.js.map +1 -1
  11. package/lib/commonjs/hooks/useCarouselController.js +1 -1
  12. package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
  13. package/lib/commonjs/hooks/useCommonVariables.js +1 -1
  14. package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
  15. package/lib/commonjs/hooks/useInitProps.js +1 -1
  16. package/lib/commonjs/hooks/useInitProps.js.map +1 -1
  17. package/lib/commonjs/hooks/useOffsetX.js +1 -1
  18. package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
  19. package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
  20. package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
  21. package/lib/commonjs/hooks/useVisibleRanges.js +1 -1
  22. package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
  23. package/lib/commonjs/layouts/BaseLayout.js +1 -1
  24. package/lib/commonjs/layouts/BaseLayout.js.map +1 -1
  25. package/lib/commonjs/layouts/ParallaxLayout.js +1 -1
  26. package/lib/commonjs/layouts/ParallaxLayout.js.map +1 -1
  27. package/lib/commonjs/layouts/normal.js +1 -1
  28. package/lib/commonjs/layouts/normal.js.map +1 -1
  29. package/lib/commonjs/layouts/parallax.js +1 -1
  30. package/lib/commonjs/layouts/parallax.js.map +1 -1
  31. package/lib/commonjs/layouts/stack.js +1 -1
  32. package/lib/commonjs/layouts/stack.js.map +1 -1
  33. package/lib/commonjs/utils/computedWithAutoFillData.js +1 -1
  34. package/lib/commonjs/utils/computedWithAutoFillData.js.map +1 -1
  35. package/lib/commonjs/utils/dealWithAnimation.js +1 -1
  36. package/lib/commonjs/utils/dealWithAnimation.js.map +1 -1
  37. package/lib/commonjs/utils/handlerOffsetDirection.js +1 -1
  38. package/lib/commonjs/utils/log.js +1 -1
  39. package/lib/module/ScrollViewGesture.js +79 -37
  40. package/lib/module/ScrollViewGesture.js.map +1 -1
  41. package/lib/module/hooks/index.test.js +0 -1
  42. package/lib/module/hooks/index.test.js.map +1 -1
  43. package/lib/module/hooks/useInitProps.js +5 -2
  44. package/lib/module/hooks/useInitProps.js.map +1 -1
  45. package/lib/module/layouts/BaseLayout.js +7 -0
  46. package/lib/module/layouts/BaseLayout.js.map +1 -1
  47. package/lib/module/utils/dealWithAnimation.js +2 -6
  48. package/lib/module/utils/dealWithAnimation.js.map +1 -1
  49. package/lib/typescript/types.d.ts +10 -5
  50. package/package.json +13 -10
  51. package/src/ScrollViewGesture.tsx +80 -39
  52. package/src/hooks/index.test.ts +0 -2
  53. package/src/hooks/useInitProps.ts +5 -2
  54. package/src/layouts/BaseLayout.tsx +7 -1
  55. package/src/types.ts +12 -5
  56. package/src/utils/dealWithAnimation.ts +6 -10
@@ -1 +1 @@
1
- {"version":3,"sources":["useCarouselController.tsx"],"names":["useCarouselController","options","size","loop","dataLength","handlerOffset","withAnimation","defaultIndex","duration","autoFillData","dataInfo","React","useMemo","length","disable","originalLength","index","sharedIndex","sharedPreIndex","currentFixedPage","useCallback","Math","round","value","fixed","abs","setSharedIndex","newSharedIndex","current","handlerOffsetValue","toInt","isPositive","i","newSharedIndexValue","rawDataLength","convertToSharedIndex","runOnJS","getCurrentIndex","realIndex","canSliding","onScrollEnd","onScrollBegin","scrollWithTiming","toValue","onFinished","callback","isFinished","defaultWithAnimation","type","config","easing","Easing","easeOutQuart","dealWithAnimation","next","opts","count","animated","nextPage","prev","prevPage","to","direction","offset","totalSize","isCloseToNextLoop","finalOffset","floor","scrollTo","n","getSharedIndex"],"mappings":"6GAAA,qDAEA,8DAMA,uCAMA,2EACA,6DACA,uEACA,iC,0/BAuBO,QAASA,CAAAA,qBAAT,CAA+BC,OAA/B,CAAoE,CACzE,GACEC,CAAAA,IADF,CASID,OATJ,CACEC,IADF,CAEEC,IAFF,CASIF,OATJ,CAEEE,IAFF,CAGEC,UAHF,CASIH,OATJ,CAGEG,UAHF,CAIEC,aAJF,CASIJ,OATJ,CAIEI,aAJF,CAKEC,aALF,CASIL,OATJ,CAKEK,aALF,uBASIL,OATJ,CAMEM,YANF,CAMEA,YANF,gCAMiB,CANjB,uBAOEC,QAPF,CASIP,OATJ,CAOEO,QAPF,CAQEC,YARF,CASIR,OATJ,CAQEQ,YARF,CAWA,GAAMC,CAAAA,QAAQ,CAAGC,eAAMC,OAAN,CACf,iBAAO,CACLC,MAAM,CAAET,UADH,CAELU,OAAO,CAAE,CAACV,UAFL,CAGLW,cAAc,CAAEX,UAHX,CAAP,EADe,CAMf,CAACA,UAAD,CANe,CAAjB,CASA,GAAMY,CAAAA,KAAK,CAAG,0CAAuBT,YAAvB,CAAd,CAEA,GAAMU,CAAAA,WAAW,CAAG,kBAAeV,YAAf,CAApB,CACA,GAAMW,CAAAA,cAAc,CAAG,kBAAeX,YAAf,CAAvB,CAEA,GAAMY,CAAAA,gBAAgB,CAAGR,eAAMS,WAAN,CAAkB,UAAM,CAC/C,GAAIjB,IAAJ,CACE,MAAO,CAACkB,IAAI,CAACC,KAAL,CAAWjB,aAAa,CAACkB,KAAd,CAAsBrB,IAAjC,CAAR,CAEF,GAAMsB,CAAAA,KAAK,CAAInB,aAAa,CAACkB,KAAd,CAAsBrB,IAAvB,CAA+BQ,QAAQ,CAACG,MAAtD,CACA,MAAOQ,CAAAA,IAAI,CAACC,KAAL,CACLjB,aAAa,CAACk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AQ,CAARA,QAAZ,CAAsBb,UAAU,CAAVA,UAAtB,CAAD,CAAJ,CACH,CAlBc,CAmBf,CAACe,IAAD,CAAOL,IAAP,CAAaO,EAAb,CAnBe,CAAjB,CAsBA,MAAO,CACLP,IAAI,CAAJA,IADK,CAELK,IAAI,CAAJA,IAFK,CAGLS,QAAQ,CAARA,QAHK,CAIL/B,eAAe,CAAfA,eAJK,CAKLiC,cAAc,CAAE,gCAAMrD,CAAAA,WAAW,CAACW,OAAlB,EALX,CAAP,CAOD","sourcesContent":["import React, { useRef } from \"react\";\nimport type Animated from \"react-native-reanimated\";\nimport {\n runOnJS,\n useAnimatedReaction,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { Easing } from \"../constants\";\nimport type {\n TCarouselActionOptions,\n TCarouselProps,\n WithTimingAnimation,\n} from \"../types\";\nimport { computedRealIndexWithAutoFillData, convertToSharedIndex } from \"../utils/computedWithAutoFillData\";\nimport { dealWithAnimation } from \"../utils/dealWithAnimation\";\nimport { handlerOffsetDirection } from \"../utils/handlerOffsetDirection\";\nimport { round } from \"../utils/log\";\n\ninterface IOpts {\n loop: boolean\n size: number\n dataLength: number\n autoFillData: TCarouselProps[\"autoFillData\"]\n handlerOffset: 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 loop,\n dataLength,\n handlerOffset,\n withAnimation,\n defaultIndex = 0,\n duration,\n autoFillData,\n } = options;\n\n const dataInfo = React.useMemo(\n () => ({\n length: dataLength,\n disable: !dataLength,\n originalLength: dataLength,\n }),\n [dataLength],\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(handlerOffset.value / size);\n\n const fixed = (handlerOffset.value / size) % dataInfo.length;\n return Math.round(\n handlerOffset.value <= 0\n ? Math.abs(fixed)\n : Math.abs(fixed > 0 ? dataInfo.length - fixed : 0),\n );\n }, [handlerOffset, dataInfo, size, loop]);\n\n function setSharedIndex(newSharedIndex: number) {\n sharedIndex.current = newSharedIndex;\n }\n\n useAnimatedReaction(\n () => {\n const handlerOffsetValue = handlerOffset.value;\n const toInt = round(handlerOffsetValue / size) % dataInfo.length;\n const isPositive = handlerOffsetValue <= 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 handlerOffset,\n ],\n );\n\n const getCurrentIndex = React.useCallback(() => {\n const realIndex = computedRealIndexWithAutoFillData({\n index: index.value,\n dataLength: dataInfo.originalLength,\n loop,\n autoFillData: autoFillData!,\n });\n\n return realIndex;\n }, [index, autoFillData, dataInfo, loop]);\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 handlerOffset.value = scrollWithTiming(\n -nextPage * size,\n onFinished,\n ) as any;\n }\n else {\n handlerOffset.value = -nextPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n dataInfo,\n onScrollBegin,\n handlerOffset,\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 handlerOffset.value = scrollWithTiming(\n -prevPage * size,\n onFinished,\n );\n }\n else {\n handlerOffset.value = -prevPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n onScrollBegin,\n handlerOffset,\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 // direction -> 1 | -1\n const direction = handlerOffsetDirection(handlerOffset);\n\n // target offset\n const offset = i * size * direction;\n // page width size * page count\n const totalSize = dataInfo.length * size;\n\n let isCloseToNextLoop = false;\n\n if (loop) {\n isCloseToNextLoop\n = Math.abs(handlerOffset.value % totalSize) / totalSize\n >= 0.5;\n }\n\n const finalOffset\n = (Math.floor(Math.abs(handlerOffset.value / totalSize))\n + (isCloseToNextLoop ? 1 : 0))\n * totalSize\n * direction\n + offset;\n\n if (animated) {\n index.value = i;\n handlerOffset.value = scrollWithTiming(finalOffset, onFinished);\n }\n else {\n handlerOffset.value = finalOffset;\n index.value = i;\n onFinished?.();\n }\n },\n [\n index,\n canSliding,\n onScrollBegin,\n handlerOffset,\n size,\n dataInfo.length,\n loop,\n scrollWithTiming,\n ],\n );\n\n const scrollTo = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n const { index: i, count, animated = false, onFinished } = opts;\n if (typeof i === \"number\" && i > -1) {\n to({ i, animated, onFinished });\n return;\n }\n\n if (!count)\n return;\n\n const n = Math.round(count);\n\n if (n < 0)\n prev({ count: Math.abs(n), animated, onFinished });\n\n else\n next({ count: n, animated, onFinished });\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","loop","dataLength","handlerOffset","withAnimation","defaultIndex","duration","autoFillData","dataInfo","React","useMemo","length","disable","originalLength","index","sharedIndex","sharedPreIndex","currentFixedPage","useCallback","Math","round","value","fixed","abs","setSharedIndex","newSharedIndex","current","handlerOffsetValue","toInt","isPositive","i","newSharedIndexValue","rawDataLength","convertToSharedIndex","runOnJS","getCurrentIndex","realIndex","canSliding","onScrollEnd","onScrollBegin","scrollWithTiming","toValue","onFinished","callback","isFinished","defaultWithAnimation","type","config","easing","Easing","easeOutQuart","dealWithAnimation","next","opts","count","animated","nextPage","prev","prevPage","to","direction","offset","totalSize","isCloseToNextLoop","finalOffset","floor","scrollTo","n","getSharedIndex"],"mappings":"6GAAA,qDAEA,8DAMA,uCAMA,2EACA,6DACA,uEACA,iC,0/BAuBO,QAASA,CAAAA,qBAAT,CAA+BC,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K,CAIL/B,eAAe,CAAfA,eAJK,CAKLiC,cAAc,CAAE,gCAAMrD,CAAAA,WAAW,CAACW,OAAlB,EALX,CAAP,CAOD","sourcesContent":["import React, { useRef } from \"react\";\nimport type Animated from \"react-native-reanimated\";\nimport {\n runOnJS,\n useAnimatedReaction,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { Easing } from \"../constants\";\nimport type {\n TCarouselActionOptions,\n TCarouselProps,\n WithTimingAnimation,\n} from \"../types\";\nimport { computedRealIndexWithAutoFillData, convertToSharedIndex } from \"../utils/computedWithAutoFillData\";\nimport { dealWithAnimation } from \"../utils/dealWithAnimation\";\nimport { handlerOffsetDirection } from \"../utils/handlerOffsetDirection\";\nimport { round } from \"../utils/log\";\n\ninterface IOpts {\n loop: boolean\n size: number\n dataLength: number\n autoFillData: TCarouselProps[\"autoFillData\"]\n handlerOffset: 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 loop,\n dataLength,\n handlerOffset,\n withAnimation,\n defaultIndex = 0,\n duration,\n autoFillData,\n } = options;\n\n const dataInfo = React.useMemo(\n () => ({\n length: dataLength,\n disable: !dataLength,\n originalLength: dataLength,\n }),\n [dataLength],\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(handlerOffset.value / size);\n\n const fixed = (handlerOffset.value / size) % dataInfo.length;\n return Math.round(\n handlerOffset.value <= 0\n ? Math.abs(fixed)\n : Math.abs(fixed > 0 ? dataInfo.length - fixed : 0),\n );\n }, [handlerOffset, dataInfo, size, loop]);\n\n function setSharedIndex(newSharedIndex: number) {\n sharedIndex.current = newSharedIndex;\n }\n\n useAnimatedReaction(\n () => {\n const handlerOffsetValue = handlerOffset.value;\n const toInt = round(handlerOffsetValue / size) % dataInfo.length;\n const isPositive = handlerOffsetValue <= 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 handlerOffset,\n ],\n );\n\n const getCurrentIndex = React.useCallback(() => {\n const realIndex = computedRealIndexWithAutoFillData({\n index: index.value,\n dataLength: dataInfo.originalLength,\n loop,\n autoFillData: autoFillData!,\n });\n\n return realIndex;\n }, [index, autoFillData, dataInfo, loop]);\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 handlerOffset.value = scrollWithTiming(\n -nextPage * size,\n onFinished,\n ) as any;\n }\n else {\n handlerOffset.value = -nextPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n dataInfo,\n onScrollBegin,\n handlerOffset,\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 handlerOffset.value = scrollWithTiming(\n -prevPage * size,\n onFinished,\n );\n }\n else {\n handlerOffset.value = -prevPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n onScrollBegin,\n handlerOffset,\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 // direction -> 1 | -1\n const direction = handlerOffsetDirection(handlerOffset);\n\n // target offset\n const offset = i * size * direction;\n // page width size * page count\n const totalSize = dataInfo.length * size;\n\n let isCloseToNextLoop = false;\n\n if (loop) {\n isCloseToNextLoop\n = Math.abs(handlerOffset.value % totalSize) / totalSize\n >= 0.5;\n }\n\n const finalOffset\n = (Math.floor(Math.abs(handlerOffset.value / totalSize))\n + (isCloseToNextLoop ? 1 : 0))\n * totalSize\n * direction\n + offset;\n\n if (animated) {\n index.value = i;\n handlerOffset.value = scrollWithTiming(finalOffset, onFinished);\n }\n else {\n handlerOffset.value = finalOffset;\n index.value = i;\n onFinished?.();\n }\n },\n [\n index,\n canSliding,\n onScrollBegin,\n handlerOffset,\n size,\n dataInfo.length,\n loop,\n scrollWithTiming,\n ],\n );\n\n const scrollTo = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n const { index: i, count, animated = false, onFinished } = opts;\n if (typeof i === \"number\" && i > -1) {\n to({ i, animated, onFinished });\n return;\n }\n\n if (!count)\n return;\n\n const n = Math.round(count);\n\n if (n < 0)\n prev({ count: Math.abs(n), animated, onFinished });\n\n else\n next({ count: n, animated, onFinished });\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
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useCommonVariables=useCommonVariables;var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=require("react-native-reanimated");var _computeNewIndexWhenDataChanges=require("./computeNewIndexWhenDataChanges");var _handlerOffsetDirection=require("../utils/handlerOffsetDirection");function useCommonVariables(props){var vertical=props.vertical,height=props.height,width=props.width,dataLength=props.dataLength,defaultIndex=props.defaultIndex,defaultScrollOffsetValue=props.defaultScrollOffsetValue,loop=props.loop;var size=vertical?height:width;var validLength=dataLength-1;var defaultHandlerOffsetValue=-Math.abs(defaultIndex*size);var _handlerOffset=(0,_reactNativeReanimated.useSharedValue)(defaultHandlerOffsetValue);var handlerOffset=defaultScrollOffsetValue!=null?defaultScrollOffsetValue:_handlerOffset;var prevDataLength=(0,_reactNativeReanimated.useSharedValue)(dataLength);_react.default.useEffect(function(){handlerOffset.value=defaultHandlerOffsetValue;},[vertical,handlerOffset,defaultHandlerOffsetValue]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){var previousLength=prevDataLength.value;var currentLength=dataLength;var isLengthChanged=previousLength!==currentLength;var shouldComputed=isLengthChanged&&loop;if(shouldComputed)prevDataLength.value=dataLength;return{shouldComputed:shouldComputed,previousLength:previousLength,currentLength:currentLength};};_f._closure={prevDataLength:prevDataLength,dataLength:dataLength,loop:loop};_f.asString="function _f(){const{prevDataLength,dataLength,loop}=jsThis._closure;{const previousLength=prevDataLength.value;const currentLength=dataLength;const isLengthChanged=previousLength!==currentLength;const shouldComputed=isLengthChanged&&loop;if(shouldComputed)prevDataLength.value=dataLength;return{shouldComputed:shouldComputed,previousLength:previousLength,currentLength:currentLength};}}";_f.__workletHash=13698961874962;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCommonVariables.ts (39:22)";return _f;}(),function(){var _f=function _f(_ref){var shouldComputed=_ref.shouldComputed,previousLength=_ref.previousLength,currentLength=_ref.currentLength;if(shouldComputed){var direction=(0,_handlerOffsetDirection.handlerOffsetDirection)(handlerOffset);handlerOffset.value=(0,_computeNewIndexWhenDataChanges.computeNewIndexWhenDataChanges)({direction:direction,previousLength:previousLength,currentLength:currentLength,size:size,handlerOffset:handlerOffset.value});}};_f._closure={handlerOffsetDirection:_handlerOffsetDirection.handlerOffsetDirection,handlerOffset:handlerOffset,computeNewIndexWhenDataChanges:_computeNewIndexWhenDataChanges.computeNewIndexWhenDataChanges,size:size};_f.asString="function _f({shouldComputed:shouldComputed,previousLength:previousLength,currentLength:currentLength}){const{handlerOffsetDirection,handlerOffset,computeNewIndexWhenDataChanges,size}=jsThis._closure;{if(shouldComputed){const direction=handlerOffsetDirection(handlerOffset);handlerOffset.value=computeNewIndexWhenDataChanges({direction:direction,previousLength:previousLength,currentLength:currentLength,size:size,handlerOffset:handlerOffset.value});}}}";_f.__workletHash=7425703877323;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCommonVariables.ts (53:5)";return _f;}(),[dataLength,loop]);return{size:size,validLength:validLength,handlerOffset:handlerOffset};}
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useCommonVariables=useCommonVariables;var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=require("react-native-reanimated");var _computeNewIndexWhenDataChanges=require("./computeNewIndexWhenDataChanges");var _handlerOffsetDirection=require("../utils/handlerOffsetDirection");function useCommonVariables(props){var vertical=props.vertical,height=props.height,width=props.width,dataLength=props.dataLength,defaultIndex=props.defaultIndex,defaultScrollOffsetValue=props.defaultScrollOffsetValue,loop=props.loop;var size=vertical?height:width;var validLength=dataLength-1;var defaultHandlerOffsetValue=-Math.abs(defaultIndex*size);var _handlerOffset=(0,_reactNativeReanimated.useSharedValue)(defaultHandlerOffsetValue);var handlerOffset=defaultScrollOffsetValue!=null?defaultScrollOffsetValue:_handlerOffset;var prevDataLength=(0,_reactNativeReanimated.useSharedValue)(dataLength);_react.default.useEffect(function(){handlerOffset.value=defaultHandlerOffsetValue;},[vertical,handlerOffset,defaultHandlerOffsetValue]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){var previousLength=prevDataLength.value;var currentLength=dataLength;var isLengthChanged=previousLength!==currentLength;var shouldComputed=isLengthChanged&&loop;if(shouldComputed)prevDataLength.value=dataLength;return{shouldComputed:shouldComputed,previousLength:previousLength,currentLength:currentLength};};_f._closure={prevDataLength:prevDataLength,dataLength:dataLength,loop:loop};_f.asString="function _f(){const{prevDataLength,dataLength,loop}=jsThis._closure;{const previousLength=prevDataLength.value;const currentLength=dataLength;const isLengthChanged=previousLength!==currentLength;const shouldComputed=isLengthChanged&&loop;if(shouldComputed)prevDataLength.value=dataLength;return{shouldComputed:shouldComputed,previousLength:previousLength,currentLength:currentLength};}}";_f.__workletHash=13698961874962;_f.__location="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCommonVariables.ts (39:22)";return _f;}(),function(){var _f=function _f(_ref){var shouldComputed=_ref.shouldComputed,previousLength=_ref.previousLength,currentLength=_ref.currentLength;if(shouldComputed){var direction=(0,_handlerOffsetDirection.handlerOffsetDirection)(handlerOffset);handlerOffset.value=(0,_computeNewIndexWhenDataChanges.computeNewIndexWhenDataChanges)({direction:direction,previousLength:previousLength,currentLength:currentLength,size:size,handlerOffset:handlerOffset.value});}};_f._closure={handlerOffsetDirection:_handlerOffsetDirection.handlerOffsetDirection,handlerOffset:handlerOffset,computeNewIndexWhenDataChanges:_computeNewIndexWhenDataChanges.computeNewIndexWhenDataChanges,size:size};_f.asString="function _f({shouldComputed:shouldComputed,previousLength:previousLength,currentLength:currentLength}){const{handlerOffsetDirection,handlerOffset,computeNewIndexWhenDataChanges,size}=jsThis._closure;{if(shouldComputed){const direction=handlerOffsetDirection(handlerOffset);handlerOffset.value=computeNewIndexWhenDataChanges({direction:direction,previousLength:previousLength,currentLength:currentLength,size:size,handlerOffset:handlerOffset.value});}}}";_f.__workletHash=7425703877323;_f.__location="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCommonVariables.ts (53:5)";return _f;}(),[dataLength,loop]);return{size:size,validLength:validLength,handlerOffset:handlerOffset};}
2
2
  //# sourceMappingURL=useCommonVariables.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["useCommonVariables.ts"],"names":["useCommonVariables","props","vertical","height","width","dataLength","defaultIndex","defaultScrollOffsetValue","loop","size","validLength","defaultHandlerOffsetValue","Math","abs","_handlerOffset","handlerOffset","prevDataLength","React","useEffect","value","previousLength","currentLength","isLengthChanged","shouldComputed","direction","handlerOffsetDirection","computeNewIndexWhenDataChanges"],"mappings":"0LAAA,oDAEA,8DAEA,gFAGA,uEAQO,QAASA,CAAAA,kBAAT,CACLC,KADK,CAEa,CAClB,GACEC,CAAAA,QADF,CAQID,KARJ,CACEC,QADF,CAEEC,MAFF,CAQIF,KARJ,CAEEE,MAFF,CAGEC,KAHF,CAQIH,KARJ,CAGEG,KAHF,CAIEC,UAJF,CAQIJ,KARJ,CAIEI,UAJF,CAKEC,YALF,CAQIL,KARJ,CAKEK,YALF,CAMEC,wBANF,CAQIN,KARJ,CAMEM,wB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AA+B,CACnDK,SAAS,CAATA,SADmD,CAEnDJ,cAAc,CAAdA,cAFmD,CAGnDC,aAAa,CAAbA,aAHmD,CAInDZ,IAAI,CAAJA,IAJmD,CAKnDM,aAAa,CAAEA,aAAa,CAACI,KALsB,CAA/B,CAAtB,CAOD,CACF,CA3BD,qCA9BoBM,8CA8BpB,eAxBmBV,aAwBnB,gCA7BwBW,8DA6BxB,MAzBIjB,IAyBJ,ynBA2BG,CAACJ,UAAD,CAAaG,IAAb,CA3BH,EA6BA,MAAO,CACLC,IAAI,CAAJA,IADK,CAELC,WAAW,CAAXA,WAFK,CAGLK,aAAa,CAAbA,aAHK,CAAP,CAKD","sourcesContent":["import React from \"react\";\nimport type Animated from \"react-native-reanimated\";\nimport { useSharedValue, useAnimatedReaction } from \"react-native-reanimated\";\n\nimport { computeNewIndexWhenDataChanges } from \"./computeNewIndexWhenDataChanges\";\nimport type { TInitializeCarouselProps } from \"./useInitProps\";\n\nimport { handlerOffsetDirection } from \"../utils/handlerOffsetDirection\";\n\ninterface ICommonVariables {\n size: number\n validLength: number\n handlerOffset: Animated.SharedValue<number>\n}\n\nexport function useCommonVariables(\n props: TInitializeCarouselProps<any>,\n): ICommonVariables {\n const {\n vertical,\n height,\n width,\n dataLength,\n defaultIndex,\n defaultScrollOffsetValue,\n loop,\n } = props;\n const size = vertical ? height : width;\n const validLength = dataLength - 1;\n const defaultHandlerOffsetValue = -Math.abs(defaultIndex * size);\n const _handlerOffset = useSharedValue<number>(defaultHandlerOffsetValue);\n const handlerOffset = defaultScrollOffsetValue ?? _handlerOffset;\n const prevDataLength = useSharedValue(dataLength);\n\n React.useEffect(() => {\n handlerOffset.value = defaultHandlerOffsetValue;\n }, [vertical, handlerOffset, defaultHandlerOffsetValue]);\n\n useAnimatedReaction(() => {\n const previousLength = prevDataLength.value;\n const currentLength = dataLength;\n const isLengthChanged = previousLength !== currentLength;\n const shouldComputed = isLengthChanged && loop;\n\n if (shouldComputed)\n prevDataLength.value = dataLength;\n\n return {\n shouldComputed,\n previousLength,\n currentLength,\n };\n }, ({ shouldComputed, previousLength, currentLength }) => {\n if (shouldComputed) {\n // direction -> 1 | -1\n const direction = handlerOffsetDirection(handlerOffset);\n\n handlerOffset.value = computeNewIndexWhenDataChanges({\n direction,\n previousLength,\n currentLength,\n size,\n handlerOffset: handlerOffset.value,\n });\n }\n }, [dataLength, loop]);\n\n return {\n size,\n validLength,\n handlerOffset,\n };\n}\n"]}
1
+ {"version":3,"sources":["useCommonVariables.ts"],"names":["useCommonVariables","props","vertical","height","width","dataLength","defaultIndex","defaultScrollOffsetValue","loop","size","validLength","defaultHandlerOffsetValue","Math","abs","_handlerOffset","handlerOffset","prevDataLength","React","useEffect","value","previousLength","currentLength","isLengthChanged","shouldComputed","direction","handlerOffsetDirection","computeNewIndexWhenDataChanges"],"mappings":"0LAAA,oDAEA,8DAEA,gFAGA,uEAQO,QAASA,CAAAA,kBAAT,CACLC,KADK,CAEa,CAClB,GACEC,CAAAA,QADF,CAQID,KARJ,CACEC,QADF,CAEEC,MAFF,CAQIF,KARJ,CAEEE,MAFF,CAGEC,KAHF,CAQIH,KARJ,CAGEG,KAHF,CAIEC,UAJF,CAQIJ,KARJ,CAIEI,UAJF,CAKEC,YALF,CAQIL,KARJ,CAKEK,YALF,CAMEC,wBANF,CAQIN,KARJ,CAMEM,wBANF,CAOEC,IAPF,CAQIP,KARJ,CAOEO,IAPF,CASA,GAAMC,CAAAA,IAAI,CAAGP,QAAQ,CAAGC,MAAH,CAAYC,KAAjC,CACA,GAAMM,CAAAA,WAAW,CAAGL,UAAU,CAAG,CAAjC,CACA,GAAMM,CAAAA,yBAAyB,CAAG,CAACC,IAAI,CAACC,GAAL,CAASP,YAAY,CAAGG,IAAxB,CAAnC,CACA,GAAMK,CAAAA,cAAc,CAAG,0CAAuBH,yBAAvB,CAAvB,CACA,GAAMI,CAAAA,aAAa,CAAGR,wBAAH,OAAGA,wBAAH,CAA+BO,cAAlD,CACA,GAAME,CAAAA,cAA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AAP,CAKD","sourcesContent":["import React from \"react\";\nimport type Animated from \"react-native-reanimated\";\nimport { useSharedValue, useAnimatedReaction } from \"react-native-reanimated\";\n\nimport { computeNewIndexWhenDataChanges } from \"./computeNewIndexWhenDataChanges\";\nimport type { TInitializeCarouselProps } from \"./useInitProps\";\n\nimport { handlerOffsetDirection } from \"../utils/handlerOffsetDirection\";\n\ninterface ICommonVariables {\n size: number\n validLength: number\n handlerOffset: Animated.SharedValue<number>\n}\n\nexport function useCommonVariables(\n props: TInitializeCarouselProps<any>,\n): ICommonVariables {\n const {\n vertical,\n height,\n width,\n dataLength,\n defaultIndex,\n defaultScrollOffsetValue,\n loop,\n } = props;\n const size = vertical ? height : width;\n const validLength = dataLength - 1;\n const defaultHandlerOffsetValue = -Math.abs(defaultIndex * size);\n const _handlerOffset = useSharedValue<number>(defaultHandlerOffsetValue);\n const handlerOffset = defaultScrollOffsetValue ?? _handlerOffset;\n const prevDataLength = useSharedValue(dataLength);\n\n React.useEffect(() => {\n handlerOffset.value = defaultHandlerOffsetValue;\n }, [vertical, handlerOffset, defaultHandlerOffsetValue]);\n\n useAnimatedReaction(() => {\n const previousLength = prevDataLength.value;\n const currentLength = dataLength;\n const isLengthChanged = previousLength !== currentLength;\n const shouldComputed = isLengthChanged && loop;\n\n if (shouldComputed)\n prevDataLength.value = dataLength;\n\n return {\n shouldComputed,\n previousLength,\n currentLength,\n };\n }, ({ shouldComputed, previousLength, currentLength }) => {\n if (shouldComputed) {\n // direction -> 1 | -1\n const direction = handlerOffsetDirection(handlerOffset);\n\n handlerOffset.value = computeNewIndexWhenDataChanges({\n direction,\n previousLength,\n currentLength,\n size,\n handlerOffset: handlerOffset.value,\n });\n }\n }, [dataLength, loop]);\n\n return {\n size,\n validLength,\n handlerOffset,\n };\n}\n"]}
@@ -1,2 +1,2 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useInitProps=useInitProps;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireDefault(require("react"));var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");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;}function useInitProps(props){var _props$enableSnap;var _props$defaultIndex=props.defaultIndex,defaultIndex=_props$defaultIndex===void 0?0:_props$defaultIndex,_props$data=props.data,rawData=_props$data===void 0?[]:_props$data,_props$loop=props.loop,loop=_props$loop===void 0?true:_props$loop,_props$enabled=props.enabled,enabled=_props$enabled===void 0?true:_props$enabled,_props$autoPlayInterv=props.autoPlayInterval,_autoPlayInterval=_props$autoPlayInterv===void 0?1000:_props$autoPlayInterv,_props$scrollAnimatio=props.scrollAnimationDuration,scrollAnimationDuration=_props$scrollAnimatio===void 0?500:_props$scrollAnimatio,_props$style=props.style,style=_props$style===void 0?{}:_props$style,_props$panGestureHand=props.panGestureHandlerProps,panGestureHandlerProps=_props$panGestureHand===void 0?{}:_props$panGestureHand,_props$pagingEnabled=props.pagingEnabled,pagingEnabled=_props$pagingEnabled===void 0?true:_props$pagingEnabled,_props$autoFillData=props.autoFillData,autoFillData=_props$autoFillData===void 0?true:_props$autoFillData,_props$snapEnabled=props.snapEnabled,snapEnabled=_props$snapEnabled===void 0?(_props$enableSnap=props.enableSnap)!=null?_props$enableSnap:true:_props$snapEnabled,_width=props.width,_height=props.height;var width=Math.round(_width||0);var height=Math.round(_height||0);var autoPlayInterval=Math.max(_autoPlayInterval,0);var data=_react.default.useMemo(function(){return(0,_computedWithAutoFillData.computedFillDataWithAutoFillData)({loop:loop,autoFillData:autoFillData,data:rawData,dataLength:rawData.length});},[rawData,loop,autoFillData]);var dataLength=data.length;var rawDataLength=rawData.length;if(props.mode==="vertical-stack"||props.mode==="horizontal-stack"){var _props$modeConfig$sho,_props$modeConfig;if(!props.modeConfig)props.modeConfig={};props.modeConfig.showLength=(_props$modeConfig$sho=(_props$modeConfig=props.modeConfig)==null?void 0:_props$modeConfig.showLength)!=null?_props$modeConfig$sho:dataLength-1;}return _objectSpread(_objectSpread({},props),{},{defaultIndex:defaultIndex,autoFillData:autoFillData,data:data,dataLength:dataLength,rawData:rawData,rawDataLength:rawDataLength,loop:loop,enabled:enabled,autoPlayInterval:autoPlayInterval,scrollAnimationDuration:scrollAnimationDuration,style:style,panGestureHandlerProps:panGestureHandlerProps,pagingEnabled:pagingEnabled,snapEnabled:snapEnabled,width:width,height:height});}
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useInitProps=useInitProps;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireDefault(require("react"));var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");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;}function useInitProps(props){var _props$enableSnap;var _props$defaultIndex=props.defaultIndex,defaultIndex=_props$defaultIndex===void 0?0:_props$defaultIndex,_props$data=props.data,rawData=_props$data===void 0?[]:_props$data,_props$loop=props.loop,loop=_props$loop===void 0?true:_props$loop,_props$autoPlayInterv=props.autoPlayInterval,_autoPlayInterval=_props$autoPlayInterv===void 0?1000:_props$autoPlayInterv,_props$scrollAnimatio=props.scrollAnimationDuration,scrollAnimationDuration=_props$scrollAnimatio===void 0?500:_props$scrollAnimatio,_props$style=props.style,style=_props$style===void 0?{}:_props$style,_props$panGestureHand=props.panGestureHandlerProps,panGestureHandlerProps=_props$panGestureHand===void 0?{}:_props$panGestureHand,_props$autoFillData=props.autoFillData,autoFillData=_props$autoFillData===void 0?true:_props$autoFillData,_props$enabled=props.enabled,enabled=_props$enabled===void 0?true:_props$enabled,_props$pagingEnabled=props.pagingEnabled,pagingEnabled=_props$pagingEnabled===void 0?true:_props$pagingEnabled,_props$overscrollEnab=props.overscrollEnabled,overscrollEnabled=_props$overscrollEnab===void 0?true:_props$overscrollEnab,_props$snapEnabled=props.snapEnabled,snapEnabled=_props$snapEnabled===void 0?(_props$enableSnap=props.enableSnap)!=null?_props$enableSnap:true:_props$snapEnabled,_width=props.width,_height=props.height;var width=Math.round(_width||0);var height=Math.round(_height||0);var autoPlayInterval=Math.max(_autoPlayInterval,0);var data=_react.default.useMemo(function(){return(0,_computedWithAutoFillData.computedFillDataWithAutoFillData)({loop:loop,autoFillData:autoFillData,data:rawData,dataLength:rawData.length});},[rawData,loop,autoFillData]);var dataLength=data.length;var rawDataLength=rawData.length;if(props.mode==="vertical-stack"||props.mode==="horizontal-stack"){var _props$modeConfig$sho,_props$modeConfig;if(!props.modeConfig)props.modeConfig={};props.modeConfig.showLength=(_props$modeConfig$sho=(_props$modeConfig=props.modeConfig)==null?void 0:_props$modeConfig.showLength)!=null?_props$modeConfig$sho:dataLength-1;}return _objectSpread(_objectSpread({},props),{},{defaultIndex:defaultIndex,autoFillData:autoFillData,data:data,dataLength:dataLength,rawData:rawData,rawDataLength:rawDataLength,loop:loop,enabled:enabled,autoPlayInterval:autoPlayInterval,scrollAnimationDuration:scrollAnimationDuration,style:style,panGestureHandlerProps:panGestureHandlerProps,pagingEnabled:pagingEnabled,snapEnabled:snapEnabled,overscrollEnabled:overscrollEnabled,width:width,height:height});}
2
2
  //# sourceMappingURL=useInitProps.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["useInitProps.ts"],"names":["useInitProps","props","defaultIndex","data","rawData","loop","enabled","autoPlayInterval","_autoPlayInterval","scrollAnimationDuration","style","panGestureHandlerProps","pagingEnabled","autoFillData","snapEnabled","enableSnap","_width","width","_height","height","Math","round","max","React","useMemo","dataLength","length","rawDataLength","mode","modeConfig","showLength"],"mappings":"4QAAA,oDAGA,2E,kxBAuBO,QAASA,CAAAA,YAAT,CACLC,KADK,CAEwB,uBAC7B,wBAcIA,KAdJ,CACEC,YADF,CACEA,YADF,8BACiB,CADjB,iCAcID,KAdJ,CAEEE,IAFF,CAEQC,OAFR,sBAEkB,EAFlB,yBAcIH,KAdJ,CAGEI,IAHF,CAGEA,IAHF,sBAGS,IAHT,4BAcIJ,KAdJ,CAIEK,OAJF,CAIEA,OAJF,yBAIY,IAJZ,sCAcIL,KAdJ,CAKEM,gBALF,CAKoBC,iBALpB,gCAKwC,IALxC,6CAcIP,KAdJ,CAMEQ,uBANF,CAMEA,uBANF,gCAM4B,GAN5B,oCAcIR,KAdJ,CAOES,KAPF,CAOEA,KAPF,uBAOU,EAPV,oCAcIT,KAdJ,CAQEU,sBARF,CAQEA,sBARF,gCAQ2B,EAR3B,4CAcIV,KAdJ,CASEW,aATF,CASEA,aATF,+BASkB,IATlB,0CAcIX,KAdJ,CAUEY,YAVF,CAUEA,YAVF,8BAUiB,IAVjB,wCAcIZ,KAdJ,CAWEa,WAXF,CAWEA,WAXF,gDAWgBb,KAAK,CAACc,UAXtB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aAAa,CAAbA,aAXF,CAYEtB,IAAI,CAAJA,IAZF,CAaEC,OAAO,CAAPA,OAbF,CAcEC,gBAAgB,CAAhBA,gBAdF,CAeEE,uBAAuB,CAAvBA,uBAfF,CAgBEC,KAAK,CAALA,KAhBF,CAiBEC,sBAAsB,CAAtBA,sBAjBF,CAkBEC,aAAa,CAAbA,aAlBF,CAmBEE,WAAW,CAAXA,WAnBF,CAoBEG,KAAK,CAALA,KApBF,CAqBEE,MAAM,CAANA,MArBF,GAuBD","sourcesContent":["import React from \"react\";\n\nimport type { TCarouselProps } from \"../types\";\nimport { computedFillDataWithAutoFillData } from \"../utils/computedWithAutoFillData\";\n\ntype TGetRequiredProps<P extends keyof TCarouselProps> = Record<\nP,\nRequired<TCarouselProps>[P]\n>;\n\nexport type TInitializeCarouselProps<T> = TCarouselProps<T> &\nTGetRequiredProps<\n| \"defaultIndex\"\n| \"loop\"\n| \"width\"\n| \"height\"\n| \"scrollAnimationDuration\"\n| \"autoPlayInterval\"\n| \"autoFillData\"\n> & {\n // Raw data that has not been processed\n rawData: T[]\n dataLength: number\n rawDataLength: number\n};\n\nexport function useInitProps<T>(\n props: TCarouselProps<T>,\n): TInitializeCarouselProps<T> {\n const {\n defaultIndex = 0,\n data: rawData = [],\n loop = true,\n enabled = true,\n autoPlayInterval: _autoPlayInterval = 1000,\n scrollAnimationDuration = 500,\n style = {},\n panGestureHandlerProps = {},\n pagingEnabled = true,\n autoFillData = true,\n snapEnabled = props.enableSnap ?? true,\n width: _width,\n height: _height,\n } = props;\n\n const width = Math.round(_width || 0);\n const height = Math.round(_height || 0);\n const autoPlayInterval = Math.max(_autoPlayInterval, 0);\n\n const data = React.useMemo<T[]>(\n () => {\n return computedFillDataWithAutoFillData<T>({\n loop,\n autoFillData,\n data: rawData,\n dataLength: rawData.length,\n });\n },\n [rawData, loop, autoFillData],\n );\n\n const dataLength = data.length;\n const rawDataLength = rawData.length;\n\n if (props.mode === \"vertical-stack\" || props.mode === \"horizontal-stack\") {\n if (!props.modeConfig)\n props.modeConfig = {};\n\n props.modeConfig.showLength = props.modeConfig?.showLength ?? dataLength - 1;\n }\n\n return {\n ...props,\n defaultIndex,\n autoFillData,\n // Fill data with autoFillData\n data,\n // Length of fill data\n dataLength,\n // Raw data that has not been processed\n rawData,\n // Length of raw data\n rawDataLength,\n loop,\n enabled,\n autoPlayInterval,\n scrollAnimationDuration,\n style,\n panGestureHandlerProps,\n pagingEnabled,\n snapEnabled,\n width,\n height,\n };\n}\n"]}
1
+ {"version":3,"sources":["useInitProps.ts"],"names":["useInitProps","props","defaultIndex","data","rawData","loop","autoPlayInterval","_autoPlayInterval","scrollAnimationDuration","style","panGestureHandlerProps","autoFillData","enabled","pagingEnabled","overscrollEnabled","snapEnabled","enableSnap","_width","width","_height","height","Math","round","max","React","useMemo","dataLength","length","rawDataLength","mode","modeConfig","showLength"],"mappings":"4QAAA,oDAGA,2E,kxBAuBO,QAASA,CAAAA,YAAT,CACLC,KADK,CAEwB,uBAC7B,wBAgBIA,KAhBJ,CACEC,YADF,CACEA,YADF,8BACiB,CADjB,iCAgBID,KAhBJ,CAEEE,IAFF,CAEQC,OAFR,sBAEkB,EAFlB,yBAgBIH,KAhBJ,CAGEI,IAHF,CAGEA,IAHF,sBAGS,IAHT,mCAgBIJ,KAhBJ,CAIEK,gBAJF,CAIoBC,iBAJpB,gCAIwC,IAJxC,6CAgBIN,KAhBJ,CAKEO,uBALF,CAKEA,uBALF,gCAK4B,GAL5B,oCAgBIP,KAhBJ,CAMEQ,KANF,CAMEA,KANF,uBAMU,EANV,oCAgBIR,KAhBJ,CAOES,sBAPF,CAOEA,sBAPF,gCAO2B,EAP3B,2CAgBIT,KAhBJ,CAQEU,YARF,CAQEA,YARF,8BAQiB,IARjB,oCAgBIV,KAhBJ,CAUEW,OAVF,CAUEA,OAVF,yBAUY,IAVZ,qCAgBIX,KAhBJ,CAWEY,aAXF,CAWEA,aAXF,+BAWkB,IAXlB,4CAgBIZ,KAhBJ,CAYEa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YAFF,CAGES,YAAY,CAAZA,YAHF,CAKER,IAAI,CAAJA,IALF,CAOEuB,UAAU,CAAVA,UAPF,CASEtB,OAAO,CAAPA,OATF,CAWEwB,aAAa,CAAbA,aAXF,CAYEvB,IAAI,CAAJA,IAZF,CAaEO,OAAO,CAAPA,OAbF,CAcEN,gBAAgB,CAAhBA,gBAdF,CAeEE,uBAAuB,CAAvBA,uBAfF,CAgBEC,KAAK,CAALA,KAhBF,CAiBEC,sBAAsB,CAAtBA,sBAjBF,CAkBEG,aAAa,CAAbA,aAlBF,CAmBEE,WAAW,CAAXA,WAnBF,CAoBED,iBAAiB,CAAjBA,iBApBF,CAqBEI,KAAK,CAALA,KArBF,CAsBEE,MAAM,CAANA,MAtBF,GAwBD","sourcesContent":["import React from \"react\";\n\nimport type { TCarouselProps } from \"../types\";\nimport { computedFillDataWithAutoFillData } from \"../utils/computedWithAutoFillData\";\n\ntype TGetRequiredProps<P extends keyof TCarouselProps> = Record<\nP,\nRequired<TCarouselProps>[P]\n>;\n\nexport type TInitializeCarouselProps<T> = TCarouselProps<T> &\nTGetRequiredProps<\n| \"defaultIndex\"\n| \"loop\"\n| \"width\"\n| \"height\"\n| \"scrollAnimationDuration\"\n| \"autoPlayInterval\"\n| \"autoFillData\"\n> & {\n // Raw data that has not been processed\n rawData: T[]\n dataLength: number\n rawDataLength: number\n};\n\nexport function useInitProps<T>(\n props: TCarouselProps<T>,\n): TInitializeCarouselProps<T> {\n const {\n defaultIndex = 0,\n data: rawData = [],\n loop = true,\n autoPlayInterval: _autoPlayInterval = 1000,\n scrollAnimationDuration = 500,\n style = {},\n panGestureHandlerProps = {},\n autoFillData = true,\n // switchers\n enabled = true,\n pagingEnabled = true,\n overscrollEnabled = true,\n snapEnabled = props.enableSnap ?? true,\n width: _width,\n height: _height,\n } = props;\n\n const width = Math.round(_width || 0);\n const height = Math.round(_height || 0);\n const autoPlayInterval = Math.max(_autoPlayInterval, 0);\n\n const data = React.useMemo<T[]>(\n () => {\n return computedFillDataWithAutoFillData<T>({\n loop,\n autoFillData,\n data: rawData,\n dataLength: rawData.length,\n });\n },\n [rawData, loop, autoFillData],\n );\n\n const dataLength = data.length;\n const rawDataLength = rawData.length;\n\n if (props.mode === \"vertical-stack\" || props.mode === \"horizontal-stack\") {\n if (!props.modeConfig)\n props.modeConfig = {};\n\n props.modeConfig.showLength = props.modeConfig?.showLength ?? dataLength - 1;\n }\n\n return {\n ...props,\n defaultIndex,\n autoFillData,\n // Fill data with autoFillData\n data,\n // Length of fill data\n dataLength,\n // Raw data that has not been processed\n rawData,\n // Length of raw data\n rawDataLength,\n loop,\n enabled,\n autoPlayInterval,\n scrollAnimationDuration,\n style,\n panGestureHandlerProps,\n pagingEnabled,\n snapEnabled,\n overscrollEnabled,\n width,\n height,\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 handlerOffset=opts.handlerOffset,index=opts.index,size=opts.size,loop=opts.loop,dataLength=opts.dataLength,_opts$type=opts.type,type=_opts$type===void 0?"positive":_opts$type,_viewCount=opts.viewCount;var ITEM_LENGTH=dataLength;var VALID_LENGTH=ITEM_LENGTH-1;var TOTAL_WIDTH=size*ITEM_LENGTH;var HALF_WIDTH=0.5*size;var viewCount=_viewCount!=null?_viewCount:Math.round((ITEM_LENGTH-1)/2);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)(handlerOffset.value,inputRange,outputRange,_reactNativeReanimated.Extrapolate.CLAMP);}return handlerOffset.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,handlerOffset:handlerOffset,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},size:size};_f.asString="function _f(){const{visibleRanges,index,loop,TOTAL_WIDTH,MIN,HALF_WIDTH,startPos,MAX,interpolate,handlerOffset,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(handlerOffset.value,inputRange,outputRange,Extrapolate.CLAMP);}return handlerOffset.value+size*index;}}";_f.__workletHash=3599227485688;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOffsetX.ts (47:28)";return _f;}(),[loop,dataLength,viewCount,type,size,visibleRanges]);return x;};exports.useOffsetX=useOffsetX;
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.useOffsetX=void 0;var _reactNativeReanimated=require("react-native-reanimated");var useOffsetX=function useOffsetX(opts,visibleRanges){var handlerOffset=opts.handlerOffset,index=opts.index,size=opts.size,loop=opts.loop,dataLength=opts.dataLength,_opts$type=opts.type,type=_opts$type===void 0?"positive":_opts$type,_viewCount=opts.viewCount;var ITEM_LENGTH=dataLength;var VALID_LENGTH=ITEM_LENGTH-1;var TOTAL_WIDTH=size*ITEM_LENGTH;var HALF_WIDTH=0.5*size;var viewCount=_viewCount!=null?_viewCount:Math.round((ITEM_LENGTH-1)/2);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)(handlerOffset.value,inputRange,outputRange,_reactNativeReanimated.Extrapolate.CLAMP);}return handlerOffset.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,handlerOffset:handlerOffset,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},size:size};_f.asString="function _f(){const{visibleRanges,index,loop,TOTAL_WIDTH,MIN,HALF_WIDTH,startPos,MAX,interpolate,handlerOffset,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(handlerOffset.value,inputRange,outputRange,Extrapolate.CLAMP);}return handlerOffset.value+size*index;}}";_f.__workletHash=3599227485688;_f.__location="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useOffsetX.ts (47:28)";return _f;}(),[loop,dataLength,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","handlerOffset","index","size","loop","dataLength","type","_viewCount","viewCount","ITEM_LENGTH","VALID_LENGTH","TOTAL_WIDTH","HALF_WIDTH","Math","round","positiveCount","startPos","MAX","MIN","x","value","negativeRange","positiveRange","Number","MAX_SAFE_INTEGER","inputRange","MIN_VALUE","outputRange","Extrapolate","CLAMP","interpolate"],"mappings":"mFACA,8DA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CAAOC,UAAP,CAAmBG,SAAnB,CAA8BF,IAA9B,CAAoCH,IAApC,CAA0CH,aAA1C,CAtCO,CAAV,CAwCA,MAAOmB,CAAAA,CAAP,CACD,CApEM,C","sourcesContent":["import type Animated from \"react-native-reanimated\";\nimport {\n Extrapolate,\n interpolate,\n useDerivedValue,\n} from \"react-native-reanimated\";\n\nimport type { IVisibleRanges } from \"./useVisibleRanges\";\n\nexport interface IOpts {\n index: number\n size: number\n handlerOffset: Animated.SharedValue<number>\n dataLength: number\n type?: \"positive\" | \"negative\"\n viewCount?: number\n loop?: boolean\n}\n\nexport const useOffsetX = (opts: IOpts, visibleRanges: IVisibleRanges) => {\n const {\n handlerOffset,\n index,\n size,\n loop,\n dataLength,\n type = \"positive\",\n viewCount: _viewCount,\n } = opts;\n\n const ITEM_LENGTH = dataLength;\n const VALID_LENGTH = ITEM_LENGTH - 1;\n const TOTAL_WIDTH = size * ITEM_LENGTH;\n const HALF_WIDTH = 0.5 * size;\n\n const viewCount = _viewCount ?? Math.round((ITEM_LENGTH - 1) / 2);\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 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 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 handlerOffset.value,\n inputRange,\n outputRange,\n Extrapolate.CLAMP,\n );\n }\n\n return handlerOffset.value + size * index;\n }, [loop, dataLength, viewCount, type, size, visibleRanges]);\n\n return x;\n};\n"]}
1
+ {"version":3,"sources":["useOffsetX.ts"],"names":["useOffsetX","opts","visibleRanges","handlerOffset","index","size","loop","dataLength","type","_viewCount","viewCount","ITEM_LENGTH","VALID_LENGTH","TOTAL_WIDTH","HALF_WIDTH","Math","round","positiveCount","startPos","MAX","MIN","x","value","negativeRange","positiveRange","Number","MAX_SAFE_INTEGER","inputRange","MIN_VALUE","outputRange","Extrapolate","CLAMP","interpolate"],"mappings":"mFACA,8DAkBO,GAAMA,CAAAA,UAAU,CAAG,QAAbA,CAAAA,UAAa,CAACC,IAAD,CAAcC,aAAd,CAAgD,CACxE,GACEC,CAAAA,aADF,CAQIF,IARJ,CACEE,aADF,CAEEC,KAFF,CAQIH,IARJ,CAEEG,KAFF,CAGEC,IAHF,CAQIJ,IARJ,CAGEI,IAHF,CAIEC,IAJF,CAQIL,IARJ,CAIEK,IAJF,CAKEC,UALF,CAQIN,IARJ,CAKEM,UALF,YAQIN,IARJ,CAMEO,IANF,CAMEA,IANF,qBAMS,UANT,YAOaC,UAPb,CAQIR,IARJ,CAOES,SAPF,CAUA,GAAMC,CAAAA,WAAW,CAAGJ,UAApB,CACA,GAAMK,CAAAA,YAAY,CAAGD,WAAW,CAAG,CAAnC,CACA,GAAME,CAAAA,WAAW,CAAGR,IAAI,CAAGM,WAA3B,CACA,GAAMG,CAAAA,UAAU,CAAG,IAAMT,IAAzB,CAEA,GAAMK,CAAAA,SAAS,CAAGD,UAAH,OAAGA,UAAH,CAAiBM,IAAI,CAACC,KAAL,CAAW,CAACL,WAAW,CAAG,CAAf,EAAoB,CAA/B,CAAhC,CACA,GAAMM,CAAAA,aAAa,CACXT,IAAI,GAA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,UALY,CAMlBM,GAAG,CAAGN,UAAN,CAAmBW,MAAM,CAACG,SANR,CAOlBV,QAPkB,CAApB,CAUA,MAAO,uCACLf,aAAa,CAACmB,KADT,CAELK,UAFK,CAGLE,WAHK,CAILC,mCAAYC,KAJP,CAAP,CAMD,CAED,MAAO5B,CAAAA,aAAa,CAACmB,KAAd,CAAsBjB,IAAI,CAAGD,KAApC,CACD,CAtCS,4BAzCNF,aAyCM,OAhC0BE,KAgC1B,MAtCNE,IAsCM,aArCuLO,WAqCvL,KApC0GO,GAoC1G,YApCgHN,UAoChH,UApC+II,QAoC/I,KApCwFC,GAoCxF,aAnCDa,kCAmCC,eAhCH7B,aAgCG,oBAnCyD2B,mCAAYC,KAmCrE,OAhCmB1B,IAgCnB,4+BAsCP,CAACC,IAAD,CAAOC,UAAP,CAAmBG,SAAnB,CAA8BF,IAA9B,CAAoCH,IAApC,CAA0CH,aAA1C,CAtCO,CAAV,CAwCA,MAAOmB,CAAAA,CAAP,CACD,CApEM,C","sourcesContent":["import type Animated from \"react-native-reanimated\";\nimport {\n Extrapolate,\n interpolate,\n useDerivedValue,\n} from \"react-native-reanimated\";\n\nimport type { IVisibleRanges } from \"./useVisibleRanges\";\n\nexport interface IOpts {\n index: number\n size: number\n handlerOffset: Animated.SharedValue<number>\n dataLength: number\n type?: \"positive\" | \"negative\"\n viewCount?: number\n loop?: boolean\n}\n\nexport const useOffsetX = (opts: IOpts, visibleRanges: IVisibleRanges) => {\n const {\n handlerOffset,\n index,\n size,\n loop,\n dataLength,\n type = \"positive\",\n viewCount: _viewCount,\n } = opts;\n\n const ITEM_LENGTH = dataLength;\n const VALID_LENGTH = ITEM_LENGTH - 1;\n const TOTAL_WIDTH = size * ITEM_LENGTH;\n const HALF_WIDTH = 0.5 * size;\n\n const viewCount = _viewCount ?? Math.round((ITEM_LENGTH - 1) / 2);\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 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 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 handlerOffset.value,\n inputRange,\n outputRange,\n Extrapolate.CLAMP,\n );\n }\n\n return handlerOffset.value + size * index;\n }, [loop, dataLength, 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,size=opts.size,rawDataLength=opts.rawDataLength,onProgressChange=opts.onProgressChange;(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:4)";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;if(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;if(onProgressChange)runOnJS(onProgressChange)(value,absoluteProgress);}}";_f.__workletHash=4815839705374;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts (24:4)";return _f;}(),[loop,autoFillData,rawDataLength,onProgressChange]);}
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,size=opts.size,rawDataLength=opts.rawDataLength,onProgressChange=opts.onProgressChange;(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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts (23:4)";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;if(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;if(onProgressChange)runOnJS(onProgressChange)(value,absoluteProgress);}}";_f.__workletHash=4815839705374;_f.__location="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts (24:4)";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","size","rawDataLength","onProgressChange","value","_value","Math","max","min","absoluteProgress","abs","computedOffsetXValueWithAutoFillData","runOnJS"],"mappings":"yGACA,8DAMA,2EAEO,QAASA,CAAAA,mBAAT,CACLC,IADK,CAQL,CACA,GAAQC,CAAAA,YAAR,CACQD,IADR,CAAQC,YAAR,CAAsBC,IAAtB,CACQF,IADR,CAAsBE,IAAtB,CAA4BC,OAA5B,CACQH,IADR,CAA4BG,OAA5B,CAAqCC,IAArC,CACQJ,IADR,CAAqCI,IAArC,CAA2CC,aAA3C,CACQL,IADR,CAA2CK,aAA3C,CAA0DC,gBAA1D,CACQN,IADR,CAA0DM,gBAA1D,CAGA,iEACE,oBAAMH,CAAAA,OAAO,CAACI,KAAd,EADF,sBApBKJ,OAoBL,0RAEGK,MAFH,CAEc,CACV,GAAID,CAAAA,KAAK,CAAG,mEAAqC,CAC/CA,KAAK,CAAEC,MADwC,CAE/CH,aAAa,CAAbA,aAF+C,CAG/CD,IAAI,CAAJA,IAH+C,CAI/CH,YAAY,CAAZA,YAJ+C,CAK/CC,IAAI,CAAJA,IAL+C,CAArC,CAAZ,CAQA,GAAI,CAACA,IAAL,CAAW,CACTK,KAAK,CAAGE,IAAI,CAACC,GAAL,CACN,EAAE,CAACL,aAAa,CAAG,CAAjB,EAAsBD,IAAxB,CADM,CAENK,IAAI,CAACE,GAAL,CAASJ,KAAT,CAAgB,CAAhB,CAFM,CAAR,CAID,CAED,GAAIK,CAAAA,gBAAgB,CAAGH,IAAI,CAACI,GAAL,CAASN,KAAK,CAAGH,IAAjB,CAAvB,CAEA,GAAIG,KAAK,CAAG,CAAZ,CACEK,gBAAgB,CAAGP,aAAa,CAAGO,gBAAnC,CAEF,GAAIN,gBAAJ,CACE,mCAAQA,gBAAR,EAA0BC,KAA1B,CAAiCK,gBAAjC,EACH,CAzBH,mDAnBYE,8DAmBZ,eANkCT,aAMlC,MAPwCD,IAOxC,cAfEH,YAeF,MAXKC,IAWL,kBAL8BI,gBAK9B,SALsBS,8BAKtB,ksBA0BE,CAACb,IAAD,CAAOD,YAAP,CAAqBI,aAArB,CAAoCC,gBAApC,CA1BF,EA4BD","sourcesContent":["import type Animated from \"react-native-reanimated\";\nimport {\n runOnJS,\n useAnimatedReaction,\n} from \"react-native-reanimated\";\n\nimport type { TCarouselProps } from \"../types\";\nimport { computedOffsetXValueWithAutoFillData } from \"../utils/computedWithAutoFillData\";\n\nexport function useOnProgressChange(\n opts: {\n size: number\n autoFillData: boolean\n loop: boolean\n offsetX: Animated.SharedValue<number>\n rawDataLength: number\n } & Pick<TCarouselProps, \"onProgressChange\">,\n) {\n const { autoFillData, loop, offsetX, size, rawDataLength, onProgressChange }\n = opts;\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 if (onProgressChange)\n runOnJS(onProgressChange)(value, absoluteProgress);\n },\n [loop, autoFillData, rawDataLength, onProgressChange],\n );\n}\n"]}
1
+ {"version":3,"sources":["useOnProgressChange.ts"],"names":["useOnProgressChange","opts","autoFillData","loop","offsetX","size","rawDataLength","onProgressChange","value","_value","Math","max","min","absoluteProgress","abs","computedOffsetXValueWithAutoFillData","runOnJS"],"mappings":"yGACA,8DAMA,2EAEO,QAASA,CAAAA,mBAAT,CACLC,IADK,CAQL,CACA,GAAQC,CAAAA,YAAR,CACQD,IADR,CAAQC,YAAR,CAAsBC,IAAtB,CACQF,IADR,CAAsBE,IAAtB,CAA4BC,OAA5B,CACQH,IADR,CAA4BG,OAA5B,CAAqCC,IAArC,CACQJ,IADR,CAAqCI,IAArC,CAA2CC,aAA3C,CACQL,IADR,CAA2CK,aAA3C,CAA0DC,gBAA1D,CACQN,IADR,CAA0DM,gBAA1D,CAGA,iEACE,oBAAMH,CAAAA,OAAO,CAACI,KAAd,EADF,sBApBKJ,OAoBL,8SAEGK,MAFH,CAEc,CACV,GAAID,CAAAA,KAAK,CAAG,mEAAqC,CAC/CA,KAAK,CAAEC,MADwC,CAE/CH,aAAa,CAAbA,aAF+C,CAG/CD,IAAI,CAAJA,IAH+C,CAI/CH,YAAY,CAAZA,YAJ+C,CAK/CC,IAAI,CAAJA,IAL+C,CAArC,CAAZ,CAQA,GAAI,CAACA,IAAL,CAAW,CACTK,KAAK,CAAGE,IAAI,CAACC,GAAL,CACN,EAAE,CAACL,aAAa,CAAG,CAAjB,EAAsBD,IAAxB,CADM,CAENK,IAAI,CAACE,GAAL,CAASJ,KAAT,CAAgB,CAAhB,CAFM,CAAR,CAID,CAED,GAAIK,CAAAA,gBAAgB,CAAGH,IAAI,CAACI,GAAL,CAASN,KAAK,CAAGH,IAAjB,CAAvB,CAEA,GAAIG,KAAK,CAAG,CAAZ,CACEK,gBAAgB,CAAGP,aAAa,CAAGO,gBAAnC,CAEF,GAAIN,gBAAJ,CACE,mCAAQA,gBAAR,EAA0BC,KAA1B,CAAiCK,gBAAjC,EACH,CAzBH,mDAnBYE,8DAmBZ,eANkCT,aAMlC,MAPwCD,IAOxC,cAfEH,YAeF,MAXKC,IAWL,kBAL8BI,gBAK9B,SALsBS,8BAKtB,stBA0BE,CAACb,IAAD,CAAOD,YAAP,CAAqBI,aAArB,CAAoCC,gBAApC,CA1BF,EA4BD","sourcesContent":["import type Animated from \"react-native-reanimated\";\nimport {\n runOnJS,\n useAnimatedReaction,\n} from \"react-native-reanimated\";\n\nimport type { TCarouselProps } from \"../types\";\nimport { computedOffsetXValueWithAutoFillData } from \"../utils/computedWithAutoFillData\";\n\nexport function useOnProgressChange(\n opts: {\n size: number\n autoFillData: boolean\n loop: boolean\n offsetX: Animated.SharedValue<number>\n rawDataLength: number\n } & Pick<TCarouselProps, \"onProgressChange\">,\n) {\n const { autoFillData, loop, offsetX, size, rawDataLength, onProgressChange }\n = opts;\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 if (onProgressChange)\n runOnJS(onProgressChange)(value, absoluteProgress);\n },\n [loop, autoFillData, rawDataLength, onProgressChange],\n );\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:33)";return _f;}(),[total,windowSize,translation]);return ranges;}
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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useVisibleRanges.tsx (24:33)";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,CACjB,mBAKIA,OALJ,CACEC,KADF,CACEA,KADF,yBACU,CADV,gBAEEC,QAFF,CAKIF,OALJ,CAEEE,QAFF,CAGEC,WAHF,CAKIH,OALJ,CAGEG,WAHF,qBAKIH,OALJ,CAIEI,UAJF,CAIcC,WAJd,8BAI4B,CAJ5B,qBAOA,GAAMD,CAAAA,UAAU,CAAGH,KAAK,EAAII,WAAT,CAAuBJ,KAAvB,CAA+BI,WAAlD,CAEA,GAAMC,CAAAA,MAAM,CAAG,0EAAsB,CACnC,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,CACpB,CAACF,QAAQ,CAAGD,aAAX,CAA2BT,KAA5B,EAAqCA,KADjB,CAEpB,CAACU,QAAQ,CAAG,CAAX,CAAeV,KAAhB,EAAyBA,KAFL,CAAtB,CAIA,GAAMa,CAAAA,aAAa,CAAG,CACpB,CAACH,QAAQ,CAAGV,KAAZ,EAAqBA,KADD,CAEpB,CAACU,QAAQ,CAAGJ,aAAX,CAA2BN,KAA5B,EAAqCA,KAFjB,CAAtB,CAIA,GAAIY,aAAa,CAAC,CAAD,CAAb,CAAmBZ,KAAnB,EAA4BY,aAAa,CAAC,CAAD,CAAb,CAAmBA,aAAa,CAAC,CAAD,CAAhE,CAAqE,CACnEA,aAAa,CAAC,CAAD,CAAb,CAAmBZ,KAAK,CAAG,CAA3B,CACAa,aAAa,CAAC,CAAD,CAAb,CAAmB,CAAnB,CACD,CACD,GAAIA,aAAa,CAAC,CAAD,CAAb,CAAmBA,aAAa,CAAC,CAAD,CAApC,CAAyC,CACvCD,aAAa,CAAC,CAAD,CAAb,CAAmBZ,KAAK,CAAG,CAA3B,CACAa,aAAa,CAAC,CAAD,CAAb,CAAmB,CAAnB,CACD,CACD,MAAO,CAAED,aAAa,CAAbA,aAAF,CAAiBC,aAAa,CAAbA,aAAjB,CAAP,CACD,CAtBc,yBApBOV,UAoBP,aAnBYD,WAmBZ,UAnBgCD,QAmBhC,OARMD,KAQN,y2BAsBZ,CAACA,KAAD,CAAQG,UAAR,CAAoBD,WAApB,CAtBY,CAAf,CAwBA,MAAOG,CAAAA,MAAP,CACD","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
+ {"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,CACjB,mBAKIA,OALJ,CACEC,KADF,CACEA,KADF,yBACU,CADV,gBAEEC,QAFF,CAKIF,OALJ,CAEEE,QAFF,CAGEC,WAHF,CAKIH,OALJ,CAGEG,WAHF,qBAKIH,OALJ,CAIEI,UAJF,CAIcC,WAJd,8BAI4B,CAJ5B,qBAOA,GAAMD,CAAAA,UAAU,CAAGH,KAAK,EAAII,WAAT,CAAuBJ,KAAvB,CAA+BI,WAAlD,CAEA,GAAMC,CAAAA,MAAM,CAAG,0EAAsB,CACnC,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,CACpB,CAACF,QAAQ,CAAGD,aAAX,CAA2BT,KAA5B,EAAqCA,KADjB,CAEpB,CAACU,QAAQ,CAAG,CAAX,CAAeV,KAAhB,EAAyBA,KAFL,CAAtB,CAIA,GAAMa,CAAAA,aAAa,CAAG,CACpB,CAACH,QAAQ,CAAGV,KAAZ,EAAqBA,KADD,CAEpB,CAACU,QAAQ,CAAGJ,aAAX,CAA2BN,KAA5B,EAAqCA,KAFjB,CAAtB,CAIA,GAAIY,aAAa,CAAC,CAAD,CAAb,CAAmBZ,KAAnB,EAA4BY,aAAa,CAAC,CAAD,CAAb,CAAmBA,aAAa,CAAC,CAAD,CAAhE,CAAqE,CACnEA,aAAa,CAAC,CAAD,CAAb,CAAmBZ,KAAK,CAAG,CAA3B,CACAa,aAAa,CAAC,CAAD,CAAb,CAAmB,CAAnB,CACD,CACD,GAAIA,aAAa,CAAC,CAAD,CAAb,CAAmBA,aAAa,CAAC,CAAD,CAApC,CAAyC,CACvCD,aAAa,CAAC,CAAD,CAAb,CAAmBZ,KAAK,CAAG,CAA3B,CACAa,aAAa,CAAC,CAAD,CAAb,CAAmB,CAAnB,CACD,CACD,MAAO,CAAED,aAAa,CAAbA,aAAF,CAAiBC,aAAa,CAAbA,aAAjB,CAAP,CACD,CAtBc,yBApBOV,UAoBP,aAnBYD,WAmBZ,UAnBgCD,QAmBhC,OARMD,KAQN,63BAsBZ,CAACA,KAAD,CAAQG,UAAR,CAAoBD,WAApB,CAtBY,CAAf,CAwBA,MAAOG,CAAAA,MAAP,CACD","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 handlerOffset=props.handlerOffset,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,dataLength=_context$props.dataLength,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({handlerOffset:handlerOffset,index:index,size:size,dataLength:dataLength,loop:loop},typeof customConfig==="function"?customConfig():{});if(mode==="horizontal-stack"){var _ref=modeConfig,snapDirection=_ref.snapDirection,showLength=_ref.showLength;offsetXConfig={handlerOffset:handlerOffset,index:index,size:size,dataLength:dataLength,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 (74:41)";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 (76:4)";_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 (92:4)";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 (93:4)";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:103,columnNumber:5}},_react.default.createElement(_LazyView.LazyView,{shouldUpdate:shouldUpdate,__self:_this,__source:{fileName:_jsxFileName,lineNumber:113,columnNumber:7}},children({animationValue:animationValue})));};exports.BaseLayout=BaseLayout;
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="/home/runner/work/react-native-reanimated-carousel/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 handlerOffset=props.handlerOffset,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,dataLength=_context$props.dataLength,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({handlerOffset:handlerOffset,index:index,size:size,dataLength:dataLength,loop:loop},typeof customConfig==="function"?customConfig():{});if(mode==="horizontal-stack"){var _ref=modeConfig,snapDirection=_ref.snapDirection,showLength=_ref.showLength;offsetXConfig={handlerOffset:handlerOffset,index:index,size:size,dataLength:dataLength,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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (74:41)";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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (76:4)";_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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (92:4)";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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (93:4)";return _f;}(),[visibleRanges.value]);return _react.default.createElement(_reactNativeReanimated.default.View,{style:[{width:width||"100%",height:height||"100%",position:"absolute"},animatedStyle],testID:"__CAROUSEL_ITEM_"+index+"_"+(shouldUpdate?"READY":"NOT_READY")+"__",__self:_this,__source:{fileName:_jsxFileName,lineNumber:103,columnNumber:5}},_react.default.createElement(_LazyView.LazyView,{shouldUpdate:shouldUpdate,__self:_this,__source:{fileName:_jsxFileName,lineNumber:119,columnNumber:7}},children({animationValue:animationValue})));};exports.BaseLayout=BaseLayout;
2
2
  //# sourceMappingURL=BaseLayout.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["BaseLayout.tsx"],"names":["BaseLayout","props","mounted","handlerOffset","index","children","visibleRanges","animationStyle","context","React","useContext","CTX","loop","dataLength","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,oDAGA,uFASA,yDAEA,+CAEA,qCACA,+B,q4DAIO,GAAMA,CAAAA,UAQX,CAAG,QARQA,CAAAA,UAQR,CAACC,KAAD,CAAW,CACd,GAAMC,CAAAA,OAAO,CAAG,sCAAhB,CACA,GAAQC,CAAAA,aAAR,CACQF,KADR,CAAQE,aAAR,CAAuBC,KAAvB,CACQH,KADR,CAAuBG,KAAvB,CAA8BC,QAA9B,CACQJ,KADR,CAA8BI,QAA9B,CAAwCC,aAAxC,CACQL,KADR,CAAwCK,aAAxC,CAAuDC,cAAvD,CACQN,KADR,CAAuDM,cAAvD,CAGA,GAAMC,CAAAA,OAAO,CAAGC,eAAMC,UAAN,CAAiBC,UAAjB,CAAhB,CACA,mBAWIH,OAXJ,CACEP,KADF,CAEIW,IAFJ,gBAEIA,IAFJ,CAGIC,UAHJ,gBAGIA,UAHJ,CAIIC,KAJJ,gBAIIA,KAJJ,CAKIC,MALJ,gBAKIA,MALJ,CAMIC,QANJ,gBAMIA,QANJ,CAOIC,YAPJ,gBAOIA,YAPJ,CAQIC,IARJ,gBA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b,cAAD,CAFoB,CAAtB,CAKA,GAAM0B,CAAAA,UAAU,CAAGxB,eAAMyB,WAAN,CACjB,SAACC,aAAD,CAA0BC,aAA1B,CAAsD,CACpDlC,OAAO,CAACmC,OAAR,EACad,eAAe,CACfnB,KAAK,EAAI+B,aAAa,CAAC,CAAD,CAAtB,EAA6B/B,KAAK,EAAI+B,aAAa,CAAC,CAAD,CAApD,EACU/B,KAAK,EAAIgC,aAAa,CAAC,CAAD,CAAtB,EAA6BhC,KAAK,EAAIgC,aAAa,CAAC,CAAD,CAF7C,CAD5B,CAKD,CAPgB,CAQjB,CAAChC,KAAD,CAAQF,OAAR,CARiB,CAAnB,CAWA,iEACE,oBAAMI,CAAAA,aAAa,CAACyB,KAApB,EADF,4BAzFKzB,aAyFL,iSAEQ,CACJ,mCAAQ2B,UAAR,EACE3B,aAAa,CAACyB,KAAd,CAAoBI,aADtB,CAEE7B,aAAa,CAACyB,KAAd,CAAoBK,aAFtB,EAID,CAPH,sBAxFAE,8BAwFA,YAxFQL,UAwFR,eAxFuD3B,aAwFvD,kVAQE,CAACA,aAAa,CAACyB,KAAf,CARF,EAWA,MACE,8BAAC,8BAAD,CAAU,IAAV,EACE,KAAK,CAAE,CACL,CACEjB,KAAK,CAAEA,KAAK,EAAI,MADlB,CAEEC,MAAM,CAAEA,MAAM,EAAI,MAFpB,CAGEwB,QAAQ,CAAE,UAHZ,CADK,CAMLP,aANK,CADT,8EAUE,6BAAC,kBAAD,EAAU,YAAY,CAAEV,YAAxB,8EACGjB,QAAQ,CAAC,CAAEyB,cAAc,CAAdA,cAAF,CAAD,CADX,CAVF,CADF,CAgBD,CAhGM,C","sourcesContent":["import React from \"react\";\nimport type { ViewStyle } from \"react-native\";\nimport type { AnimatedStyleProp } from \"react-native-reanimated\";\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n useDerivedValue,\n} from \"react-native-reanimated\";\n\nimport type { ILayoutConfig } from \"./stack\";\n\nimport { useCheckMounted } from \"../hooks/useCheckMounted\";\nimport type { IOpts } from \"../hooks/useOffsetX\";\nimport { useOffsetX } from \"../hooks/useOffsetX\";\nimport type { IVisibleRanges } from \"../hooks/useVisibleRanges\";\nimport { LazyView } from \"../LazyView\";\nimport { CTX } from \"../store\";\n\nexport type TAnimationStyle = (value: number) => AnimatedStyleProp<ViewStyle>;\n\nexport const BaseLayout: React.FC<{\n index: number\n handlerOffset: 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 { handlerOffset, index, children, visibleRanges, animationStyle }\n = props;\n\n const context = React.useContext(CTX);\n const {\n props: {\n loop,\n dataLength,\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 handlerOffset,\n index,\n size,\n dataLength,\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 handlerOffset,\n index,\n size,\n dataLength,\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 () => 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
+ {"version":3,"sources":["BaseLayout.tsx"],"names":["BaseLayout","props","mounted","handlerOffset","index","children","visibleRanges","animationStyle","context","React","useContext","CTX","loop","dataLength","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,oDAGA,uFASA,yDAEA,+CAEA,qCACA,+B,y5DAIO,GAAMA,CAAAA,UAQX,CAAG,QARQA,CAAAA,UAQR,CAACC,KAAD,CAAW,CACd,GAAMC,CAAAA,OAAO,CAAG,sCAAhB,CACA,GAAQC,CAAAA,aAAR,CACEF,KADF,CAAQE,aAAR,CAAuBC,KAAvB,CACEH,KADF,CAAuBG,KAAvB,CAA8BC,QAA9B,CACEJ,KADF,CAA8BI,QAA9B,CAAwCC,aAAxC,CACEL,KADF,CAAwCK,aAAxC,CAAuDC,cAAvD,CACEN,KADF,CAAuDM,cAAvD,CAGA,GAAMC,CAAAA,OAAO,CAAGC,eAAMC,UAAN,CAAiBC,UAAjB,CAAhB,CACA,mBAWIH,OAXJ,CACEP,KADF,CAEIW,IAFJ,gBAEIA,IAFJ,CAGIC,UAHJ,gBAGIA,UAHJ,CAIIC,KAJJ,gBAIIA,KAJJ,CAKIC,MALJ,gBAKIA,MALJ,CAMIC,QANJ,gBAMIA,QANJ,CAOIC,YAPJ,gBAOIA,YAPJ,CAQIC,IARJ,gBAQIA,IARJ,CASIC,UATJ,gBASIA,UATJ,CAYA,GAAMC,CAAAA,IAAI,CAAGJ,QAAQ,CAAGD,MAAH,CAAYD,KAAjC,CACA,oBAAwCL,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C,OAAO,CAACmC,OAAR,EACad,eAAe,CACfnB,KAAK,EAAI+B,aAAa,CAAC,CAAD,CAAtB,EAA6B/B,KAAK,EAAI+B,aAAa,CAAC,CAAD,CAApD,EACU/B,KAAK,EAAIgC,aAAa,CAAC,CAAD,CAAtB,EAA6BhC,KAAK,EAAIgC,aAAa,CAAC,CAAD,CAF7C,CAD5B,CAKD,CAPgB,CAQjB,CAAChC,KAAD,CAAQF,OAAR,CARiB,CAAnB,CAWA,iEACE,oBAAMI,CAAAA,aAAa,CAACyB,KAApB,EADF,4BAzFKzB,aAyFL,qTAEQ,CACJ,mCAAQ2B,UAAR,EACE3B,aAAa,CAACyB,KAAd,CAAoBI,aADtB,CAEE7B,aAAa,CAACyB,KAAd,CAAoBK,aAFtB,EAID,CAPH,sBAxFAE,8BAwFA,YAxFQL,UAwFR,eAxFuD3B,aAwFvD,sWAQE,CAACA,aAAa,CAACyB,KAAf,CARF,EAWA,MACE,8BAAC,8BAAD,CAAU,IAAV,EACE,KAAK,CAAE,CACL,CACEjB,KAAK,CAAEA,KAAK,EAAI,MADlB,CAEEC,MAAM,CAAEA,MAAM,EAAI,MAFpB,CAGEwB,QAAQ,CAAE,UAHZ,CADK,CAMLP,aANK,CADT,CAcE,MAAM,oBAAqB5B,KAArB,MAA8BkB,YAAY,CAAG,OAAH,CAAa,WAAvD,MAdR,8EAgBE,6BAAC,kBAAD,EAAU,YAAY,CAAEA,YAAxB,8EACGjB,QAAQ,CAAC,CAAEyB,cAAc,CAAdA,cAAF,CAAD,CADX,CAhBF,CADF,CAsBD,CAtGM,C","sourcesContent":["import React from \"react\";\nimport type { ViewStyle } from \"react-native\";\nimport type { AnimatedStyleProp } from \"react-native-reanimated\";\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n useDerivedValue,\n} from \"react-native-reanimated\";\n\nimport type { ILayoutConfig } from \"./stack\";\n\nimport { useCheckMounted } from \"../hooks/useCheckMounted\";\nimport type { IOpts } from \"../hooks/useOffsetX\";\nimport { useOffsetX } from \"../hooks/useOffsetX\";\nimport type { IVisibleRanges } from \"../hooks/useVisibleRanges\";\nimport { LazyView } from \"../LazyView\";\nimport { CTX } from \"../store\";\n\nexport type TAnimationStyle = (value: number) => AnimatedStyleProp<ViewStyle>;\n\nexport const BaseLayout: React.FC<{\n index: number\n handlerOffset: 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 { handlerOffset, index, children, visibleRanges, animationStyle }\n = props;\n\n const context = React.useContext(CTX);\n const {\n props: {\n loop,\n dataLength,\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 handlerOffset,\n index,\n size,\n dataLength,\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 handlerOffset,\n index,\n size,\n dataLength,\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 () => 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 * We use this testID to know when the carousel item is ready to be tested in test.\n * e.g.\n * The testID of first item will be changed to __CAROUSEL_ITEM_0_READY__ from __CAROUSEL_ITEM_0_NOT_READY__ when the item is ready.\n * */\n testID={`__CAROUSEL_ITEM_${index}_${shouldUpdate ? \"READY\" : \"NOT_READY\"}__`}\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 handlerOffset=props.handlerOffset,_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,dataLength=props.dataLength,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)({handlerOffset:handlerOffset,index:index,size:size,dataLength:dataLength,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 (58:40)";_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 (118:4)";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 (119:4)";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:129,columnNumber:5}},_react.default.createElement(_LazyView.LazyView,{shouldUpdate:shouldUpdate,__self:_this,__source:{fileName:_jsxFileName,lineNumber:139,columnNumber:7}},children));};exports.ParallaxLayout=ParallaxLayout;
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="/home/runner/work/react-native-reanimated-carousel/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 handlerOffset=props.handlerOffset,_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,dataLength=props.dataLength,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)({handlerOffset:handlerOffset,index:index,size:size,dataLength:dataLength,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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (58:40)";_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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (118:4)";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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (119:4)";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:129,columnNumber:5}},_react.default.createElement(_LazyView.LazyView,{shouldUpdate:shouldUpdate,__self:_this,__source:{fileName:_jsxFileName,lineNumber:139,columnNumber:7}},children));};exports.ParallaxLayout=ParallaxLayout;
2
2
  //# sourceMappingURL=ParallaxLayout.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["ParallaxLayout.tsx"],"names":["ParallaxLayout","props","handlerOffset","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","index","width","height","loop","dataLength","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,uFAUA,+CAEA,qC,unCAGO,GAAMA,CAAAA,cAUZ,CAAG,QAVSA,CAAAA,cAUT,CAACC,KAAD,CAAW,CACb,GACEC,CAAAA,aADF,CAaID,KAbJ,CACEC,aADF,uBAaID,KAbJ,CAEEE,uBAFF,CAEEA,uBAFF,gCAE4B,GAF5B,8CAaIF,KAbJ,CAGEG,sBAHF,CAGEA,sBAHF,iCAG2B,GAH3B,8CAaIH,KAbJ,CAIEI,yBAJF,CAIEA,yBAJF,yCAI8BD,sBAJ9B,CAIwD,CAJxD,wBAKEE,KALF,CAaIL,KAbJ,CAKEK,KALF,CAMEC,KANF,CAaIN,KAbJ,CAMEM,KANF,CAOEC,MAPF,CAaIP,KAbJ,CAOEO,MAPF,CAQEC,IARF,CAaIR,KAbJ,CAQEQ,IARF,CASEC,UATF,CAaIT,KAbJ,CASES,UATF,CAUEC,QAVF,CAaIV,KAbJ,CAUEU,QAVF,CAWEC,aAXF,CAaIX,KAbJ,CAWEW,aAXF,CAYEC,QAZF,CAaIZ,KAb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"react\";\nimport Animated, {\n Extrapolate,\n interpolate,\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n} from \"react-native-reanimated\";\n\nimport type { ILayoutConfig } from \"./parallax\";\n\nimport { useOffsetX } from \"../hooks/useOffsetX\";\nimport type { IVisibleRanges } from \"../hooks/useVisibleRanges\";\nimport { LazyView } from \"../LazyView\";\nimport type { IComputedDirectionTypes } from \"../types\";\n\nexport const ParallaxLayout: React.FC<\nIComputedDirectionTypes<\n{\n loop?: boolean\n handlerOffset: Animated.SharedValue<number>\n index: number\n dataLength: number\n visibleRanges: IVisibleRanges\n} & ILayoutConfig\n>\n> = (props) => {\n const {\n handlerOffset,\n parallaxScrollingOffset = 100,\n parallaxScrollingScale = 0.8,\n parallaxAdjacentItemScale = parallaxScrollingScale ** 2,\n index,\n width,\n height,\n loop,\n dataLength,\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 handlerOffset,\n index,\n size,\n dataLength,\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
+ {"version":3,"sources":["ParallaxLayout.tsx"],"names":["ParallaxLayout","props","handlerOffset","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","index","width","height","loop","dataLength","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,uFAUA,+CAEA,qC,2oCAGO,GAAMA,CAAAA,cAUZ,CAAG,QAVSA,CAAAA,cAUT,CAACC,KAAD,CAAW,CACb,GACEC,CAAAA,aADF,CAaID,KAbJ,CACEC,aADF,uBAaID,KAbJ,CAEEE,uBAFF,CAEEA,uBAFF,gCAE4B,GAF5B,8CAaIF,KAbJ,CAGEG,sBAHF,CAGEA,sBAHF,iCAG2B,GAH3B,8CAaIH,KAbJ,CAIEI,yBAJF,CAIEA,yBAJF,yCAI8BD,sBAJ9B,CAIwD,CAJxD,wBAKEE,KALF,CAaIL,KAbJ,CAKEK,KALF,CAMEC,KANF,CAaIN,KAbJ,CAMEM,KANF,CAOEC,MAPF,CAaIP,KAbJ,CAOEO,MAPF,CAQEC,IARF,CAaIR,KAbJ,CAQEQ,IARF,CASEC,UATF,CAaIT,KAbJ,CASES,UATF,CAUEC,QAVF,CAaIV,KAbJ,CAUEU,QAVF,CAWEC,aAXF,CAaIX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AAvC,CAVF,CADF,CAcD,CA7HM,C","sourcesContent":["import React from \"react\";\nimport Animated, {\n Extrapolate,\n interpolate,\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n} from \"react-native-reanimated\";\n\nimport type { ILayoutConfig } from \"./parallax\";\n\nimport { useOffsetX } from \"../hooks/useOffsetX\";\nimport type { IVisibleRanges } from \"../hooks/useVisibleRanges\";\nimport { LazyView } from \"../LazyView\";\nimport type { IComputedDirectionTypes } from \"../types\";\n\nexport const ParallaxLayout: React.FC<\nIComputedDirectionTypes<\n{\n loop?: boolean\n handlerOffset: Animated.SharedValue<number>\n index: number\n dataLength: number\n visibleRanges: IVisibleRanges\n} & ILayoutConfig\n>\n> = (props) => {\n const {\n handlerOffset,\n parallaxScrollingOffset = 100,\n parallaxScrollingScale = 0.8,\n parallaxAdjacentItemScale = parallaxScrollingScale ** 2,\n index,\n width,\n height,\n loop,\n dataLength,\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 handlerOffset,\n index,\n size,\n dataLength,\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:9)";return _f;}();}
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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/normal.ts (6:9)";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,CACtE,GAAQC,CAAAA,IAAR,CAA2BD,IAA3B,CAAQC,IAAR,CAAcC,QAAd,CAA2BF,IAA3B,CAAcE,QAAd,CAEA,qCAAQC,KAAR,CAA0B,CAExB,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,CACLI,SAAS,CAAE,CACTH,QAAQ,CACJ,CACAI,UAAU,CAAEF,SADZ,CADI,CAIJ,CACAG,UAAU,CAAEH,SADZ,CALK,CADN,CAAP,CAWD,CAfD,0BAHkBI,kCAGlB,MAH4DP,IAG5D,UADcC,QACd,wXAgBD","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
+ {"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,CACtE,GAAQC,CAAAA,IAAR,CAA2BD,IAA3B,CAAQC,IAAR,CAAcC,QAAd,CAA2BF,IAA3B,CAAcE,QAAd,CAEA,qCAAQC,KAAR,CAA0B,CAExB,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,CACLI,SAAS,CAAE,CACTH,QAAQ,CACJ,CACAI,UAAU,CAAEF,SADZ,CADI,CAIJ,CACAG,UAAU,CAAEH,SADZ,CALK,CADN,CAAP,CAWD,CAfD,0BAHkBI,kCAGlB,MAH4DP,IAG5D,UADcC,QACd,4YAgBD","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 (47:9)";return _f;}();}
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="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/parallax.ts (47:9)";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","value","translate","zIndex","Extrapolate","CLAMP","scale","transform","translateY","translateX","interpolate"],"mappings":"+FAAA,8DAmCO,QAASA,CAAAA,cAAT,CACLC,UADK,CAGL,IADAC,CAAAA,UACA,2DAD4B,EAC5B,CACA,GAAQC,CAAAA,IAAR,CAA2BF,UAA3B,CAAQE,IAAR,CAAcC,QAAd,CAA2BH,UAA3B,CAAcG,QAAd,CACA,0BAIIF,UAJJ,CACEG,uBADF,CACEA,uBADF,gCAC4B,GAD5B,8CAIIH,UAJJ,CAEEI,sBAFF,CAEEA,sBAFF,iCAE2B,GAF3B,8CAIIJ,UAJJ,CAGEK,yBAHF,CAGEA,yBAHF,yCAG8BD,sBAH9B,CAGwD,CAHxD,wBAMA,qCAAQE,KAAR,CAA0B,CAExB,GAAMC,CAAAA,SAAS,CAAG,uCAChBD,KADgB,CAEhB,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAFgB,CAGhB,CAAC,CAACL,IAAD,CAAQE,uBAAT,CAAkC,CAAlC,CAAqCF,IAAI,CAAGE,uBAA5C,CAHgB,CAAlB,CAMA,GAAMK,CAAAA,MAAM,CAAG,uCACbF,KADa,CAEb,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAFa,CAGb,CAAC,CAAD,CAAIL,IAAJ,CAAU,CAAV,CAHa,CAIbQ,mCAAYC,KAJC,CAAf,CAOA,GAAMC,CAAAA,KAAK,CAAG,uCACZL,KADY,CAEZ,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAFY,CAGZ,CACED,yBADF,CAEED,sBAFF,CAGEC,yBAHF,CAHY,CAQZI,mCAAYC,KARA,CAAd,CAWA,MAAO,CACLE,SAAS,CAAE,CACTV,QAAQ,CACJ,CACAW,UAAU,CAAEN,SADZ,CADI,CAIJ,CACAO,UAAU,CAAEP,SADZ,CALK,CAQT,CACEI,KAAK,CAALA,KADF,CARS,CADN,CAaLH,MAAM,CAANA,MAbK,CAAP,CAeD,CAzCD,0BA1CcO,kCA0Cd,MA3CkDd,IA2ClD,yBA5C6FE,uBA4C7F,oBA1C6HM,mCAAYC,KA0CzI,4BA1CiGL,yBA0CjG,wBA1CyED,sBA0CzE,UAxCcF,QAwCd,uuBA0CD","sourcesContent":["import { Extrapolate, interpolate } from \"react-native-reanimated\";\n\nimport type { IComputedDirectionTypes } from \"../types\";\n\ninterface 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 = IComputedDirectionTypes<{\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 = 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
+ {"version":3,"sources":["parallax.ts"],"names":["parallaxLayout","baseConfig","modeConfig","size","vertical","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","value","translate","zIndex","Extrapolate","CLAMP","scale","transform","translateY","translateX","interpolate"],"mappings":"+FAAA,8DAmCO,QAASA,CAAAA,cAAT,CACLC,UADK,CAGL,IADAC,CAAAA,UACA,2DAD4B,EAC5B,CACA,GAAQC,CAAAA,IAAR,CAA2BF,UAA3B,CAAQE,IAAR,CAAcC,QAAd,CAA2BH,UAA3B,CAAcG,QAAd,CACA,0BAIIF,UAJJ,CACEG,uBADF,CACEA,uBADF,gCAC4B,GAD5B,8CAIIH,UAJJ,CAEEI,sBAFF,CAEEA,sBAFF,iCAE2B,GAF3B,8CAIIJ,UAJJ,CAGEK,yBAHF,CAGEA,yBAHF,yCAG8BD,sBAH9B,CAGwD,CAHxD,wBAMA,qCAAQE,KAAR,CAA0B,CAExB,GAAMC,CAAAA,SAAS,CAAG,uCAChBD,KADgB,CAEhB,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAFgB,CAGhB,CAAC,CAACL,IAAD,CAAQE,uBAAT,CAAkC,CAAlC,CAAqCF,IAAI,CAAGE,uBAA5C,CAHgB,CAAlB,CAMA,GAAMK,CAAAA,MAAM,CAAG,uCACbF,KADa,CAEb,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAFa,CAGb,CAAC,CAAD,CAAIL,IAAJ,CAAU,CAAV,CAHa,CAIbQ,mCAAYC,KAJC,CAAf,CAOA,GAAMC,CAAAA,KAAK,CAAG,uCACZL,KADY,CAEZ,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAFY,CAGZ,CACED,yBADF,CAEED,sBAFF,CAGEC,yBAHF,CAHY,CAQZI,mCAAYC,KARA,CAAd,CAWA,MAAO,CACLE,SAAS,CAAE,CACTV,QAAQ,CACJ,CACAW,UAAU,CAAEN,SADZ,CADI,CAIJ,CACAO,UAAU,CAAEP,SADZ,CALK,CAQT,CACEI,KAAK,CAALA,KADF,CARS,CADN,CAaLH,MAAM,CAANA,MAbK,CAAP,CAeD,CAzCD,0BA1CcO,kCA0Cd,MA3CkDd,IA2ClD,yBA5C6FE,uBA4C7F,oBA1C6HM,mCAAYC,KA0CzI,4BA1CiGL,yBA0CjG,wBA1CyED,sBA0CzE,UAxCcF,QAwCd,2vBA0CD","sourcesContent":["import { Extrapolate, interpolate } from \"react-native-reanimated\";\n\nimport type { IComputedDirectionTypes } from \"../types\";\n\ninterface 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 = IComputedDirectionTypes<{\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 = 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"]}