react-native-reanimated-carousel 3.1.3 → 3.1.5

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 (57) hide show
  1. package/lib/commonjs/Carousel.js +1 -1
  2. package/lib/commonjs/Carousel.js.map +1 -1
  3. package/lib/commonjs/ScrollViewGesture.js +1 -1
  4. package/lib/commonjs/ScrollViewGesture.js.map +1 -1
  5. package/lib/commonjs/hooks/useCarouselController.js +1 -1
  6. package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
  7. package/lib/commonjs/hooks/useCommonVariables.js +1 -1
  8. package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
  9. package/lib/commonjs/hooks/useInitProps.js +1 -1
  10. package/lib/commonjs/hooks/useInitProps.js.map +1 -1
  11. package/lib/commonjs/hooks/useOffsetX.js +1 -1
  12. package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
  13. package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
  14. package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
  15. package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
  16. package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
  17. package/lib/commonjs/layouts/BaseLayout.js +1 -1
  18. package/lib/commonjs/layouts/BaseLayout.js.map +1 -1
  19. package/lib/commonjs/layouts/ParallaxLayout.js +1 -1
  20. package/lib/commonjs/layouts/ParallaxLayout.js.map +1 -1
  21. package/lib/module/Carousel.js +17 -10
  22. package/lib/module/Carousel.js.map +1 -1
  23. package/lib/module/ScrollViewGesture.js +3 -3
  24. package/lib/module/ScrollViewGesture.js.map +1 -1
  25. package/lib/module/hooks/useCarouselController.js +14 -8
  26. package/lib/module/hooks/useCarouselController.js.map +1 -1
  27. package/lib/module/hooks/useCommonVariables.js +6 -6
  28. package/lib/module/hooks/useCommonVariables.js.map +1 -1
  29. package/lib/module/hooks/useInitProps.js +17 -7
  30. package/lib/module/hooks/useInitProps.js.map +1 -1
  31. package/lib/module/hooks/useOffsetX.js +5 -4
  32. package/lib/module/hooks/useOffsetX.js.map +1 -1
  33. package/lib/module/hooks/useOnProgressChange.js +1 -2
  34. package/lib/module/hooks/useOnProgressChange.js.map +1 -1
  35. package/lib/module/hooks/usePropsErrorBoundary.js +1 -2
  36. package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
  37. package/lib/module/layouts/BaseLayout.js +3 -3
  38. package/lib/module/layouts/BaseLayout.js.map +1 -1
  39. package/lib/module/layouts/ParallaxLayout.js +2 -2
  40. package/lib/module/layouts/ParallaxLayout.js.map +1 -1
  41. package/lib/typescript/hooks/useCarouselController.d.ts +1 -1
  42. package/lib/typescript/hooks/useInitProps.d.ts +2 -0
  43. package/lib/typescript/hooks/useOffsetX.d.ts +1 -1
  44. package/lib/typescript/hooks/useOnProgressChange.d.ts +1 -1
  45. package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +3 -1
  46. package/lib/typescript/layouts/ParallaxLayout.d.ts +1 -1
  47. package/package.json +1 -1
  48. package/src/Carousel.tsx +15 -10
  49. package/src/ScrollViewGesture.tsx +2 -2
  50. package/src/hooks/useCarouselController.tsx +16 -9
  51. package/src/hooks/useCommonVariables.ts +6 -6
  52. package/src/hooks/useInitProps.ts +17 -5
  53. package/src/hooks/useOffsetX.ts +6 -5
  54. package/src/hooks/useOnProgressChange.ts +2 -4
  55. package/src/hooks/usePropsErrorBoundary.ts +2 -3
  56. package/src/layouts/BaseLayout.tsx +3 -3
  57. package/src/layouts/ParallaxLayout.tsx +3 -3
@@ -1,2 +1,2 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _reactNativeReanimated=require("react-native-reanimated");var _useAutoPlay2=require("./hooks/useAutoPlay");var _useCarouselController=require("./hooks/useCarouselController");var _useCommonVariables=require("./hooks/useCommonVariables");var _useInitProps=require("./hooks/useInitProps");var _useLayoutConfig=require("./hooks/useLayoutConfig");var _useOnProgressChange=require("./hooks/useOnProgressChange");var _usePropsErrorBoundary=require("./hooks/usePropsErrorBoundary");var _useVisibleRanges=require("./hooks/useVisibleRanges");var _BaseLayout=require("./layouts/BaseLayout");var _ScrollViewGesture=require("./ScrollViewGesture");var _store=require("./store");var _computedWithAutoFillData=require("./utils/computedWithAutoFillData");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/Carousel.tsx";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 Carousel=_react.default.forwardRef(function(_props,ref){var props=(0,_useInitProps.useInitProps)(_props);var testID=props.testID,data=props.data,rawData=props.rawData,loop=props.loop,autoFillData=props.autoFillData,mode=props.mode,style=props.style,width=props.width,height=props.height,vertical=props.vertical,autoPlay=props.autoPlay,windowSize=props.windowSize,autoPlayReverse=props.autoPlayReverse,autoPlayInterval=props.autoPlayInterval,scrollAnimationDuration=props.scrollAnimationDuration,withAnimation=props.withAnimation,renderItem=props.renderItem,onScrollEnd=props.onScrollEnd,onSnapToItem=props.onSnapToItem,_onScrollBegin=props.onScrollBegin,onProgressChange=props.onProgressChange,customAnimation=props.customAnimation,defaultIndex=props.defaultIndex;var commonVariables=(0,_useCommonVariables.useCommonVariables)(props);var size=commonVariables.size,handlerOffset=commonVariables.handlerOffset;var dataLength=data.length;var offsetX=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var totalSize=size*dataLength;var x=handlerOffset.value%totalSize;if(!loop)return handlerOffset.value;return isNaN(x)?0:x;};_f._closure={size:size,dataLength:dataLength,handlerOffset:handlerOffset,loop:loop};_f.asString="function _f(){const{size,dataLength,handlerOffset,loop}=jsThis._closure;{const totalSize=size*dataLength;const x=handlerOffset.value%totalSize;if(!loop)return handlerOffset.value;return isNaN(x)?0:x;}}";_f.__workletHash=9793733890185;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/Carousel.tsx (54:36)";return _f;}(),[loop,size,dataLength]);(0,_usePropsErrorBoundary.usePropsErrorBoundary)(props);(0,_useOnProgressChange.useOnProgressChange)({autoFillData:autoFillData,loop:loop,size:size,offsetX:offsetX,rawData:rawData,onProgressChange:onProgressChange});var carouselController=(0,_useCarouselController.useCarouselController)({loop:loop,size:size,data:data,autoFillData:autoFillData,handlerOffset:handlerOffset,withAnimation:withAnimation,defaultIndex:defaultIndex,onScrollEnd:function onScrollEnd(){return(0,_reactNativeReanimated.runOnJS)(_onScrollEnd)();},onScrollBegin:function onScrollBegin(){return!!_onScrollBegin&&(0,_reactNativeReanimated.runOnJS)(_onScrollBegin)();},duration:scrollAnimationDuration});var next=carouselController.next,prev=carouselController.prev,scrollTo=carouselController.scrollTo,getSharedIndex=carouselController.getSharedIndex,getCurrentIndex=carouselController.getCurrentIndex;var _useAutoPlay=(0,_useAutoPlay2.useAutoPlay)({autoPlay:autoPlay,autoPlayInterval:autoPlayInterval,autoPlayReverse:autoPlayReverse,carouselController:carouselController}),startAutoPlay=_useAutoPlay.start,pauseAutoPlay=_useAutoPlay.pause;var _onScrollEnd=_react.default.useCallback(function(){var _sharedIndex=Math.round(getSharedIndex());var realIndex=(0,_computedWithAutoFillData.computedRealIndexWithAutoFillData)({index:_sharedIndex,dataLength:rawData.length,loop:loop,autoFillData:autoFillData});if(onSnapToItem)onSnapToItem(realIndex);if(onScrollEnd)onScrollEnd(realIndex);},[loop,autoFillData,rawData.length,getSharedIndex,onSnapToItem,onScrollEnd]);var scrollViewGestureOnScrollBegin=_react.default.useCallback(function(){pauseAutoPlay();_onScrollBegin==null?void 0:_onScrollBegin();},[_onScrollBegin,pauseAutoPlay]);var scrollViewGestureOnScrollEnd=_react.default.useCallback(function(){startAutoPlay();_onScrollEnd();},[_onScrollEnd,startAutoPlay]);var scrollViewGestureOnTouchBegin=_react.default.useCallback(pauseAutoPlay,[pauseAutoPlay]);var scrollViewGestureOnTouchEnd=_react.default.useCallback(startAutoPlay,[startAutoPlay]);_react.default.useImperativeHandle(ref,function(){return{next:next,prev:prev,getCurrentIndex:getCurrentIndex,scrollTo:scrollTo};},[getCurrentIndex,next,prev,scrollTo]);var visibleRanges=(0,_useVisibleRanges.useVisibleRanges)({total:data.length,viewSize:size,translation:handlerOffset,windowSize:windowSize});var layoutConfig=(0,_useLayoutConfig.useLayoutConfig)(_objectSpread(_objectSpread({},props),{},{size:size}));var renderLayout=_react.default.useCallback(function(item,i){var realIndex=(0,_computedWithAutoFillData.computedRealIndexWithAutoFillData)({index:i,dataLength:rawData.length,loop:loop,autoFillData:autoFillData});return _react.default.createElement(_BaseLayout.BaseLayout,{key:i,index:i,handlerOffset:offsetX,visibleRanges:visibleRanges,animationStyle:customAnimation||layoutConfig,__self:_this,__source:{fileName:_jsxFileName,lineNumber:169,columnNumber:11}},function(_ref){var animationValue=_ref.animationValue;return renderItem({item:item,index:realIndex,animationValue:animationValue});});},[loop,rawData,offsetX,visibleRanges,autoFillData,renderItem,layoutConfig,customAnimation]);return _react.default.createElement(_store.CTX.Provider,{value:{props:props,common:commonVariables},__self:_this,__source:{fileName:_jsxFileName,lineNumber:199,columnNumber:7}},_react.default.createElement(_ScrollViewGesture.ScrollViewGesture,{key:mode,size:size,translation:handlerOffset,style:[styles.container,{width:width||"100%",height:height||"100%"},style,vertical?styles.itemsVertical:styles.itemsHorizontal],testID:testID,onScrollBegin:scrollViewGestureOnScrollBegin,onScrollEnd:scrollViewGestureOnScrollEnd,onTouchBegin:scrollViewGestureOnTouchBegin,onTouchEnd:scrollViewGestureOnTouchEnd,__self:_this,__source:{fileName:_jsxFileName,lineNumber:200,columnNumber:9}},data.map(renderLayout)));});var _default=Carousel;exports.default=_default;var styles=_reactNative.StyleSheet.create({container:{overflow:"hidden"},itemsHorizontal:{flexDirection:"row"},itemsVertical:{flexDirection:"column"}});
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _reactNativeReanimated=require("react-native-reanimated");var _useAutoPlay2=require("./hooks/useAutoPlay");var _useCarouselController=require("./hooks/useCarouselController");var _useCommonVariables=require("./hooks/useCommonVariables");var _useInitProps=require("./hooks/useInitProps");var _useLayoutConfig=require("./hooks/useLayoutConfig");var _useOnProgressChange=require("./hooks/useOnProgressChange");var _usePropsErrorBoundary=require("./hooks/usePropsErrorBoundary");var _useVisibleRanges=require("./hooks/useVisibleRanges");var _BaseLayout=require("./layouts/BaseLayout");var _ScrollViewGesture=require("./ScrollViewGesture");var _store=require("./store");var _computedWithAutoFillData=require("./utils/computedWithAutoFillData");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/Carousel.tsx";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 Carousel=_react.default.forwardRef(function(_props,ref){var props=(0,_useInitProps.useInitProps)(_props);var testID=props.testID,loop=props.loop,autoFillData=props.autoFillData,data=props.data,dataLength=props.dataLength,rawData=props.rawData,rawDataLength=props.rawDataLength,mode=props.mode,style=props.style,width=props.width,height=props.height,vertical=props.vertical,autoPlay=props.autoPlay,windowSize=props.windowSize,autoPlayReverse=props.autoPlayReverse,autoPlayInterval=props.autoPlayInterval,scrollAnimationDuration=props.scrollAnimationDuration,withAnimation=props.withAnimation,renderItem=props.renderItem,onScrollEnd=props.onScrollEnd,onSnapToItem=props.onSnapToItem,_onScrollBegin=props.onScrollBegin,onProgressChange=props.onProgressChange,customAnimation=props.customAnimation,defaultIndex=props.defaultIndex;var commonVariables=(0,_useCommonVariables.useCommonVariables)(props);var size=commonVariables.size,handlerOffset=commonVariables.handlerOffset;var offsetX=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var totalSize=size*dataLength;var x=handlerOffset.value%totalSize;if(!loop)return handlerOffset.value;return isNaN(x)?0:x;};_f._closure={size:size,dataLength:dataLength,handlerOffset:handlerOffset,loop:loop};_f.asString="function _f(){const{size,dataLength,handlerOffset,loop}=jsThis._closure;{const totalSize=size*dataLength;const x=handlerOffset.value%totalSize;if(!loop)return handlerOffset.value;return isNaN(x)?0:x;}}";_f.__workletHash=9793733890185;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/Carousel.tsx (59:36)";return _f;}(),[loop,size,dataLength]);(0,_usePropsErrorBoundary.usePropsErrorBoundary)(_objectSpread(_objectSpread({},props),{},{dataLength:dataLength}));(0,_useOnProgressChange.useOnProgressChange)({autoFillData:autoFillData,loop:loop,size:size,offsetX:offsetX,rawDataLength:rawDataLength,onProgressChange:onProgressChange});var carouselController=(0,_useCarouselController.useCarouselController)({loop:loop,size:size,dataLength:dataLength,autoFillData:autoFillData,handlerOffset:handlerOffset,withAnimation:withAnimation,defaultIndex:defaultIndex,onScrollEnd:function onScrollEnd(){return(0,_reactNativeReanimated.runOnJS)(_onScrollEnd)();},onScrollBegin:function onScrollBegin(){return!!_onScrollBegin&&(0,_reactNativeReanimated.runOnJS)(_onScrollBegin)();},duration:scrollAnimationDuration});var next=carouselController.next,prev=carouselController.prev,scrollTo=carouselController.scrollTo,getSharedIndex=carouselController.getSharedIndex,getCurrentIndex=carouselController.getCurrentIndex;var _useAutoPlay=(0,_useAutoPlay2.useAutoPlay)({autoPlay:autoPlay,autoPlayInterval:autoPlayInterval,autoPlayReverse:autoPlayReverse,carouselController:carouselController}),startAutoPlay=_useAutoPlay.start,pauseAutoPlay=_useAutoPlay.pause;var _onScrollEnd=_react.default.useCallback(function(){var _sharedIndex=Math.round(getSharedIndex());var realIndex=(0,_computedWithAutoFillData.computedRealIndexWithAutoFillData)({index:_sharedIndex,dataLength:rawDataLength,loop:loop,autoFillData:autoFillData});if(onSnapToItem)onSnapToItem(realIndex);if(onScrollEnd)onScrollEnd(realIndex);},[loop,autoFillData,rawDataLength,getSharedIndex,onSnapToItem,onScrollEnd]);var scrollViewGestureOnScrollBegin=_react.default.useCallback(function(){pauseAutoPlay();_onScrollBegin==null?void 0:_onScrollBegin();},[_onScrollBegin,pauseAutoPlay]);var scrollViewGestureOnScrollEnd=_react.default.useCallback(function(){startAutoPlay();_onScrollEnd();},[_onScrollEnd,startAutoPlay]);var scrollViewGestureOnTouchBegin=_react.default.useCallback(pauseAutoPlay,[pauseAutoPlay]);var scrollViewGestureOnTouchEnd=_react.default.useCallback(startAutoPlay,[startAutoPlay]);_react.default.useImperativeHandle(ref,function(){return{next:next,prev:prev,getCurrentIndex:getCurrentIndex,scrollTo:scrollTo};},[getCurrentIndex,next,prev,scrollTo]);var visibleRanges=(0,_useVisibleRanges.useVisibleRanges)({total:dataLength,viewSize:size,translation:handlerOffset,windowSize:windowSize});var layoutConfig=(0,_useLayoutConfig.useLayoutConfig)(_objectSpread(_objectSpread({},props),{},{size:size}));var renderLayout=_react.default.useCallback(function(item,i){var realIndex=(0,_computedWithAutoFillData.computedRealIndexWithAutoFillData)({index:i,dataLength:rawDataLength,loop:loop,autoFillData:autoFillData});return _react.default.createElement(_BaseLayout.BaseLayout,{key:i,index:i,handlerOffset:offsetX,visibleRanges:visibleRanges,animationStyle:customAnimation||layoutConfig,__self:_this,__source:{fileName:_jsxFileName,lineNumber:174,columnNumber:11}},function(_ref){var animationValue=_ref.animationValue;return renderItem({item:item,index:realIndex,animationValue:animationValue});});},[loop,rawData,offsetX,visibleRanges,autoFillData,renderItem,layoutConfig,customAnimation]);return _react.default.createElement(_store.CTX.Provider,{value:{props:props,common:commonVariables},__self:_this,__source:{fileName:_jsxFileName,lineNumber:204,columnNumber:7}},_react.default.createElement(_ScrollViewGesture.ScrollViewGesture,{key:mode,size:size,translation:handlerOffset,style:[styles.container,{width:width||"100%",height:height||"100%"},style,vertical?styles.itemsVertical:styles.itemsHorizontal],testID:testID,onScrollBegin:scrollViewGestureOnScrollBegin,onScrollEnd:scrollViewGestureOnScrollEnd,onTouchBegin:scrollViewGestureOnTouchBegin,onTouchEnd:scrollViewGestureOnTouchEnd,__self:_this,__source:{fileName:_jsxFileName,lineNumber:205,columnNumber:9}},data.map(renderLayout)));});var _default=Carousel;exports.default=_default;var styles=_reactNative.StyleSheet.create({container:{overflow:"hidden"},itemsHorizontal:{flexDirection:"row"},itemsVertical:{flexDirection:"column"}});
2
2
  //# sourceMappingURL=Carousel.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Carousel.tsx"],"names":["Carousel","React","forwardRef","_props","ref","props","testID","data","rawData","loop","autoFillData","mode","style","width","height","vertical","autoPlay","windowSize","autoPlayReverse","autoPlayInterval","scrollAnimationDuration","withAnimation","renderItem","onScrollEnd","onSnapToItem","onScrollBegin","onProgressChange","customAnimation","defaultIndex","commonVariables","size","handlerOffset","dataLength","length","offsetX","totalSize","x","value","isNaN","carouselController","_onScrollEnd","duration","next","prev","scrollTo","getSharedIndex","getCurrentIndex","startAutoPlay","start","pauseAutoPlay","pause","useCallback","_sharedIndex","Math","round","realIndex","index","scrollViewGestureOnScrollBegin","scrollViewGestureOnScrollEnd","scrollViewGestureOnTouchBegin","scrollViewGestureOnTouchEnd","useImperativeHandle","visibleRanges","total","viewSize","translation","layoutConfig","renderLayout","item","i","animationValue","common","styles","container","itemsVertical","itemsHorizontal","map","StyleSheet","create","overflow","flexDirection"],"mappings":"iQACA,oDACA,yCACA,8DAEA,iDACA,oEACA,8DACA,kDACA,wDACA,gEACA,oEACA,0DACA,gDACA,sDACA,8BAEA,0E,i4BAEA,GAAMA,CAAAA,QAAQ,CAAGC,eAAMC,UAAN,CACf,SAACC,MAAD,CAASC,GAAT,CAAiB,CACf,GAAMC,CAAAA,KAAK,CAAG,+BAAaF,MAAb,CAAd,CAEA,GACEG,CAAAA,MADF,CAwBID,KAxBJ,CACEC,MADF,CAEEC,IAFF,CAwBIF,KAxBJ,CAEEE,IAFF,CAGEC,OAHF,CAwBIH,KAxBJ,CAGEG,OAHF,CAIEC,IAJF,CAwBIJ,KAxBJ,CAIEI,IAJF,CAKEC,YALF,CAwBIL,KAxBJ,CAKEK,YALF,CAMEC,IANF,CAwBIN,KAxBJ,CAMEM,IANF,CAOEC,KAPF,CAwBIP,KAxBJ,CAOEO,KAPF,CAQEC,KARF,CAwBIR,KAxBJ,CAQEQ,KARF,CASEC,MATF,CAwBIT,KAxBJ,CASES,MATF,CAUEC,QAVF,CAwBIV,KAxBJ,CAUEU,QAVF,CAWEC,QAXF,CAwBIX,KAxBJ,CAWEW,QAXF,CAYEC,UAZF,CAwBIZ,KAxBJ,CAYEY,UAZF,CAaEC,eAbF,CAwBIb,KAxBJ,CAaEa,eAbF,CAcEC,gBAdF,CAwBId,KAxBJ,CAcEc,gBAdF,CAeEC,uBAfF,CAwBI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N,CAJT,CAeE,MAAM,CAAErE,MAfV,CAgBE,aAAa,CAAEmD,8BAhBjB,CAiBE,WAAW,CAAEC,4BAjBf,CAkBE,YAAY,CAAEC,6BAlBhB,CAmBE,UAAU,CAAEC,2BAnBd,8EAqBGrD,IAAI,CAACqE,GAAL,CAAST,YAAT,CArBH,CADF,CADF,CA2BD,CA7Mc,CAAjB,C,aAgNenE,Q,0BAIf,GAAMwE,CAAAA,MAAM,CAAGK,wBAAWC,MAAX,CAAkB,CAC/BL,SAAS,CAAE,CACTM,QAAQ,CAAE,QADD,CADoB,CAI/BJ,eAAe,CAAE,CACfK,aAAa,CAAE,KADA,CAJc,CAO/BN,aAAa,CAAE,CACbM,aAAa,CAAE,QADF,CAPgB,CAAlB,CAAf","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport React from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport { runOnJS, useDerivedValue } from \"react-native-reanimated\";\n\nimport { useAutoPlay } from \"./hooks/useAutoPlay\";\nimport { useCarouselController } from \"./hooks/useCarouselController\";\nimport { useCommonVariables } from \"./hooks/useCommonVariables\";\nimport { useInitProps } from \"./hooks/useInitProps\";\nimport { useLayoutConfig } from \"./hooks/useLayoutConfig\";\nimport { useOnProgressChange } from \"./hooks/useOnProgressChange\";\nimport { usePropsErrorBoundary } from \"./hooks/usePropsErrorBoundary\";\nimport { useVisibleRanges } from \"./hooks/useVisibleRanges\";\nimport { BaseLayout } from \"./layouts/BaseLayout\";\nimport { ScrollViewGesture } from \"./ScrollViewGesture\";\nimport { CTX } from \"./store\";\nimport type { ICarouselInstance, TCarouselProps } from \"./types\";\nimport { computedRealIndexWithAutoFillData } from \"./utils/computedWithAutoFillData\";\n\nconst Carousel = React.forwardRef<ICarouselInstance, TCarouselProps<any>>(\n (_props, ref) => {\n const props = useInitProps(_props);\n\n const {\n testID,\n data,\n rawData,\n loop,\n autoFillData,\n mode,\n style,\n width,\n height,\n vertical,\n autoPlay,\n windowSize,\n autoPlayReverse,\n autoPlayInterval,\n scrollAnimationDuration,\n withAnimation,\n renderItem,\n onScrollEnd,\n onSnapToItem,\n onScrollBegin,\n onProgressChange,\n customAnimation,\n defaultIndex,\n } = props;\n\n const commonVariables = useCommonVariables(props);\n const { size, handlerOffset } = commonVariables;\n const dataLength = data.length;\n\n const offsetX = useDerivedValue(() => {\n const totalSize = size * dataLength;\n const x = handlerOffset.value % totalSize;\n\n if (!loop)\n return handlerOffset.value;\n\n return isNaN(x) ? 0 : x;\n }, [loop, size, dataLength]);\n\n usePropsErrorBoundary(props);\n useOnProgressChange({\n autoFillData,\n loop,\n size,\n offsetX,\n rawData,\n onProgressChange,\n });\n\n const carouselController = useCarouselController({\n loop,\n size,\n data,\n autoFillData,\n handlerOffset,\n withAnimation,\n defaultIndex,\n onScrollEnd: () => runOnJS(_onScrollEnd)(),\n onScrollBegin: () => !!onScrollBegin && runOnJS(onScrollBegin)(),\n duration: scrollAnimationDuration,\n });\n\n const { next, prev, scrollTo, getSharedIndex, getCurrentIndex }\n = carouselController;\n\n const { start: startAutoPlay, pause: pauseAutoPlay } = useAutoPlay({\n autoPlay,\n autoPlayInterval,\n autoPlayReverse,\n carouselController,\n });\n\n const _onScrollEnd = React.useCallback(() => {\n const _sharedIndex = Math.round(getSharedIndex());\n\n const realIndex = computedRealIndexWithAutoFillData({\n index: _sharedIndex,\n dataLength: rawData.length,\n loop,\n autoFillData,\n });\n\n if (onSnapToItem)\n onSnapToItem(realIndex);\n\n if (onScrollEnd)\n onScrollEnd(realIndex);\n }, [\n loop,\n autoFillData,\n rawData.length,\n getSharedIndex,\n onSnapToItem,\n onScrollEnd,\n ]);\n\n const scrollViewGestureOnScrollBegin = React.useCallback(() => {\n pauseAutoPlay();\n onScrollBegin?.();\n }, [onScrollBegin, pauseAutoPlay]);\n\n const scrollViewGestureOnScrollEnd = React.useCallback(() => {\n startAutoPlay();\n _onScrollEnd();\n }, [_onScrollEnd, startAutoPlay]);\n\n const scrollViewGestureOnTouchBegin = React.useCallback(pauseAutoPlay, [\n pauseAutoPlay,\n ]);\n\n const scrollViewGestureOnTouchEnd = React.useCallback(startAutoPlay, [\n startAutoPlay,\n ]);\n\n React.useImperativeHandle(\n ref,\n () => ({\n next,\n prev,\n getCurrentIndex,\n scrollTo,\n }),\n [getCurrentIndex, next, prev, scrollTo],\n );\n\n const visibleRanges = useVisibleRanges({\n total: data.length,\n viewSize: size,\n translation: handlerOffset,\n windowSize,\n });\n\n const layoutConfig = useLayoutConfig({ ...props, size });\n\n const renderLayout = React.useCallback(\n (item: any, i: number) => {\n const realIndex = computedRealIndexWithAutoFillData({\n index: i,\n dataLength: rawData.length,\n loop,\n autoFillData,\n });\n\n return (\n <BaseLayout\n key={i}\n index={i}\n handlerOffset={offsetX}\n visibleRanges={visibleRanges}\n animationStyle={customAnimation || layoutConfig}\n >\n {({ animationValue }) =>\n renderItem({\n item,\n index: realIndex,\n animationValue,\n })\n }\n </BaseLayout>\n );\n },\n [\n loop,\n rawData,\n offsetX,\n visibleRanges,\n autoFillData,\n renderItem,\n layoutConfig,\n customAnimation,\n ],\n );\n\n return (\n <CTX.Provider value={{ props, common: commonVariables }}>\n <ScrollViewGesture\n key={mode}\n size={size}\n translation={handlerOffset}\n style={[\n styles.container,\n {\n width: width || \"100%\",\n height: height || \"100%\",\n },\n style,\n vertical\n ? styles.itemsVertical\n : styles.itemsHorizontal,\n ]}\n testID={testID}\n onScrollBegin={scrollViewGestureOnScrollBegin}\n onScrollEnd={scrollViewGestureOnScrollEnd}\n onTouchBegin={scrollViewGestureOnTouchBegin}\n onTouchEnd={scrollViewGestureOnTouchEnd}\n >\n {data.map(renderLayout)}\n </ScrollViewGesture>\n </CTX.Provider>\n );\n },\n);\n\nexport default Carousel as <T extends any>(\n props: React.PropsWithChildren<TCarouselProps<T>>\n) => React.ReactElement;\n\nconst styles = StyleSheet.create({\n container: {\n overflow: \"hidden\",\n },\n itemsHorizontal: {\n flexDirection: \"row\",\n },\n itemsVertical: {\n flexDirection: \"column\",\n },\n});\n"]}
1
+ {"version":3,"sources":["Carousel.tsx"],"names":["Carousel","React","forwardRef","_props","ref","props","testID","loop","autoFillData","data","dataLength","rawData","rawDataLength","mode","style","width","height","vertical","autoPlay","windowSize","autoPlayReverse","autoPlayInterval","scrollAnimationDuration","withAnimation","renderItem","onScrollEnd","onSnapToItem","onScrollBegin","onProgressChange","customAnimation","defaultIndex","commonVariables","size","handlerOffset","offsetX","totalSize","x","value","isNaN","carouselController","_onScrollEnd","duration","next","prev","scrollTo","getSharedIndex","getCurrentIndex","startAutoPlay","start","pauseAutoPlay","pause","useCallback","_sharedIndex","Math","round","realIndex","index","scrollViewGestureOnScrollBegin","scrollViewGestureOnScrollEnd","scrollViewGestureOnTouchBegin","scrollViewGestureOnTouchEnd","useImperativeHandle","visibleRanges","total","viewSize","translation","layoutConfig","renderLayout","item","i","animationValue","common","styles","container","itemsVertical","itemsHorizontal","map","StyleSheet","create","overflow","flexDirection"],"mappings":"iQACA,oDACA,yCACA,8DAEA,iDACA,oEACA,8DACA,kDACA,wDACA,gEACA,oEACA,0DACA,gDACA,sDACA,8BAEA,0E,i4BAEA,GAAMA,CAAAA,QAAQ,CAAGC,eAAMC,UAAN,CACf,SAACC,MAAD,CAASC,GAAT,CAAiB,CACf,GAAMC,CAAAA,KAAK,CAAG,+BAAaF,MAAb,CAAd,CAEA,GACEG,CAAAA,MADF,CA8BID,KA9BJ,CACEC,MADF,CAEEC,IAFF,CA8BIF,KA9BJ,CAEEE,IAFF,CAGEC,YAHF,CA8BIH,KA9BJ,CAGEG,YAHF,CAKEC,IALF,CA8BIJ,KA9BJ,CAKEI,IALF,CAOEC,UAPF,CA8BIL,KA9BJ,CAOEK,UAPF,CASEC,OATF,CA8BIN,KA9BJ,CASEM,OATF,CAWEC,aAXF,CA8BIP,KA9BJ,CAWEO,aAXF,CAYEC,IAZF,CA8BIR,KA9BJ,CAYEQ,IAZF,CAaEC,KAbF,CA8BIT,KA9BJ,CAaES,KAbF,CAcEC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AD,EACE,GAAG,CAAElB,IADP,CAEE,IAAI,CAAEmB,IAFR,CAGE,WAAW,CAAEC,aAHf,CAIE,KAAK,CAAE,CACLuC,MAAM,CAACC,SADF,CAEL,CACE1D,KAAK,CAAEA,KAAK,EAAI,MADlB,CAEEC,MAAM,CAAEA,MAAM,EAAI,MAFpB,CAFK,CAMLF,KANK,CAOLG,QAAQ,CACJuD,MAAM,CAACE,aADH,CAEJF,MAAM,CAACG,eATN,CAJT,CAeE,MAAM,CAAErE,MAfV,CAgBE,aAAa,CAAEmD,8BAhBjB,CAiBE,WAAW,CAAEC,4BAjBf,CAkBE,YAAY,CAAEC,6BAlBhB,CAmBE,UAAU,CAAEC,2BAnBd,8EAqBGnD,IAAI,CAACmE,GAAL,CAAST,YAAT,CArBH,CADF,CADF,CA2BD,CAlNc,CAAjB,C,aAqNenE,Q,0BAIf,GAAMwE,CAAAA,MAAM,CAAGK,wBAAWC,MAAX,CAAkB,CAC/BL,SAAS,CAAE,CACTM,QAAQ,CAAE,QADD,CADoB,CAI/BJ,eAAe,CAAE,CACfK,aAAa,CAAE,KADA,CAJc,CAO/BN,aAAa,CAAE,CACbM,aAAa,CAAE,QADF,CAPgB,CAAlB,CAAf","sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport React from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport { runOnJS, useDerivedValue } from \"react-native-reanimated\";\n\nimport { useAutoPlay } from \"./hooks/useAutoPlay\";\nimport { useCarouselController } from \"./hooks/useCarouselController\";\nimport { useCommonVariables } from \"./hooks/useCommonVariables\";\nimport { useInitProps } from \"./hooks/useInitProps\";\nimport { useLayoutConfig } from \"./hooks/useLayoutConfig\";\nimport { useOnProgressChange } from \"./hooks/useOnProgressChange\";\nimport { usePropsErrorBoundary } from \"./hooks/usePropsErrorBoundary\";\nimport { useVisibleRanges } from \"./hooks/useVisibleRanges\";\nimport { BaseLayout } from \"./layouts/BaseLayout\";\nimport { ScrollViewGesture } from \"./ScrollViewGesture\";\nimport { CTX } from \"./store\";\nimport type { ICarouselInstance, TCarouselProps } from \"./types\";\nimport { computedRealIndexWithAutoFillData } from \"./utils/computedWithAutoFillData\";\n\nconst Carousel = React.forwardRef<ICarouselInstance, TCarouselProps<any>>(\n (_props, ref) => {\n const props = useInitProps(_props);\n\n const {\n testID,\n loop,\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 mode,\n style,\n width,\n height,\n vertical,\n autoPlay,\n windowSize,\n autoPlayReverse,\n autoPlayInterval,\n scrollAnimationDuration,\n withAnimation,\n renderItem,\n onScrollEnd,\n onSnapToItem,\n onScrollBegin,\n onProgressChange,\n customAnimation,\n defaultIndex,\n } = props;\n\n const commonVariables = useCommonVariables(props);\n const { size, handlerOffset } = commonVariables;\n\n const offsetX = useDerivedValue(() => {\n const totalSize = size * dataLength;\n const x = handlerOffset.value % totalSize;\n\n if (!loop)\n return handlerOffset.value;\n\n return isNaN(x) ? 0 : x;\n }, [loop, size, dataLength]);\n\n usePropsErrorBoundary({ ...props, dataLength });\n useOnProgressChange({\n autoFillData,\n loop,\n size,\n offsetX,\n rawDataLength,\n onProgressChange,\n });\n\n const carouselController = useCarouselController({\n loop,\n size,\n dataLength,\n autoFillData,\n handlerOffset,\n withAnimation,\n defaultIndex,\n onScrollEnd: () => runOnJS(_onScrollEnd)(),\n onScrollBegin: () => !!onScrollBegin && runOnJS(onScrollBegin)(),\n duration: scrollAnimationDuration,\n });\n\n const { next, prev, scrollTo, getSharedIndex, getCurrentIndex }\n = carouselController;\n\n const { start: startAutoPlay, pause: pauseAutoPlay } = useAutoPlay({\n autoPlay,\n autoPlayInterval,\n autoPlayReverse,\n carouselController,\n });\n\n const _onScrollEnd = React.useCallback(() => {\n const _sharedIndex = Math.round(getSharedIndex());\n\n const realIndex = computedRealIndexWithAutoFillData({\n index: _sharedIndex,\n dataLength: rawDataLength,\n loop,\n autoFillData,\n });\n\n if (onSnapToItem)\n onSnapToItem(realIndex);\n\n if (onScrollEnd)\n onScrollEnd(realIndex);\n }, [\n loop,\n autoFillData,\n rawDataLength,\n getSharedIndex,\n onSnapToItem,\n onScrollEnd,\n ]);\n\n const scrollViewGestureOnScrollBegin = React.useCallback(() => {\n pauseAutoPlay();\n onScrollBegin?.();\n }, [onScrollBegin, pauseAutoPlay]);\n\n const scrollViewGestureOnScrollEnd = React.useCallback(() => {\n startAutoPlay();\n _onScrollEnd();\n }, [_onScrollEnd, startAutoPlay]);\n\n const scrollViewGestureOnTouchBegin = React.useCallback(pauseAutoPlay, [\n pauseAutoPlay,\n ]);\n\n const scrollViewGestureOnTouchEnd = React.useCallback(startAutoPlay, [\n startAutoPlay,\n ]);\n\n React.useImperativeHandle(\n ref,\n () => ({\n next,\n prev,\n getCurrentIndex,\n scrollTo,\n }),\n [getCurrentIndex, next, prev, scrollTo],\n );\n\n const visibleRanges = useVisibleRanges({\n total: dataLength,\n viewSize: size,\n translation: handlerOffset,\n windowSize,\n });\n\n const layoutConfig = useLayoutConfig({ ...props, size });\n\n const renderLayout = React.useCallback(\n (item: any, i: number) => {\n const realIndex = computedRealIndexWithAutoFillData({\n index: i,\n dataLength: rawDataLength,\n loop,\n autoFillData,\n });\n\n return (\n <BaseLayout\n key={i}\n index={i}\n handlerOffset={offsetX}\n visibleRanges={visibleRanges}\n animationStyle={customAnimation || layoutConfig}\n >\n {({ animationValue }) =>\n renderItem({\n item,\n index: realIndex,\n animationValue,\n })\n }\n </BaseLayout>\n );\n },\n [\n loop,\n rawData,\n offsetX,\n visibleRanges,\n autoFillData,\n renderItem,\n layoutConfig,\n customAnimation,\n ],\n );\n\n return (\n <CTX.Provider value={{ props, common: commonVariables }}>\n <ScrollViewGesture\n key={mode}\n size={size}\n translation={handlerOffset}\n style={[\n styles.container,\n {\n width: width || \"100%\",\n height: height || \"100%\",\n },\n style,\n vertical\n ? styles.itemsVertical\n : styles.itemsHorizontal,\n ]}\n testID={testID}\n onScrollBegin={scrollViewGestureOnScrollBegin}\n onScrollEnd={scrollViewGestureOnScrollEnd}\n onTouchBegin={scrollViewGestureOnTouchBegin}\n onTouchEnd={scrollViewGestureOnTouchEnd}\n >\n {data.map(renderLayout)}\n </ScrollViewGesture>\n </CTX.Provider>\n );\n },\n);\n\nexport default Carousel as <T extends any>(\n props: React.PropsWithChildren<TCarouselProps<T>>\n) => React.ReactElement;\n\nconst styles = StyleSheet.create({\n container: {\n overflow: \"hidden\",\n },\n itemsHorizontal: {\n flexDirection: \"row\",\n },\n itemsVertical: {\n flexDirection: \"column\",\n },\n});\n"]}
@@ -1,2 +1,2 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ScrollViewGesture=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _react=_interopRequireDefault(require("react"));var _reactNativeGestureHandler=require("react-native-gesture-handler");var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _constants=require("./constants");var _store=require("./store");var _dealWithAnimation=require("./utils/dealWithAnimation");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.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 IScrollViewGesture=function IScrollViewGesture(props){var _React$useContext=_react.default.useContext(_store.CTX),_React$useContext$pro=_React$useContext.props,vertical=_React$useContext$pro.vertical,data=_React$useContext$pro.data,pagingEnabled=_React$useContext$pro.pagingEnabled,snapEnabled=_React$useContext$pro.snapEnabled,panGestureHandlerProps=_React$useContext$pro.panGestureHandlerProps,infinite=_React$useContext$pro.loop,scrollAnimationDuration=_React$useContext$pro.scrollAnimationDuration,withAnimation=_React$useContext$pro.withAnimation,enabled=_React$useContext$pro.enabled;var size=props.size,translation=props.translation,testID=props.testID,_props$style=props.style,style=_props$style===void 0?{}:_props$style,onScrollBegin=props.onScrollBegin,onScrollEnd=props.onScrollEnd,onTouchBegin=props.onTouchBegin,onTouchEnd=props.onTouchEnd;var maxPage=data.length;var isHorizontal=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){return!vertical;};_f._closure={vertical:vertical};_f.asString="function _f(){const{vertical}=jsThis._closure;{return!vertical;}}";_f.__workletHash=14495821007639;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (67:39)";return _f;}(),[vertical]);var touching=(0,_reactNativeReanimated.useSharedValue)(false);var scrollEndTranslation=(0,_reactNativeReanimated.useSharedValue)(0);var scrollEndVelocity=(0,_reactNativeReanimated.useSharedValue)(0);var _withSpring=_react.default.useCallback(function(){var _f=function _f(toValue,onFinished){var defaultWithAnimation={type:"timing",config:{duration:scrollAnimationDuration+100,easing:_constants.Easing.easeOutQuart}};return(0,_dealWithAnimation.dealWithAnimation)(withAnimation!=null?withAnimation:defaultWithAnimation)(toValue,function(){var _f=function _f(isFinished){if(isFinished)onFinished&&(0,_reactNativeReanimated.runOnJS)(onFinished)();};_f._closure={onFinished:onFinished,runOnJS:_reactNativeReanimated.runOnJS};_f.asString="function _f(isFinished){const{onFinished,runOnJS}=jsThis._closure;{if(isFinished)onFinished&&runOnJS(onFinished)();}}";_f.__workletHash=3881957308013;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (85:8)";return _f;}());};_f._closure={scrollAnimationDuration:scrollAnimationDuration,Easing:{easeOutQuart:_constants.Easing.easeOutQuart},dealWithAnimation:_dealWithAnimation.dealWithAnimation,withAnimation:withAnimation,runOnJS:_reactNativeReanimated.runOnJS};_f.asString="function _f(toValue,onFinished){const{scrollAnimationDuration,Easing,dealWithAnimation,withAnimation,runOnJS}=jsThis._closure;{var _withAnimation;const defaultWithAnimation={type:\"timing\",config:{duration:scrollAnimationDuration+100,easing:Easing.easeOutQuart}};return dealWithAnimation((_withAnimation=withAnimation)!==null&&_withAnimation!==void 0?_withAnimation:defaultWithAnimation)(toValue,function(isFinished){\"worklet\";if(isFinished)onFinished&&runOnJS(onFinished)();});}}";_f.__workletHash=4492029393801;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (73:4)";return _f;}(),[scrollAnimationDuration,withAnimation]);var endWithSpring=_react.default.useCallback(function(){var _f=function _f(onFinished){var origin=translation.value;var velocity=scrollEndVelocity.value;if(!pagingEnabled){if(snapEnabled){var nextPage=Math.round((origin+velocity*0.4)/size)*size;translation.value=_withSpring(nextPage,onFinished);return;}translation.value=(0,_reactNativeReanimated.withDecay)({velocity:velocity,deceleration:0.999});return;}var direction=-(scrollEndTranslation.value>=0?1:-1);var computed=direction<0?Math.ceil:Math.floor;var page=computed(-translation.value/size);var finalPage=page+direction;if(!infinite)finalPage=Math.min(maxPage-1,Math.max(0,finalPage));translation.value=_withSpring(-finalPage*size,onFinished);};_f._closure={translation:translation,scrollEndVelocity:scrollEndVelocity,pagingEnabled:pagingEnabled,snapEnabled:snapEnabled,size:size,_withSpring:_withSpring,withDecay:_reactNativeReanimated.withDecay,scrollEndTranslation:scrollEndTranslation,infinite:infinite,maxPage:maxPage};_f.asString="function _f(onFinished){const{translation,scrollEndVelocity,pagingEnabled,snapEnabled,size,_withSpring,withDecay,scrollEndTranslation,infinite,maxPage}=jsThis._closure;{const origin=translation.value;const velocity=scrollEndVelocity.value;if(!pagingEnabled){if(snapEnabled){const nextPage=Math.round((origin+velocity*0.4)/size)*size;translation.value=_withSpring(nextPage,onFinished);return;}translation.value=withDecay({velocity:velocity,deceleration:0.999});return;}const direction=-(scrollEndTranslation.value>=0?1:-1);const computed=direction<0?Math.ceil:Math.floor;const page=computed(-translation.value/size);let finalPage=page+direction;if(!infinite)finalPage=Math.min(maxPage-1,Math.max(0,finalPage));translation.value=_withSpring(-finalPage*size,onFinished);}}";_f.__workletHash=7195121800163;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (96:4)";return _f;}(),[translation,scrollEndVelocity.value,pagingEnabled,size,scrollEndTranslation.value,infinite,_withSpring,snapEnabled,maxPage]);var onFinish=_react.default.useCallback(function(){var _f=function _f(isFinished){if(isFinished){touching.value=false;onScrollEnd&&(0,_reactNativeReanimated.runOnJS)(onScrollEnd)();}};_f._closure={touching:touching,onScrollEnd:onScrollEnd,runOnJS:_reactNativeReanimated.runOnJS};_f.asString="function _f(isFinished){const{touching,onScrollEnd,runOnJS}=jsThis._closure;{if(isFinished){touching.value=false;onScrollEnd&&runOnJS(onScrollEnd)();}}}";_f.__workletHash=12308424749737;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (143:4)";return _f;}(),[onScrollEnd,touching]);var activeDecay=_react.default.useCallback(function(){var _f=function _f(){touching.value=true;translation.value=(0,_reactNativeReanimated.withDecay)({velocity:scrollEndVelocity.value},function(){var _f=function _f(isFinished){return onFinish(isFinished);};_f._closure={onFinish:onFinish};_f.asString="function _f(isFinished){const{onFinish}=jsThis._closure;{return onFinish(isFinished);}}";_f.__workletHash=12004837605207;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (158:6)";return _f;}());};_f._closure={touching:touching,translation:translation,withDecay:_reactNativeReanimated.withDecay,scrollEndVelocity:scrollEndVelocity,onFinish:onFinish};_f.asString="function _f(){const{touching,translation,withDecay,scrollEndVelocity,onFinish}=jsThis._closure;{touching.value=true;translation.value=withDecay({velocity:scrollEndVelocity.value},function(isFinished){return onFinish(isFinished);});}}";_f.__workletHash=1701548878343;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (153:40)";return _f;}(),[onFinish,scrollEndVelocity.value,touching,translation]);var resetBoundary=_react.default.useCallback(function(){var _f=function _f(){if(touching.value)return;if(translation.value>0){if(scrollEndTranslation.value<0){activeDecay();return;}if(!infinite){translation.value=_withSpring(0);return;}}if(translation.value<-((maxPage-1)*size)){if(scrollEndTranslation.value>0){activeDecay();return;}if(!infinite)translation.value=_withSpring(-((maxPage-1)*size));}};_f._closure={touching:touching,translation:translation,scrollEndTranslation:scrollEndTranslation,activeDecay:activeDecay,infinite:infinite,_withSpring:_withSpring,maxPage:maxPage,size:size};_f.asString="function _f(){const{touching,translation,scrollEndTranslation,activeDecay,infinite,_withSpring,maxPage,size}=jsThis._closure;{if(touching.value)return;if(translation.value>0){if(scrollEndTranslation.value<0){activeDecay();return;}if(!infinite){translation.value=_withSpring(0);return;}}if(translation.value<-((maxPage-1)*size)){if(scrollEndTranslation.value>0){activeDecay();return;}if(!infinite)translation.value=_withSpring(-((maxPage-1)*size));}}}";_f.__workletHash=17032900471906;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (162:42)";return _f;}(),[touching.value,translation,maxPage,size,scrollEndTranslation.value,infinite,activeDecay,_withSpring]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return translation.value;};_f._closure={translation:translation};_f.asString="function _f(){const{translation}=jsThis._closure;{return translation.value;}}";_f.__workletHash=9829368032147;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (198:4)";return _f;}(),function(){var _f=function _f(){if(!pagingEnabled)resetBoundary();};_f._closure={pagingEnabled:pagingEnabled,resetBoundary:resetBoundary};_f.asString="function _f(){const{pagingEnabled,resetBoundary}=jsThis._closure;{if(!pagingEnabled)resetBoundary();}}";_f.__workletHash=3586615076030;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (199:4)";return _f;}(),[pagingEnabled,resetBoundary]);var panGestureEventHandler=(0,_reactNativeReanimated.useAnimatedGestureHandler)({onStart:function(){var _f=function _f(_,ctx){touching.value=true;ctx.validStart=true;onScrollBegin&&(0,_reactNativeReanimated.runOnJS)(onScrollBegin)();ctx.max=(maxPage-1)*size;ctx.panOffset=translation.value;};_f._closure={touching:touching,onScrollBegin:onScrollBegin,runOnJS:_reactNativeReanimated.runOnJS,maxPage:maxPage,size:size,translation:translation};_f.asString="function _f(_,ctx){const{touching,onScrollBegin,runOnJS,maxPage,size,translation}=jsThis._closure;{touching.value=true;ctx.validStart=true;onScrollBegin&&runOnJS(onScrollBegin)();ctx.max=(maxPage-1)*size;ctx.panOffset=translation.value;}}";_f.__workletHash=1789833551681;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (211:15)";return _f;}(),onActive:function(){var _f=function _f(e,ctx){if(ctx.validStart){ctx.validStart=false;(0,_reactNativeReanimated.cancelAnimation)(translation);}touching.value=true;var translationX=e.translationX,translationY=e.translationY;var panTranslation=isHorizontal.value?translationX:translationY;if(!infinite&&(translation.value>0||translation.value<-ctx.max)){var boundary=translation.value>0?0:-ctx.max;var fixed=boundary-ctx.panOffset;var dynamic=panTranslation-fixed;translation.value=boundary+dynamic*0.5;return;}translation.value=ctx.panOffset+panTranslation;};_f._closure={cancelAnimation:_reactNativeReanimated.cancelAnimation,translation:translation,touching:touching,isHorizontal:isHorizontal,infinite:infinite};_f.asString="function _f(e,ctx){const{cancelAnimation,translation,touching,isHorizontal,infinite}=jsThis._closure;{if(ctx.validStart){ctx.validStart=false;cancelAnimation(translation);}touching.value=true;const{translationX:translationX,translationY:translationY}=e;const panTranslation=isHorizontal.value?translationX:translationY;if(!infinite&&(translation.value>0||translation.value<-ctx.max)){const boundary=translation.value>0?0:-ctx.max;const fixed=boundary-ctx.panOffset;const dynamic=panTranslation-fixed;translation.value=boundary+dynamic*0.5;return;}translation.value=ctx.panOffset+panTranslation;}}";_f.__workletHash=11738845597539;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (218:16)";return _f;}(),onEnd:function(){var _f=function _f(e){var velocityX=e.velocityX,velocityY=e.velocityY,translationX=e.translationX,translationY=e.translationY;scrollEndVelocity.value=isHorizontal.value?velocityX:velocityY;scrollEndTranslation.value=isHorizontal.value?translationX:translationY;endWithSpring(onScrollEnd);if(!infinite)touching.value=false;};_f._closure={scrollEndVelocity:scrollEndVelocity,isHorizontal:isHorizontal,scrollEndTranslation:scrollEndTranslation,endWithSpring:endWithSpring,onScrollEnd:onScrollEnd,infinite:infinite,touching:touching};_f.asString="function _f(e){const{scrollEndVelocity,isHorizontal,scrollEndTranslation,endWithSpring,onScrollEnd,infinite,touching}=jsThis._closure;{const{velocityX:velocityX,velocityY:velocityY,translationX:translationX,translationY:translationY}=e;scrollEndVelocity.value=isHorizontal.value?velocityX:velocityY;scrollEndTranslation.value=isHorizontal.value?translationX:translationY;endWithSpring(onScrollEnd);if(!infinite)touching.value=false;}}";_f.__workletHash=10638018947905;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (242:13)";return _f;}()},[pagingEnabled,isHorizontal.value,infinite,maxPage,size,snapEnabled,onScrollBegin,onScrollEnd]);return _react.default.createElement(_reactNativeGestureHandler.PanGestureHandler,(0,_extends2.default)({},panGestureHandlerProps,{enabled:enabled,onGestureEvent:panGestureEventHandler,__self:_this,__source:{fileName:_jsxFileName,lineNumber:270,columnNumber:5}}),_react.default.createElement(_reactNativeReanimated.default.View,{testID:testID,style:style,onTouchStart:onTouchBegin,onTouchEnd:onTouchEnd,__self:_this,__source:{fileName:_jsxFileName,lineNumber:275,columnNumber:7}},props.children));};var ScrollViewGesture=IScrollViewGesture;exports.ScrollViewGesture=ScrollViewGesture;
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ScrollViewGesture=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _react=_interopRequireDefault(require("react"));var _reactNativeGestureHandler=require("react-native-gesture-handler");var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _constants=require("./constants");var _store=require("./store");var _dealWithAnimation=require("./utils/dealWithAnimation");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.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 IScrollViewGesture=function IScrollViewGesture(props){var _React$useContext=_react.default.useContext(_store.CTX),_React$useContext$pro=_React$useContext.props,vertical=_React$useContext$pro.vertical,pagingEnabled=_React$useContext$pro.pagingEnabled,snapEnabled=_React$useContext$pro.snapEnabled,panGestureHandlerProps=_React$useContext$pro.panGestureHandlerProps,infinite=_React$useContext$pro.loop,scrollAnimationDuration=_React$useContext$pro.scrollAnimationDuration,withAnimation=_React$useContext$pro.withAnimation,enabled=_React$useContext$pro.enabled,dataLength=_React$useContext$pro.dataLength;var size=props.size,translation=props.translation,testID=props.testID,_props$style=props.style,style=_props$style===void 0?{}:_props$style,onScrollBegin=props.onScrollBegin,onScrollEnd=props.onScrollEnd,onTouchBegin=props.onTouchBegin,onTouchEnd=props.onTouchEnd;var maxPage=dataLength;var isHorizontal=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){return!vertical;};_f._closure={vertical:vertical};_f.asString="function _f(){const{vertical}=jsThis._closure;{return!vertical;}}";_f.__workletHash=14495821007639;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (67:39)";return _f;}(),[vertical]);var touching=(0,_reactNativeReanimated.useSharedValue)(false);var scrollEndTranslation=(0,_reactNativeReanimated.useSharedValue)(0);var scrollEndVelocity=(0,_reactNativeReanimated.useSharedValue)(0);var _withSpring=_react.default.useCallback(function(){var _f=function _f(toValue,onFinished){var defaultWithAnimation={type:"timing",config:{duration:scrollAnimationDuration+100,easing:_constants.Easing.easeOutQuart}};return(0,_dealWithAnimation.dealWithAnimation)(withAnimation!=null?withAnimation:defaultWithAnimation)(toValue,function(){var _f=function _f(isFinished){if(isFinished)onFinished&&(0,_reactNativeReanimated.runOnJS)(onFinished)();};_f._closure={onFinished:onFinished,runOnJS:_reactNativeReanimated.runOnJS};_f.asString="function _f(isFinished){const{onFinished,runOnJS}=jsThis._closure;{if(isFinished)onFinished&&runOnJS(onFinished)();}}";_f.__workletHash=3881957308013;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (85:8)";return _f;}());};_f._closure={scrollAnimationDuration:scrollAnimationDuration,Easing:{easeOutQuart:_constants.Easing.easeOutQuart},dealWithAnimation:_dealWithAnimation.dealWithAnimation,withAnimation:withAnimation,runOnJS:_reactNativeReanimated.runOnJS};_f.asString="function _f(toValue,onFinished){const{scrollAnimationDuration,Easing,dealWithAnimation,withAnimation,runOnJS}=jsThis._closure;{var _withAnimation;const defaultWithAnimation={type:\"timing\",config:{duration:scrollAnimationDuration+100,easing:Easing.easeOutQuart}};return dealWithAnimation((_withAnimation=withAnimation)!==null&&_withAnimation!==void 0?_withAnimation:defaultWithAnimation)(toValue,function(isFinished){\"worklet\";if(isFinished)onFinished&&runOnJS(onFinished)();});}}";_f.__workletHash=4492029393801;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (73:4)";return _f;}(),[scrollAnimationDuration,withAnimation]);var endWithSpring=_react.default.useCallback(function(){var _f=function _f(onFinished){var origin=translation.value;var velocity=scrollEndVelocity.value;if(!pagingEnabled){if(snapEnabled){var nextPage=Math.round((origin+velocity*0.4)/size)*size;translation.value=_withSpring(nextPage,onFinished);return;}translation.value=(0,_reactNativeReanimated.withDecay)({velocity:velocity,deceleration:0.999});return;}var direction=-(scrollEndTranslation.value>=0?1:-1);var computed=direction<0?Math.ceil:Math.floor;var page=computed(-translation.value/size);var finalPage=page+direction;if(!infinite)finalPage=Math.min(maxPage-1,Math.max(0,finalPage));translation.value=_withSpring(-finalPage*size,onFinished);};_f._closure={translation:translation,scrollEndVelocity:scrollEndVelocity,pagingEnabled:pagingEnabled,snapEnabled:snapEnabled,size:size,_withSpring:_withSpring,withDecay:_reactNativeReanimated.withDecay,scrollEndTranslation:scrollEndTranslation,infinite:infinite,maxPage:maxPage};_f.asString="function _f(onFinished){const{translation,scrollEndVelocity,pagingEnabled,snapEnabled,size,_withSpring,withDecay,scrollEndTranslation,infinite,maxPage}=jsThis._closure;{const origin=translation.value;const velocity=scrollEndVelocity.value;if(!pagingEnabled){if(snapEnabled){const nextPage=Math.round((origin+velocity*0.4)/size)*size;translation.value=_withSpring(nextPage,onFinished);return;}translation.value=withDecay({velocity:velocity,deceleration:0.999});return;}const direction=-(scrollEndTranslation.value>=0?1:-1);const computed=direction<0?Math.ceil:Math.floor;const page=computed(-translation.value/size);let finalPage=page+direction;if(!infinite)finalPage=Math.min(maxPage-1,Math.max(0,finalPage));translation.value=_withSpring(-finalPage*size,onFinished);}}";_f.__workletHash=7195121800163;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (96:4)";return _f;}(),[translation,scrollEndVelocity.value,pagingEnabled,size,scrollEndTranslation.value,infinite,_withSpring,snapEnabled,maxPage]);var onFinish=_react.default.useCallback(function(){var _f=function _f(isFinished){if(isFinished){touching.value=false;onScrollEnd&&(0,_reactNativeReanimated.runOnJS)(onScrollEnd)();}};_f._closure={touching:touching,onScrollEnd:onScrollEnd,runOnJS:_reactNativeReanimated.runOnJS};_f.asString="function _f(isFinished){const{touching,onScrollEnd,runOnJS}=jsThis._closure;{if(isFinished){touching.value=false;onScrollEnd&&runOnJS(onScrollEnd)();}}}";_f.__workletHash=12308424749737;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (143:4)";return _f;}(),[onScrollEnd,touching]);var activeDecay=_react.default.useCallback(function(){var _f=function _f(){touching.value=true;translation.value=(0,_reactNativeReanimated.withDecay)({velocity:scrollEndVelocity.value},function(){var _f=function _f(isFinished){return onFinish(isFinished);};_f._closure={onFinish:onFinish};_f.asString="function _f(isFinished){const{onFinish}=jsThis._closure;{return onFinish(isFinished);}}";_f.__workletHash=12004837605207;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (158:6)";return _f;}());};_f._closure={touching:touching,translation:translation,withDecay:_reactNativeReanimated.withDecay,scrollEndVelocity:scrollEndVelocity,onFinish:onFinish};_f.asString="function _f(){const{touching,translation,withDecay,scrollEndVelocity,onFinish}=jsThis._closure;{touching.value=true;translation.value=withDecay({velocity:scrollEndVelocity.value},function(isFinished){return onFinish(isFinished);});}}";_f.__workletHash=1701548878343;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (153:40)";return _f;}(),[onFinish,scrollEndVelocity.value,touching,translation]);var resetBoundary=_react.default.useCallback(function(){var _f=function _f(){if(touching.value)return;if(translation.value>0){if(scrollEndTranslation.value<0){activeDecay();return;}if(!infinite){translation.value=_withSpring(0);return;}}if(translation.value<-((maxPage-1)*size)){if(scrollEndTranslation.value>0){activeDecay();return;}if(!infinite)translation.value=_withSpring(-((maxPage-1)*size));}};_f._closure={touching:touching,translation:translation,scrollEndTranslation:scrollEndTranslation,activeDecay:activeDecay,infinite:infinite,_withSpring:_withSpring,maxPage:maxPage,size:size};_f.asString="function _f(){const{touching,translation,scrollEndTranslation,activeDecay,infinite,_withSpring,maxPage,size}=jsThis._closure;{if(touching.value)return;if(translation.value>0){if(scrollEndTranslation.value<0){activeDecay();return;}if(!infinite){translation.value=_withSpring(0);return;}}if(translation.value<-((maxPage-1)*size)){if(scrollEndTranslation.value>0){activeDecay();return;}if(!infinite)translation.value=_withSpring(-((maxPage-1)*size));}}}";_f.__workletHash=17032900471906;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (162:42)";return _f;}(),[touching.value,translation,maxPage,size,scrollEndTranslation.value,infinite,activeDecay,_withSpring]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return translation.value;};_f._closure={translation:translation};_f.asString="function _f(){const{translation}=jsThis._closure;{return translation.value;}}";_f.__workletHash=9829368032147;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (198:4)";return _f;}(),function(){var _f=function _f(){if(!pagingEnabled)resetBoundary();};_f._closure={pagingEnabled:pagingEnabled,resetBoundary:resetBoundary};_f.asString="function _f(){const{pagingEnabled,resetBoundary}=jsThis._closure;{if(!pagingEnabled)resetBoundary();}}";_f.__workletHash=3586615076030;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (199:4)";return _f;}(),[pagingEnabled,resetBoundary]);var panGestureEventHandler=(0,_reactNativeReanimated.useAnimatedGestureHandler)({onStart:function(){var _f=function _f(_,ctx){touching.value=true;ctx.validStart=true;onScrollBegin&&(0,_reactNativeReanimated.runOnJS)(onScrollBegin)();ctx.max=(maxPage-1)*size;ctx.panOffset=translation.value;};_f._closure={touching:touching,onScrollBegin:onScrollBegin,runOnJS:_reactNativeReanimated.runOnJS,maxPage:maxPage,size:size,translation:translation};_f.asString="function _f(_,ctx){const{touching,onScrollBegin,runOnJS,maxPage,size,translation}=jsThis._closure;{touching.value=true;ctx.validStart=true;onScrollBegin&&runOnJS(onScrollBegin)();ctx.max=(maxPage-1)*size;ctx.panOffset=translation.value;}}";_f.__workletHash=1789833551681;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (211:15)";return _f;}(),onActive:function(){var _f=function _f(e,ctx){if(ctx.validStart){ctx.validStart=false;(0,_reactNativeReanimated.cancelAnimation)(translation);}touching.value=true;var translationX=e.translationX,translationY=e.translationY;var panTranslation=isHorizontal.value?translationX:translationY;if(!infinite&&(translation.value>0||translation.value<-ctx.max)){var boundary=translation.value>0?0:-ctx.max;var fixed=boundary-ctx.panOffset;var dynamic=panTranslation-fixed;translation.value=boundary+dynamic*0.5;return;}translation.value=ctx.panOffset+panTranslation;};_f._closure={cancelAnimation:_reactNativeReanimated.cancelAnimation,translation:translation,touching:touching,isHorizontal:isHorizontal,infinite:infinite};_f.asString="function _f(e,ctx){const{cancelAnimation,translation,touching,isHorizontal,infinite}=jsThis._closure;{if(ctx.validStart){ctx.validStart=false;cancelAnimation(translation);}touching.value=true;const{translationX:translationX,translationY:translationY}=e;const panTranslation=isHorizontal.value?translationX:translationY;if(!infinite&&(translation.value>0||translation.value<-ctx.max)){const boundary=translation.value>0?0:-ctx.max;const fixed=boundary-ctx.panOffset;const dynamic=panTranslation-fixed;translation.value=boundary+dynamic*0.5;return;}translation.value=ctx.panOffset+panTranslation;}}";_f.__workletHash=11738845597539;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (218:16)";return _f;}(),onEnd:function(){var _f=function _f(e){var velocityX=e.velocityX,velocityY=e.velocityY,translationX=e.translationX,translationY=e.translationY;scrollEndVelocity.value=isHorizontal.value?velocityX:velocityY;scrollEndTranslation.value=isHorizontal.value?translationX:translationY;endWithSpring(onScrollEnd);if(!infinite)touching.value=false;};_f._closure={scrollEndVelocity:scrollEndVelocity,isHorizontal:isHorizontal,scrollEndTranslation:scrollEndTranslation,endWithSpring:endWithSpring,onScrollEnd:onScrollEnd,infinite:infinite,touching:touching};_f.asString="function _f(e){const{scrollEndVelocity,isHorizontal,scrollEndTranslation,endWithSpring,onScrollEnd,infinite,touching}=jsThis._closure;{const{velocityX:velocityX,velocityY:velocityY,translationX:translationX,translationY:translationY}=e;scrollEndVelocity.value=isHorizontal.value?velocityX:velocityY;scrollEndTranslation.value=isHorizontal.value?translationX:translationY;endWithSpring(onScrollEnd);if(!infinite)touching.value=false;}}";_f.__workletHash=10638018947905;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/ScrollViewGesture.tsx (242:13)";return _f;}()},[pagingEnabled,isHorizontal.value,infinite,maxPage,size,snapEnabled,onScrollBegin,onScrollEnd]);return _react.default.createElement(_reactNativeGestureHandler.PanGestureHandler,(0,_extends2.default)({},panGestureHandlerProps,{enabled:enabled,onGestureEvent:panGestureEventHandler,__self:_this,__source:{fileName:_jsxFileName,lineNumber:270,columnNumber:5}}),_react.default.createElement(_reactNativeReanimated.default.View,{testID:testID,style:style,onTouchStart:onTouchBegin,onTouchEnd:onTouchEnd,__self:_this,__source:{fileName:_jsxFileName,lineNumber:275,columnNumber:7}},props.children));};var ScrollViewGesture=IScrollViewGesture;exports.ScrollViewGesture=ScrollViewGesture;
2
2
  //# sourceMappingURL=ScrollViewGesture.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["ScrollViewGesture.tsx"],"names":["IScrollViewGesture","props","React","useContext","CTX","vertical","data","pagingEnabled","snapEnabled","panGestureHandlerProps","infinite","loop","scrollAnimationDuration","withAnimation","enabled","size","translation","testID","style","onScrollBegin","onScrollEnd","onTouchBegin","onTouchEnd","maxPage","length","isHorizontal","touching","scrollEndTranslation","scrollEndVelocity","_withSpring","useCallback","toValue","onFinished","defaultWithAnimation","type","config","duration","easing","Easing","easeOutQuart","isFinished","runOnJS","dealWithAnimation","endWithSpring","origin","value","velocity","nextPage","Math","round","deceleration","direction","computed","ceil","floor","page","finalPage","min","max","withDecay","onFinish","activeDecay","resetBoundary","panGestureEventHandler","onStart","_","ctx","validStart","panOffset","onActive","e","translationX","translationY","panTranslation","boundary","fixed","dynamic","cancelAnimation","onEnd","velocityX","velocityY","children","ScrollViewGesture"],"mappings":"6PAAA,oDAGA,uEAGA,uFAUA,sCACA,8BAEA,4D,knCAoBA,GAAMA,CAAAA,kBAAmC,CAAG,QAAtCA,CAAAA,kBAAsC,CAACC,KAAD,CAAW,CACrD,sBAYIC,eAAMC,UAAN,CAAiBC,UAAjB,CAZJ,yCACEH,KADF,CAEII,QAFJ,uBAEIA,QAFJ,CAGIC,IAHJ,uBAGIA,IAHJ,CAIIC,aAJJ,uBAIIA,aAJJ,CAKIC,WALJ,uBAKIA,WALJ,CAMIC,sBANJ,uBAMIA,sBANJ,CAOUC,QAPV,uBAOIC,IAPJ,CAQIC,uBARJ,uBAQIA,uBARJ,CASIC,aATJ,uBASIA,aATJ,CAUIC,OAVJ,uBAUIA,OAVJ,CAcA,GACEC,CAAAA,IADF,CASId,KATJ,CACEc,IADF,CAEEC,WAFF,CASIf,KATJ,CAEEe,WAFF,CAGEC,MAHF,CASIhB,KATJ,CAGEgB,MAHF,cASIh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\";\nimport type { PanGestureHandlerGestureEvent } from \"react-native-gesture-handler\";\nimport {\n PanGestureHandler,\n} from \"react-native-gesture-handler\";\nimport Animated, {\n cancelAnimation,\n runOnJS,\n useAnimatedGestureHandler,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n withDecay,\n} from \"react-native-reanimated\";\n\nimport { Easing } from \"./constants\";\nimport { CTX } from \"./store\";\nimport type { WithTimingAnimation } from \"./types\";\nimport { dealWithAnimation } from \"./utils/dealWithAnimation\";\n\ninterface GestureContext extends Record<string, unknown> {\n validStart: boolean\n panOffset: number\n max: number\n}\n\ninterface Props {\n size: number\n infinite?: boolean\n testID?: string\n style?: StyleProp<ViewStyle>\n onScrollBegin?: () => void\n onScrollEnd?: () => void\n onTouchBegin?: () => void\n onTouchEnd?: () => void\n translation: Animated.SharedValue<number>\n}\n\nconst IScrollViewGesture: React.FC<Props> = (props) => {\n const {\n props: {\n vertical,\n data,\n pagingEnabled,\n snapEnabled,\n panGestureHandlerProps,\n loop: infinite,\n scrollAnimationDuration,\n withAnimation,\n enabled,\n },\n } = React.useContext(CTX);\n\n const {\n size,\n translation,\n testID,\n style = {},\n onScrollBegin,\n onScrollEnd,\n onTouchBegin,\n onTouchEnd,\n } = props;\n\n const maxPage = data.length;\n const isHorizontal = useDerivedValue(() => !vertical, [vertical]);\n const touching = useSharedValue(false);\n const scrollEndTranslation = useSharedValue(0);\n const scrollEndVelocity = useSharedValue(0);\n\n const _withSpring = React.useCallback(\n (toValue: number, onFinished?: () => void) => {\n \"worklet\";\n const defaultWithAnimation: WithTimingAnimation = {\n type: \"timing\",\n config: {\n duration: scrollAnimationDuration + 100,\n easing: Easing.easeOutQuart,\n },\n };\n\n return dealWithAnimation(withAnimation ?? defaultWithAnimation)(\n toValue,\n (isFinished: boolean) => {\n \"worklet\";\n if (isFinished)\n onFinished && runOnJS(onFinished)();\n },\n );\n },\n [scrollAnimationDuration, withAnimation],\n );\n\n const endWithSpring = React.useCallback(\n (onFinished?: () => void) => {\n \"worklet\";\n const origin = translation.value;\n const velocity = scrollEndVelocity.value;\n if (!pagingEnabled) {\n /**\n * If enabled, releasing the touch will scroll to the nearest item.\n * valid when pagingEnabled=false\n */\n if (snapEnabled) {\n const nextPage\n = Math.round((origin + velocity * 0.4) / size) * size;\n\n translation.value = _withSpring(nextPage, onFinished);\n return;\n }\n translation.value = withDecay({\n velocity,\n deceleration: 0.999,\n });\n return;\n }\n\n const direction = -(scrollEndTranslation.value >= 0 ? 1 : -1);\n const computed = direction < 0 ? Math.ceil : Math.floor;\n const page = computed(-translation.value / size);\n let finalPage = page + direction;\n\n if (!infinite)\n finalPage = Math.min(maxPage - 1, Math.max(0, finalPage));\n\n translation.value = _withSpring(-finalPage * size, onFinished);\n },\n [\n translation,\n scrollEndVelocity.value,\n pagingEnabled,\n size,\n scrollEndTranslation.value,\n infinite,\n _withSpring,\n snapEnabled,\n maxPage,\n ],\n );\n\n const onFinish = React.useCallback(\n (isFinished: boolean) => {\n \"worklet\";\n if (isFinished) {\n touching.value = false;\n onScrollEnd && runOnJS(onScrollEnd)();\n }\n },\n [onScrollEnd, touching],\n );\n\n const activeDecay = React.useCallback(() => {\n \"worklet\";\n touching.value = true;\n translation.value = withDecay(\n { velocity: scrollEndVelocity.value },\n isFinished => onFinish(isFinished as boolean),\n );\n }, [onFinish, scrollEndVelocity.value, touching, translation]);\n\n const resetBoundary = React.useCallback(() => {\n \"worklet\";\n if (touching.value)\n return;\n\n if (translation.value > 0) {\n if (scrollEndTranslation.value < 0) {\n activeDecay();\n return;\n }\n if (!infinite) {\n translation.value = _withSpring(0);\n return;\n }\n }\n\n if (translation.value < -((maxPage - 1) * size)) {\n if (scrollEndTranslation.value > 0) {\n activeDecay();\n return;\n }\n if (!infinite)\n translation.value = _withSpring(-((maxPage - 1) * size));\n }\n }, [\n touching.value,\n translation,\n maxPage,\n size,\n scrollEndTranslation.value,\n infinite,\n activeDecay,\n _withSpring,\n ]);\n\n useAnimatedReaction(\n () => translation.value,\n () => {\n if (!pagingEnabled)\n resetBoundary();\n },\n [pagingEnabled, resetBoundary],\n );\n\n const panGestureEventHandler = useAnimatedGestureHandler<\n PanGestureHandlerGestureEvent,\n GestureContext\n >(\n {\n onStart: (_, ctx) => {\n touching.value = true;\n ctx.validStart = true;\n onScrollBegin && runOnJS(onScrollBegin)();\n ctx.max = (maxPage - 1) * size;\n ctx.panOffset = translation.value;\n },\n onActive: (e, ctx) => {\n if (ctx.validStart) {\n ctx.validStart = false;\n cancelAnimation(translation);\n }\n touching.value = true;\n const { translationX, translationY } = e;\n const panTranslation = isHorizontal.value\n ? translationX\n : translationY;\n\n if (\n !infinite\n && (translation.value > 0 || translation.value < -ctx.max)\n ) {\n const boundary = translation.value > 0 ? 0 : -ctx.max;\n const fixed = boundary - ctx.panOffset;\n const dynamic = panTranslation - fixed;\n translation.value = boundary + dynamic * 0.5;\n return;\n }\n\n translation.value = ctx.panOffset + panTranslation;\n },\n onEnd: (e) => {\n const { velocityX, velocityY, translationX, translationY } = e;\n scrollEndVelocity.value = isHorizontal.value\n ? velocityX\n : velocityY;\n scrollEndTranslation.value = isHorizontal.value\n ? translationX\n : translationY;\n\n endWithSpring(onScrollEnd);\n\n if (!infinite)\n touching.value = false;\n },\n },\n [\n pagingEnabled,\n isHorizontal.value,\n infinite,\n maxPage,\n size,\n snapEnabled,\n onScrollBegin,\n onScrollEnd,\n ],\n );\n\n return (\n <PanGestureHandler\n {...panGestureHandlerProps}\n enabled={enabled}\n onGestureEvent={panGestureEventHandler}\n >\n <Animated.View\n testID={testID}\n style={style}\n onTouchStart={onTouchBegin}\n onTouchEnd={onTouchEnd}\n >\n {props.children}\n </Animated.View>\n </PanGestureHandler>\n );\n};\n\nexport const ScrollViewGesture = IScrollViewGesture;\n"]}
1
+ {"version":3,"sources":["ScrollViewGesture.tsx"],"names":["IScrollViewGesture","props","React","useContext","CTX","vertical","pagingEnabled","snapEnabled","panGestureHandlerProps","infinite","loop","scrollAnimationDuration","withAnimation","enabled","dataLength","size","translation","testID","style","onScrollBegin","onScrollEnd","onTouchBegin","onTouchEnd","maxPage","isHorizontal","touching","scrollEndTranslation","scrollEndVelocity","_withSpring","useCallback","toValue","onFinished","defaultWithAnimation","type","config","duration","easing","Easing","easeOutQuart","isFinished","runOnJS","dealWithAnimation","endWithSpring","origin","value","velocity","nextPage","Math","round","deceleration","direction","computed","ceil","floor","page","finalPage","min","max","withDecay","onFinish","activeDecay","resetBoundary","panGestureEventHandler","onStart","_","ctx","validStart","panOffset","onActive","e","translationX","translationY","panTranslation","boundary","fixed","dynamic","cancelAnimation","onEnd","velocityX","velocityY","children","ScrollViewGesture"],"mappings":"6PAAA,oDAGA,uEAGA,uFAUA,sCACA,8BAEA,4D,knCAoBA,GAAMA,CAAAA,kBAAmC,CAAG,QAAtCA,CAAAA,kBAAsC,CAACC,KAAD,CAAW,CACrD,sBAYIC,eAAMC,UAAN,CAAiBC,UAAjB,CAZJ,yCACEH,KADF,CAEII,QAFJ,uBAEIA,QAFJ,CAGIC,aAHJ,uBAGIA,aAHJ,CAIIC,WAJJ,uBAIIA,WAJJ,CAKIC,sBALJ,uBAKIA,sBALJ,CAMUC,QANV,uBAMIC,IANJ,CAOIC,uBAPJ,uBAOIA,uBAPJ,CAQIC,aARJ,uBAQIA,aARJ,CASIC,OATJ,uBASIA,OATJ,CAUIC,UAVJ,uBAUIA,UAVJ,CAcA,GACEC,CAAAA,IADF,CASId,KATJ,CACEc,IADF,CAEEC,WAFF,CASIf,KATJ,CAEEe,WAFF,CAGEC,MAHF,CASIhB,KATJ,CAGEgB,MAHF,cASIhB,KATJ,CAIEiB,KAJF,CAIEA,KAJF,uBAIU,EAJV,cAKEC,aALF,CASIlB,KATJ,CAKEkB,aALF,CAMEC,WANF,CASInB,KATJ,CAMEmB,WANF,CAOEC,YAPF,CASIpB,KATJ,CAOEoB,YAPF,CAQEC,UARF,CASIrB,KATJ,CAQEqB,UARF,CAWA,GAAMC,CAAAA,OAAO,CAAGT,UAAhB,CACA,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A6DF,CAA7D,CAA4CE,YAA5C,CACA5C,iBAAiB,CAACiB,KAAlB,CAA0BpB,YAAY,CAACoB,KAAb,CACtBkC,SADsB,CAEtBC,SAFJ,CAGArD,oBAAoB,CAACkB,KAArB,CAA6BpB,YAAY,CAACoB,KAAb,CACzB0B,YADyB,CAEzBC,YAFJ,CAIA7B,aAAa,CAACtB,WAAD,CAAb,CAEA,GAAI,CAACX,QAAL,CACEgB,QAAQ,CAACmB,KAAT,CAAiB,KAAjB,CACH,CAbI,gCAzOTjB,iBAyOS,cAxOoBH,YAwOpB,sBAxOTE,oBAwOS,eAvOTgB,aAuOS,aAvOKtB,WAuOL,UAtOJX,QAsOI,UAtOMgB,QAsON,mmBAhCP,CAJ6B,CAmD7B,CACEnB,aADF,CAEEkB,YAAY,CAACoB,KAFf,CAGEnC,QAHF,CAIEc,OAJF,CAKER,IALF,CAMER,WANF,CAOEY,aAPF,CAQEC,WARF,CAnD6B,CAA/B,CA+DA,MACE,8BAAC,4CAAD,0BACMZ,sBADN,EAEE,OAAO,CAAEK,OAFX,CAGE,cAAc,CAAEiD,sBAHlB,+EAKE,6BAAC,8BAAD,CAAU,IAAV,EACE,MAAM,CAAE7C,MADV,CAEE,KAAK,CAAEC,KAFT,CAGE,YAAY,CAAEG,YAHhB,CAIE,UAAU,CAAEC,UAJd,8EAMGrB,KAAK,CAAC+E,QANT,CALF,CADF,CAgBD,CArPD,CAuPO,GAAMC,CAAAA,iBAAiB,CAAGjF,kBAA1B,C","sourcesContent":["import React from \"react\";\nimport type { StyleProp, ViewStyle } from \"react-native\";\nimport type { PanGestureHandlerGestureEvent } from \"react-native-gesture-handler\";\nimport {\n PanGestureHandler,\n} from \"react-native-gesture-handler\";\nimport Animated, {\n cancelAnimation,\n runOnJS,\n useAnimatedGestureHandler,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n withDecay,\n} from \"react-native-reanimated\";\n\nimport { Easing } from \"./constants\";\nimport { CTX } from \"./store\";\nimport type { WithTimingAnimation } from \"./types\";\nimport { dealWithAnimation } from \"./utils/dealWithAnimation\";\n\ninterface GestureContext extends Record<string, unknown> {\n validStart: boolean\n panOffset: number\n max: number\n}\n\ninterface Props {\n size: number\n infinite?: boolean\n testID?: string\n style?: StyleProp<ViewStyle>\n onScrollBegin?: () => void\n onScrollEnd?: () => void\n onTouchBegin?: () => void\n onTouchEnd?: () => void\n translation: Animated.SharedValue<number>\n}\n\nconst IScrollViewGesture: React.FC<Props> = (props) => {\n const {\n props: {\n vertical,\n pagingEnabled,\n snapEnabled,\n panGestureHandlerProps,\n loop: infinite,\n scrollAnimationDuration,\n withAnimation,\n enabled,\n dataLength,\n },\n } = React.useContext(CTX);\n\n const {\n size,\n translation,\n testID,\n style = {},\n onScrollBegin,\n onScrollEnd,\n onTouchBegin,\n onTouchEnd,\n } = props;\n\n const maxPage = dataLength;\n const isHorizontal = useDerivedValue(() => !vertical, [vertical]);\n const touching = useSharedValue(false);\n const scrollEndTranslation = useSharedValue(0);\n const scrollEndVelocity = useSharedValue(0);\n\n const _withSpring = React.useCallback(\n (toValue: number, onFinished?: () => void) => {\n \"worklet\";\n const defaultWithAnimation: WithTimingAnimation = {\n type: \"timing\",\n config: {\n duration: scrollAnimationDuration + 100,\n easing: Easing.easeOutQuart,\n },\n };\n\n return dealWithAnimation(withAnimation ?? defaultWithAnimation)(\n toValue,\n (isFinished: boolean) => {\n \"worklet\";\n if (isFinished)\n onFinished && runOnJS(onFinished)();\n },\n );\n },\n [scrollAnimationDuration, withAnimation],\n );\n\n const endWithSpring = React.useCallback(\n (onFinished?: () => void) => {\n \"worklet\";\n const origin = translation.value;\n const velocity = scrollEndVelocity.value;\n if (!pagingEnabled) {\n /**\n * If enabled, releasing the touch will scroll to the nearest item.\n * valid when pagingEnabled=false\n */\n if (snapEnabled) {\n const nextPage\n = Math.round((origin + velocity * 0.4) / size) * size;\n\n translation.value = _withSpring(nextPage, onFinished);\n return;\n }\n translation.value = withDecay({\n velocity,\n deceleration: 0.999,\n });\n return;\n }\n\n const direction = -(scrollEndTranslation.value >= 0 ? 1 : -1);\n const computed = direction < 0 ? Math.ceil : Math.floor;\n const page = computed(-translation.value / size);\n let finalPage = page + direction;\n\n if (!infinite)\n finalPage = Math.min(maxPage - 1, Math.max(0, finalPage));\n\n translation.value = _withSpring(-finalPage * size, onFinished);\n },\n [\n translation,\n scrollEndVelocity.value,\n pagingEnabled,\n size,\n scrollEndTranslation.value,\n infinite,\n _withSpring,\n snapEnabled,\n maxPage,\n ],\n );\n\n const onFinish = React.useCallback(\n (isFinished: boolean) => {\n \"worklet\";\n if (isFinished) {\n touching.value = false;\n onScrollEnd && runOnJS(onScrollEnd)();\n }\n },\n [onScrollEnd, touching],\n );\n\n const activeDecay = React.useCallback(() => {\n \"worklet\";\n touching.value = true;\n translation.value = withDecay(\n { velocity: scrollEndVelocity.value },\n isFinished => onFinish(isFinished as boolean),\n );\n }, [onFinish, scrollEndVelocity.value, touching, translation]);\n\n const resetBoundary = React.useCallback(() => {\n \"worklet\";\n if (touching.value)\n return;\n\n if (translation.value > 0) {\n if (scrollEndTranslation.value < 0) {\n activeDecay();\n return;\n }\n if (!infinite) {\n translation.value = _withSpring(0);\n return;\n }\n }\n\n if (translation.value < -((maxPage - 1) * size)) {\n if (scrollEndTranslation.value > 0) {\n activeDecay();\n return;\n }\n if (!infinite)\n translation.value = _withSpring(-((maxPage - 1) * size));\n }\n }, [\n touching.value,\n translation,\n maxPage,\n size,\n scrollEndTranslation.value,\n infinite,\n activeDecay,\n _withSpring,\n ]);\n\n useAnimatedReaction(\n () => translation.value,\n () => {\n if (!pagingEnabled)\n resetBoundary();\n },\n [pagingEnabled, resetBoundary],\n );\n\n const panGestureEventHandler = useAnimatedGestureHandler<\n PanGestureHandlerGestureEvent,\n GestureContext\n >(\n {\n onStart: (_, ctx) => {\n touching.value = true;\n ctx.validStart = true;\n onScrollBegin && runOnJS(onScrollBegin)();\n ctx.max = (maxPage - 1) * size;\n ctx.panOffset = translation.value;\n },\n onActive: (e, ctx) => {\n if (ctx.validStart) {\n ctx.validStart = false;\n cancelAnimation(translation);\n }\n touching.value = true;\n const { translationX, translationY } = e;\n const panTranslation = isHorizontal.value\n ? translationX\n : translationY;\n\n if (\n !infinite\n && (translation.value > 0 || translation.value < -ctx.max)\n ) {\n const boundary = translation.value > 0 ? 0 : -ctx.max;\n const fixed = boundary - ctx.panOffset;\n const dynamic = panTranslation - fixed;\n translation.value = boundary + dynamic * 0.5;\n return;\n }\n\n translation.value = ctx.panOffset + panTranslation;\n },\n onEnd: (e) => {\n const { velocityX, velocityY, translationX, translationY } = e;\n scrollEndVelocity.value = isHorizontal.value\n ? velocityX\n : velocityY;\n scrollEndTranslation.value = isHorizontal.value\n ? translationX\n : translationY;\n\n endWithSpring(onScrollEnd);\n\n if (!infinite)\n touching.value = false;\n },\n },\n [\n pagingEnabled,\n isHorizontal.value,\n infinite,\n maxPage,\n size,\n snapEnabled,\n onScrollBegin,\n onScrollEnd,\n ],\n );\n\n return (\n <PanGestureHandler\n {...panGestureHandlerProps}\n enabled={enabled}\n onGestureEvent={panGestureEventHandler}\n >\n <Animated.View\n testID={testID}\n style={style}\n onTouchStart={onTouchBegin}\n onTouchEnd={onTouchEnd}\n >\n {props.children}\n </Animated.View>\n </PanGestureHandler>\n );\n};\n\nexport const ScrollViewGesture = IScrollViewGesture;\n"]}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});exports.useCarouselController=useCarouselController;var _react=_interopRequireWildcard(require("react"));var _reactNativeReanimated=require("react-native-reanimated");var _constants=require("../constants");var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");var _dealWithAnimation=require("../utils/dealWithAnimation");var _handlerOffsetDirection=require("../utils/handlerOffsetDirection");var _log=require("../utils/log");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 useCarouselController(options){var size=options.size,data=options.data,loop=options.loop,handlerOffset=options.handlerOffset,withAnimation=options.withAnimation,_options$defaultIndex=options.defaultIndex,defaultIndex=_options$defaultIndex===void 0?0:_options$defaultIndex,duration=options.duration,autoFillData=options.autoFillData;var dataInfo=_react.default.useMemo(function(){return{length:data.length,disable:!data.length,originalLength:data.length};},[data]);var index=(0,_reactNativeReanimated.useSharedValue)(defaultIndex);var sharedIndex=(0,_react.useRef)(defaultIndex);var sharedPreIndex=(0,_react.useRef)(defaultIndex);var currentFixedPage=_react.default.useCallback(function(){if(loop)return-Math.round(handlerOffset.value/size);var fixed=handlerOffset.value/size%dataInfo.length;return Math.round(handlerOffset.value<=0?Math.abs(fixed):Math.abs(fixed>0?dataInfo.length-fixed:0));},[handlerOffset,dataInfo,size,loop]);function setSharedIndex(newSharedIndex){sharedIndex.current=newSharedIndex;}(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){var handlerOffsetValue=handlerOffset.value;var toInt=(0,_log.round)(handlerOffsetValue/size)%dataInfo.length;var isPositive=handlerOffsetValue<=0;var i=isPositive?Math.abs(toInt):Math.abs(toInt>0?dataInfo.length-toInt:0);var newSharedIndexValue=(0,_computedWithAutoFillData.convertToSharedIndex)({loop:loop,rawDataLength:dataInfo.originalLength,autoFillData:autoFillData,index:i});return{i:i,newSharedIndexValue:newSharedIndexValue};};_f._closure={handlerOffset:handlerOffset,round:_log.round,size:size,dataInfo:dataInfo,convertToSharedIndex:_computedWithAutoFillData.convertToSharedIndex,loop:loop,autoFillData:autoFillData};_f.asString="function _f(){const{handlerOffset,round,size,dataInfo,convertToSharedIndex,loop,autoFillData}=jsThis._closure;{const handlerOffsetValue=handlerOffset.value;const toInt=round(handlerOffsetValue/size)%dataInfo.length;const isPositive=handlerOffsetValue<=0;const i=isPositive?Math.abs(toInt):Math.abs(toInt>0?dataInfo.length-toInt:0);const newSharedIndexValue=convertToSharedIndex({loop:loop,rawDataLength:dataInfo.originalLength,autoFillData:autoFillData,index:i});return{i:i,newSharedIndexValue:newSharedIndexValue};}}";_f.__workletHash=442719064151;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx (84:4)";return _f;}(),function(){var _f=function _f(_ref){var i=_ref.i,newSharedIndexValue=_ref.newSharedIndexValue;index.value=i;(0,_reactNativeReanimated.runOnJS)(setSharedIndex)(newSharedIndexValue);};_f._closure={index:index,runOnJS:_reactNativeReanimated.runOnJS,setSharedIndex:setSharedIndex};_f.asString="function _f({i:i,newSharedIndexValue:newSharedIndexValue}){const{index,runOnJS,setSharedIndex}=jsThis._closure;{index.value=i;runOnJS(setSharedIndex)(newSharedIndexValue);}}";_f.__workletHash=16638491076412;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx (104:4)";return _f;}(),[sharedPreIndex,sharedIndex,size,dataInfo,index,loop,autoFillData,handlerOffset]);var getCurrentIndex=_react.default.useCallback(function(){return index.value;},[index]);var canSliding=_react.default.useCallback(function(){return!dataInfo.disable;},[dataInfo]);var onScrollEnd=_react.default.useCallback(function(){options.onScrollEnd==null?void 0:options.onScrollEnd();},[options]);var onScrollBegin=_react.default.useCallback(function(){options.onScrollBegin==null?void 0:options.onScrollBegin();},[options]);var scrollWithTiming=_react.default.useCallback(function(){var _f=function _f(toValue,onFinished){var callback=function(){var _f=function _f(isFinished){if(isFinished){(0,_reactNativeReanimated.runOnJS)(onScrollEnd)();onFinished&&(0,_reactNativeReanimated.runOnJS)(onFinished)();}};_f._closure={runOnJS:_reactNativeReanimated.runOnJS,onScrollEnd:onScrollEnd,onFinished:onFinished};_f.asString="function _f(isFinished){const{runOnJS,onScrollEnd,onFinished}=jsThis._closure;{if(isFinished){runOnJS(onScrollEnd)();onFinished&&runOnJS(onFinished)();}}}";_f.__workletHash=7767198641261;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx (139:23)";return _f;}();var defaultWithAnimation={type:"timing",config:{duration:duration,easing:_constants.Easing.easeOutQuart}};return(0,_dealWithAnimation.dealWithAnimation)(withAnimation!=null?withAnimation:defaultWithAnimation)(toValue,callback);};_f._closure={runOnJS:_reactNativeReanimated.runOnJS,onScrollEnd:onScrollEnd,duration:duration,Easing:{easeOutQuart:_constants.Easing.easeOutQuart},dealWithAnimation:_dealWithAnimation.dealWithAnimation,withAnimation:withAnimation};_f.asString="function _f(toValue,onFinished){const{runOnJS,onScrollEnd,duration,Easing,dealWithAnimation,withAnimation}=jsThis._closure;{var _withAnimation;const callback=function(isFinished){\"worklet\";if(isFinished){runOnJS(onScrollEnd)();onFinished&&runOnJS(onFinished)();}};const defaultWithAnimation={type:\"timing\",config:{duration:duration,easing:Easing.easeOutQuart}};return dealWithAnimation((_withAnimation=withAnimation)!==null&&_withAnimation!==void 0?_withAnimation:defaultWithAnimation)(toValue,callback);}}";_f.__workletHash=12575476119920;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx (137:4)";return _f;}(),[duration,withAnimation,onScrollEnd]);var next=_react.default.useCallback(function(){var _f=function _f(){var opts=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var _opts$count=opts.count,count=_opts$count===void 0?1:_opts$count,_opts$animated=opts.animated,animated=_opts$animated===void 0?true:_opts$animated,onFinished=opts.onFinished;if(!canSliding()||!loop&&index.value>=dataInfo.length-1)return;onScrollBegin==null?void 0:onScrollBegin();var nextPage=currentFixedPage()+count;index.value=nextPage;if(animated){handlerOffset.value=scrollWithTiming(-nextPage*size,onFinished);}else{handlerOffset.value=-nextPage*size;onFinished==null?void 0:onFinished();}};_f._closure={canSliding:canSliding,loop:loop,index:index,dataInfo:dataInfo,onScrollBegin:onScrollBegin,currentFixedPage:currentFixedPage,handlerOffset:handlerOffset,scrollWithTiming:scrollWithTiming,size:size};_f.asString="function _f(opts={}){const{canSliding,loop,index,dataInfo,onScrollBegin,currentFixedPage,handlerOffset,scrollWithTiming,size}=jsThis._closure;{var _onScrollBegin;const{count=1,animated=true,onFinished:onFinished}=opts;if(!canSliding()||!loop&&index.value>=dataInfo.length-1)return;(_onScrollBegin=onScrollBegin)===null||_onScrollBegin===void 0?void 0:_onScrollBegin();const nextPage=currentFixedPage()+count;index.value=nextPage;if(animated){handlerOffset.value=scrollWithTiming(-nextPage*size,onFinished);}else{handlerOffset.value=-nextPage*size;onFinished===null||onFinished===void 0?void 0:onFinished();}}}";_f.__workletHash=10530429864168;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx (161:4)";return _f;}(),[canSliding,loop,index,dataInfo,onScrollBegin,handlerOffset,size,scrollWithTiming,currentFixedPage]);var prev=_react.default.useCallback(function(){var opts=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var _opts$count2=opts.count,count=_opts$count2===void 0?1:_opts$count2,_opts$animated2=opts.animated,animated=_opts$animated2===void 0?true:_opts$animated2,onFinished=opts.onFinished;if(!canSliding()||!loop&&index.value<=0)return;onScrollBegin==null?void 0:onScrollBegin();var prevPage=currentFixedPage()-count;index.value=prevPage;if(animated){handlerOffset.value=scrollWithTiming(-prevPage*size,onFinished);}else{handlerOffset.value=-prevPage*size;onFinished==null?void 0:onFinished();}},[canSliding,loop,index,onScrollBegin,handlerOffset,size,scrollWithTiming,currentFixedPage]);var to=_react.default.useCallback(function(opts){var i=opts.i,_opts$animated3=opts.animated,animated=_opts$animated3===void 0?false:_opts$animated3,onFinished=opts.onFinished;if(i===index.value)return;if(!canSliding())return;onScrollBegin==null?void 0:onScrollBegin();var direction=(0,_handlerOffsetDirection.handlerOffsetDirection)(handlerOffset);var offset=i*size*direction;var totalSize=dataInfo.length*size;var isCloseToNextLoop=false;if(loop){isCloseToNextLoop=Math.abs(handlerOffset.value%totalSize)/totalSize>=0.5;}var finalOffset=(Math.floor(Math.abs(handlerOffset.value/totalSize))+(isCloseToNextLoop?1:0))*totalSize*direction+offset;if(animated){index.value=i;handlerOffset.value=scrollWithTiming(finalOffset,onFinished);}else{handlerOffset.value=finalOffset;index.value=i;onFinished==null?void 0:onFinished();}},[index,canSliding,onScrollBegin,handlerOffset,size,dataInfo.length,loop,scrollWithTiming]);var scrollTo=_react.default.useCallback(function(){var opts=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var i=opts.index,count=opts.count,_opts$animated4=opts.animated,animated=_opts$animated4===void 0?false:_opts$animated4,onFinished=opts.onFinished;if(typeof i==="number"&&i>-1){to({i:i,animated:animated,onFinished:onFinished});return;}if(!count)return;var n=Math.round(count);if(n<0)prev({count:Math.abs(n),animated:animated,onFinished:onFinished});else next({count:n,animated:animated,onFinished:onFinished});},[prev,next,to]);return{next:next,prev:prev,scrollTo:scrollTo,getCurrentIndex:getCurrentIndex,getSharedIndex:function getSharedIndex(){return sharedIndex.current;}};}
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.useCarouselController=useCarouselController;var _react=_interopRequireWildcard(require("react"));var _reactNativeReanimated=require("react-native-reanimated");var _constants=require("../constants");var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");var _dealWithAnimation=require("../utils/dealWithAnimation");var _handlerOffsetDirection=require("../utils/handlerOffsetDirection");var _log=require("../utils/log");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 useCarouselController(options){var size=options.size,loop=options.loop,dataLength=options.dataLength,handlerOffset=options.handlerOffset,withAnimation=options.withAnimation,_options$defaultIndex=options.defaultIndex,defaultIndex=_options$defaultIndex===void 0?0:_options$defaultIndex,duration=options.duration,autoFillData=options.autoFillData;var dataInfo=_react.default.useMemo(function(){return{length:dataLength,disable:!dataLength,originalLength:dataLength};},[dataLength]);var index=(0,_reactNativeReanimated.useSharedValue)(defaultIndex);var sharedIndex=(0,_react.useRef)(defaultIndex);var sharedPreIndex=(0,_react.useRef)(defaultIndex);var currentFixedPage=_react.default.useCallback(function(){if(loop)return-Math.round(handlerOffset.value/size);var fixed=handlerOffset.value/size%dataInfo.length;return Math.round(handlerOffset.value<=0?Math.abs(fixed):Math.abs(fixed>0?dataInfo.length-fixed:0));},[handlerOffset,dataInfo,size,loop]);function setSharedIndex(newSharedIndex){sharedIndex.current=newSharedIndex;}(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){var handlerOffsetValue=handlerOffset.value;var toInt=(0,_log.round)(handlerOffsetValue/size)%dataInfo.length;var isPositive=handlerOffsetValue<=0;var i=isPositive?Math.abs(toInt):Math.abs(toInt>0?dataInfo.length-toInt:0);var newSharedIndexValue=(0,_computedWithAutoFillData.convertToSharedIndex)({loop:loop,rawDataLength:dataInfo.originalLength,autoFillData:autoFillData,index:i});return{i:i,newSharedIndexValue:newSharedIndexValue};};_f._closure={handlerOffset:handlerOffset,round:_log.round,size:size,dataInfo:dataInfo,convertToSharedIndex:_computedWithAutoFillData.convertToSharedIndex,loop:loop,autoFillData:autoFillData};_f.asString="function _f(){const{handlerOffset,round,size,dataInfo,convertToSharedIndex,loop,autoFillData}=jsThis._closure;{const handlerOffsetValue=handlerOffset.value;const toInt=round(handlerOffsetValue/size)%dataInfo.length;const isPositive=handlerOffsetValue<=0;const i=isPositive?Math.abs(toInt):Math.abs(toInt>0?dataInfo.length-toInt:0);const newSharedIndexValue=convertToSharedIndex({loop:loop,rawDataLength:dataInfo.originalLength,autoFillData:autoFillData,index:i});return{i:i,newSharedIndexValue:newSharedIndexValue};}}";_f.__workletHash=442719064151;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx (84:4)";return _f;}(),function(){var _f=function _f(_ref){var i=_ref.i,newSharedIndexValue=_ref.newSharedIndexValue;index.value=i;(0,_reactNativeReanimated.runOnJS)(setSharedIndex)(newSharedIndexValue);};_f._closure={index:index,runOnJS:_reactNativeReanimated.runOnJS,setSharedIndex:setSharedIndex};_f.asString="function _f({i:i,newSharedIndexValue:newSharedIndexValue}){const{index,runOnJS,setSharedIndex}=jsThis._closure;{index.value=i;runOnJS(setSharedIndex)(newSharedIndexValue);}}";_f.__workletHash=16638491076412;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx (104:4)";return _f;}(),[sharedPreIndex,sharedIndex,size,dataInfo,index,loop,autoFillData,handlerOffset]);var getCurrentIndex=_react.default.useCallback(function(){var realIndex=(0,_computedWithAutoFillData.computedRealIndexWithAutoFillData)({index:index.value,dataLength:dataInfo.originalLength,loop:loop,autoFillData:autoFillData});return realIndex;},[index,autoFillData,dataInfo,loop]);var canSliding=_react.default.useCallback(function(){return!dataInfo.disable;},[dataInfo]);var onScrollEnd=_react.default.useCallback(function(){options.onScrollEnd==null?void 0:options.onScrollEnd();},[options]);var onScrollBegin=_react.default.useCallback(function(){options.onScrollBegin==null?void 0:options.onScrollBegin();},[options]);var scrollWithTiming=_react.default.useCallback(function(){var _f=function _f(toValue,onFinished){var callback=function(){var _f=function _f(isFinished){if(isFinished){(0,_reactNativeReanimated.runOnJS)(onScrollEnd)();onFinished&&(0,_reactNativeReanimated.runOnJS)(onFinished)();}};_f._closure={runOnJS:_reactNativeReanimated.runOnJS,onScrollEnd:onScrollEnd,onFinished:onFinished};_f.asString="function _f(isFinished){const{runOnJS,onScrollEnd,onFinished}=jsThis._closure;{if(isFinished){runOnJS(onScrollEnd)();onFinished&&runOnJS(onFinished)();}}}";_f.__workletHash=7767198641261;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx (146:23)";return _f;}();var defaultWithAnimation={type:"timing",config:{duration:duration,easing:_constants.Easing.easeOutQuart}};return(0,_dealWithAnimation.dealWithAnimation)(withAnimation!=null?withAnimation:defaultWithAnimation)(toValue,callback);};_f._closure={runOnJS:_reactNativeReanimated.runOnJS,onScrollEnd:onScrollEnd,duration:duration,Easing:{easeOutQuart:_constants.Easing.easeOutQuart},dealWithAnimation:_dealWithAnimation.dealWithAnimation,withAnimation:withAnimation};_f.asString="function _f(toValue,onFinished){const{runOnJS,onScrollEnd,duration,Easing,dealWithAnimation,withAnimation}=jsThis._closure;{var _withAnimation;const callback=function(isFinished){\"worklet\";if(isFinished){runOnJS(onScrollEnd)();onFinished&&runOnJS(onFinished)();}};const defaultWithAnimation={type:\"timing\",config:{duration:duration,easing:Easing.easeOutQuart}};return dealWithAnimation((_withAnimation=withAnimation)!==null&&_withAnimation!==void 0?_withAnimation:defaultWithAnimation)(toValue,callback);}}";_f.__workletHash=12575476119920;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx (144:4)";return _f;}(),[duration,withAnimation,onScrollEnd]);var next=_react.default.useCallback(function(){var _f=function _f(){var opts=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var _opts$count=opts.count,count=_opts$count===void 0?1:_opts$count,_opts$animated=opts.animated,animated=_opts$animated===void 0?true:_opts$animated,onFinished=opts.onFinished;if(!canSliding()||!loop&&index.value>=dataInfo.length-1)return;onScrollBegin==null?void 0:onScrollBegin();var nextPage=currentFixedPage()+count;index.value=nextPage;if(animated){handlerOffset.value=scrollWithTiming(-nextPage*size,onFinished);}else{handlerOffset.value=-nextPage*size;onFinished==null?void 0:onFinished();}};_f._closure={canSliding:canSliding,loop:loop,index:index,dataInfo:dataInfo,onScrollBegin:onScrollBegin,currentFixedPage:currentFixedPage,handlerOffset:handlerOffset,scrollWithTiming:scrollWithTiming,size:size};_f.asString="function _f(opts={}){const{canSliding,loop,index,dataInfo,onScrollBegin,currentFixedPage,handlerOffset,scrollWithTiming,size}=jsThis._closure;{var _onScrollBegin;const{count=1,animated=true,onFinished:onFinished}=opts;if(!canSliding()||!loop&&index.value>=dataInfo.length-1)return;(_onScrollBegin=onScrollBegin)===null||_onScrollBegin===void 0?void 0:_onScrollBegin();const nextPage=currentFixedPage()+count;index.value=nextPage;if(animated){handlerOffset.value=scrollWithTiming(-nextPage*size,onFinished);}else{handlerOffset.value=-nextPage*size;onFinished===null||onFinished===void 0?void 0:onFinished();}}}";_f.__workletHash=10530429864168;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx (168:4)";return _f;}(),[canSliding,loop,index,dataInfo,onScrollBegin,handlerOffset,size,scrollWithTiming,currentFixedPage]);var prev=_react.default.useCallback(function(){var opts=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var _opts$count2=opts.count,count=_opts$count2===void 0?1:_opts$count2,_opts$animated2=opts.animated,animated=_opts$animated2===void 0?true:_opts$animated2,onFinished=opts.onFinished;if(!canSliding()||!loop&&index.value<=0)return;onScrollBegin==null?void 0:onScrollBegin();var prevPage=currentFixedPage()-count;index.value=prevPage;if(animated){handlerOffset.value=scrollWithTiming(-prevPage*size,onFinished);}else{handlerOffset.value=-prevPage*size;onFinished==null?void 0:onFinished();}},[canSliding,loop,index,onScrollBegin,handlerOffset,size,scrollWithTiming,currentFixedPage]);var to=_react.default.useCallback(function(opts){var i=opts.i,_opts$animated3=opts.animated,animated=_opts$animated3===void 0?false:_opts$animated3,onFinished=opts.onFinished;if(i===index.value)return;if(!canSliding())return;onScrollBegin==null?void 0:onScrollBegin();var direction=(0,_handlerOffsetDirection.handlerOffsetDirection)(handlerOffset);var offset=i*size*direction;var totalSize=dataInfo.length*size;var isCloseToNextLoop=false;if(loop){isCloseToNextLoop=Math.abs(handlerOffset.value%totalSize)/totalSize>=0.5;}var finalOffset=(Math.floor(Math.abs(handlerOffset.value/totalSize))+(isCloseToNextLoop?1:0))*totalSize*direction+offset;if(animated){index.value=i;handlerOffset.value=scrollWithTiming(finalOffset,onFinished);}else{handlerOffset.value=finalOffset;index.value=i;onFinished==null?void 0:onFinished();}},[index,canSliding,onScrollBegin,handlerOffset,size,dataInfo.length,loop,scrollWithTiming]);var scrollTo=_react.default.useCallback(function(){var opts=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var i=opts.index,count=opts.count,_opts$animated4=opts.animated,animated=_opts$animated4===void 0?false:_opts$animated4,onFinished=opts.onFinished;if(typeof i==="number"&&i>-1){to({i:i,animated:animated,onFinished:onFinished});return;}if(!count)return;var n=Math.round(count);if(n<0)prev({count:Math.abs(n),animated:animated,onFinished:onFinished});else next({count:n,animated:animated,onFinished:onFinished});},[prev,next,to]);return{next:next,prev:prev,scrollTo:scrollTo,getCurrentIndex:getCurrentIndex,getSharedIndex:function getSharedIndex(){return sharedIndex.current;}};}
2
2
  //# sourceMappingURL=useCarouselController.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["useCarouselController.tsx"],"names":["useCarouselController","options","size","data","loop","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","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,IAHF,CASIH,OATJ,CAGEG,IAHF,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,CAAEV,IAAI,CAACU,MADR,CAELC,OAAO,CAAE,CAACX,IAAI,CAACU,MAFV,CAGLE,cAAc,CAAEZ,IAAI,CAACU,MAHhB,CAAP,EADe,CAMf,CAACV,IAAD,CANe,CAAjB,CASA,GAAMa,CAAAA,KAAK,CAAG,0CAAuBT,YAAvB,CAAd,CAEA,GAAMU,CAAAA,W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ACI,GAAL,CAAS2C,CAAT,CAAT,CAAsBZ,QAAQ,CAARA,QAAtB,CAAgCb,UAAU,CAAVA,UAAhC,CAAD,CAAJ,CADF,IAIEU,CAAAA,IAAI,CAAC,CAAEE,KAAK,CAAEa,CAAT,CAAYZ,QAAQ,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,CAIL9B,eAAe,CAAfA,eAJK,CAKLgC,cAAc,CAAE,gCAAMpD,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 { 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 data: TCarouselProps[\"data\"]\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 data,\n loop,\n handlerOffset,\n withAnimation,\n defaultIndex = 0,\n duration,\n autoFillData,\n } = options;\n\n const dataInfo = React.useMemo(\n () => ({\n length: data.length,\n disable: !data.length,\n originalLength: data.length,\n }),\n [data],\n );\n\n const index = useSharedValue<number>(defaultIndex);\n // The Index displayed to the user\n const sharedIndex = useRef<number>(defaultIndex);\n const sharedPreIndex = useRef<number>(defaultIndex);\n\n const currentFixedPage = React.useCallback(() => {\n if (loop)\n return -Math.round(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 return index.value;\n }, [index]);\n\n const canSliding = React.useCallback(() => {\n return !dataInfo.disable;\n }, [dataInfo]);\n\n const onScrollEnd = React.useCallback(() => {\n options.onScrollEnd?.();\n }, [options]);\n\n const onScrollBegin = React.useCallback(() => {\n options.onScrollBegin?.();\n }, [options]);\n\n const scrollWithTiming = React.useCallback(\n (toValue: number, onFinished?: () => void) => {\n \"worklet\";\n const callback = (isFinished: boolean) => {\n \"worklet\";\n if (isFinished) {\n runOnJS(onScrollEnd)();\n onFinished && runOnJS(onFinished)();\n }\n };\n\n const defaultWithAnimation: WithTimingAnimation = {\n type: \"timing\",\n config: { duration, easing: Easing.easeOutQuart },\n };\n\n return dealWithAnimation(withAnimation ?? defaultWithAnimation)(\n toValue,\n callback,\n );\n },\n [duration, withAnimation, onScrollEnd],\n );\n\n const next = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n \"worklet\";\n const { count = 1, animated = true, onFinished } = opts;\n if (!canSliding() || (!loop && index.value >= dataInfo.length - 1))\n return;\n\n onScrollBegin?.();\n\n const nextPage = currentFixedPage() + count;\n index.value = nextPage;\n\n if (animated) {\n 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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AAI,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,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,data=props.data,defaultIndex=props.defaultIndex,defaultScrollOffsetValue=props.defaultScrollOffsetValue,loop=props.loop;var size=vertical?height:width;var validLength=data.length-1;var defaultHandlerOffsetValue=-Math.abs(defaultIndex*size);var _handlerOffset=(0,_reactNativeReanimated.useSharedValue)(defaultHandlerOffsetValue);var handlerOffset=defaultScrollOffsetValue!=null?defaultScrollOffsetValue:_handlerOffset;var prevDataLength=(0,_reactNativeReanimated.useSharedValue)(data.length);_react.default.useEffect(function(){handlerOffset.value=defaultHandlerOffsetValue;},[vertical,handlerOffset,defaultHandlerOffsetValue]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){var previousLength=prevDataLength.value;var currentLength=data.length;var isLengthChanged=previousLength!==currentLength;var shouldComputed=isLengthChanged&&loop;if(shouldComputed)prevDataLength.value=data.length;return{shouldComputed:shouldComputed,previousLength:previousLength,currentLength:currentLength};};_f._closure={prevDataLength:prevDataLength,data:data,loop:loop};_f.asString="function _f(){const{prevDataLength,data,loop}=jsThis._closure;{const previousLength=prevDataLength.value;const currentLength=data.length;const isLengthChanged=previousLength!==currentLength;const shouldComputed=isLengthChanged&&loop;if(shouldComputed)prevDataLength.value=data.length;return{shouldComputed:shouldComputed,previousLength:previousLength,currentLength:currentLength};}}";_f.__workletHash=9379463381326;_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;}(),[data,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="/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};}
2
2
  //# sourceMappingURL=useCommonVariables.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["useCommonVariables.ts"],"names":["useCommonVariables","props","vertical","height","width","data","defaultIndex","defaultScrollOffsetValue","loop","size","validLength","length","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,IAJF,CAQIJ,KARJ,CAIEI,IAJF,CAKEC,YALF,CAQIL,KARJ,CAKEK,YALF,CAMEC,wBANF,CAQIN,KARJ,CAMEM,wB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BT,aAAvB,CAAlB,CAEAA,aAAa,CAACI,KAAd,CAAsB,mEAA+B,CACnDK,SAAS,CAATA,SADmD,CAEnDJ,cAAc,CAAdA,cAFmD,CAGnDC,aAAa,CAAbA,aAHmD,CAInDb,IAAI,CAAJA,IAJmD,CAKnDO,aAAa,CAAEA,aAAa,CAACI,KALsB,CAA/B,CAAtB,CAOD,CACF,CA3BD,qCA9BoBM,8CA8BpB,eAxBmBV,aAwBnB,gCA7BwBW,8DA6BxB,MAzBIlB,IAyBJ,ynBA2BG,CAACJ,IAAD,CAAOG,IAAP,CA3BH,EA6BA,MAAO,CACLC,IAAI,CAAJA,IADK,CAELC,WAAW,CAAXA,WAFK,CAGLM,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 data,\n defaultIndex,\n defaultScrollOffsetValue,\n loop,\n } = props;\n const size = vertical ? height : width;\n const validLength = data.length - 1;\n const defaultHandlerOffsetValue = -Math.abs(defaultIndex * size);\n const _handlerOffset = useSharedValue<number>(defaultHandlerOffsetValue);\n const handlerOffset = defaultScrollOffsetValue ?? _handlerOffset;\n const prevDataLength = useSharedValue(data.length);\n\n React.useEffect(() => {\n handlerOffset.value = defaultHandlerOffsetValue;\n }, [vertical, handlerOffset, defaultHandlerOffsetValue]);\n\n useAnimatedReaction(() => {\n const previousLength = prevDataLength.value;\n const currentLength = data.length;\n const isLengthChanged = previousLength !== currentLength;\n const shouldComputed = isLengthChanged && loop;\n\n if (shouldComputed)\n prevDataLength.value = data.length;\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 }, [data, 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,wBAA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AAXA,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,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]);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:data.length-1;}return _objectSpread(_objectSpread({},props),{},{defaultIndex:defaultIndex,autoFillData:autoFillData,data:data,rawData:rawData,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$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});}
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","mode","modeConfig","showLength"],"mappings":"4QAAA,oDAGA,2E,kxBAqBO,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,0BAWoC,IAXpC,oBAYSC,MAZT,CAcIf,KAdJ,CAYEgB,KAZF,CAaUC,OAbV,CAcIjB,KAdJ,CAaEkB,MAbF,CAgBA,GAAMF,CA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D","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};\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 computedFillDataWithAutoFillData<T>({\n loop,\n autoFillData,\n data: rawData,\n dataLength: rawData.length,\n }),\n [rawData, loop, autoFillData],\n );\n\n if (props.mode === \"vertical-stack\" || props.mode === \"horizontal-stack\") {\n if (!props.modeConfig)\n props.modeConfig = {};\n\n props.modeConfig.showLength\n = props.modeConfig?.showLength ?? data.length - 1;\n }\n return {\n ...props,\n defaultIndex,\n autoFillData,\n data,\n rawData,\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","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,0BAWoC,IAXpC,oBAYSC,MAZT,CAcIf,KAdJ,CAYEgB,KAZF,CAaUC,OAbV,CAcIjB,KAdJ,CAaEkB,MAbF,CAgBA,GAAMF,CAAAA,KAAK,CAAGG,IAAI,CAACC,KAAL,CAAWL,MAAM,EAAI,CAArB,CAAd,CACA,GAAMG,CAAAA,MAAM,CAAGC,IAAI,CAACC,KAAL,CAAWH,OAAO,EAAI,CAAtB,CAAf,CACA,GAAMX,CAAAA,gBAAgB,CAAGa,IAAI,CAACE,GAAL,CAASd,iBAAT,CAA4B,CAA5B,CAAzB,CAEA,GAAML,CAAAA,IAAI,CAAGoB,eAAMC,OAAN,CACX,UAAM,CACJ,MAAO,+DAAoC,CACzCnB,IAAI,CAAJA,IADyC,CAEzCQ,YAAY,CAAZA,YAFyC,CAGzCV,IAAI,CAAEC,OAHmC,CAIzCqB,UAAU,CAAErB,OAAO,CAACsB,MAJqB,CAApC,CAAP,CAMD,CARU,CASX,CAACtB,OAAD,CAAUC,IAAV,CAAgBQ,YAAhB,CATW,CAAb,CAYA,GAAMY,CAAAA,UAAU,CAAGtB,IAAI,CAACuB,MAAxB,CACA,GAAMC,CAAAA,aAAa,CAAGvB,OAAO,CAACsB,MAA9B,CAEA,GAAIzB,KAAK,CAAC2B,IAAN,GAAe,gBAAf,EAAmC3B,KAAK,CAAC2B,IAAN,GAAe,kBAAtD,CAA0E,6CACxE,GAAI,CAAC3B,KAAK,CAAC4B,UAAX,CACE5B,KAAK,CAAC4B,UAAN,CAAmB,EAAnB,CAEF5B,KAAK,CAAC4B,UAAN,CAAiBC,UAAjB,2CAA8B7B,KAAK,CAAC4B,UAApC,eAA8B,kBAAkBC,UAAhD,8BAA8DL,UAAU,CAAG,CAA3E,CACD,CAED,sCACKxB,KADL,MAEEC,YAAY,CAAZA,YAFF,CAGEW,YAAY,CAAZA,YAHF,CAKEV,IAAI,CAAJA,IALF,CAOEsB,UAAU,CAAVA,UAPF,CASErB,OAAO,CAAPA,OATF,CAWEuB,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,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,data=opts.data,_opts$type=opts.type,type=_opts$type===void 0?"positive":_opts$type,_opts$viewCount=opts.viewCount,viewCount=_opts$viewCount===void 0?Math.round((data.length-1)/2):_opts$viewCount;var ITEM_LENGTH=data.length;var VALID_LENGTH=ITEM_LENGTH-1;var TOTAL_WIDTH=size*ITEM_LENGTH;var HALF_WIDTH=0.5*size;var positiveCount=type==="positive"?viewCount:VALID_LENGTH-viewCount;var startPos=size*index;if(index>positiveCount)startPos=(index-ITEM_LENGTH)*size;var MAX=positiveCount*size;var MIN=-((VALID_LENGTH-positiveCount)*size);var x=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var _visibleRanges$value=visibleRanges.value,negativeRange=_visibleRanges$value.negativeRange,positiveRange=_visibleRanges$value.positiveRange;if((index<negativeRange[0]||index>negativeRange[1])&&(index<positiveRange[0]||index>positiveRange[1]))return Number.MAX_SAFE_INTEGER;if(loop){var inputRange=[-TOTAL_WIDTH,MIN-HALF_WIDTH-startPos-Number.MIN_VALUE,MIN-HALF_WIDTH-startPos,0,MAX+HALF_WIDTH-startPos,MAX+HALF_WIDTH-startPos+Number.MIN_VALUE,TOTAL_WIDTH];var outputRange=[startPos,MAX+HALF_WIDTH-Number.MIN_VALUE,MIN-HALF_WIDTH,startPos,MAX+HALF_WIDTH,MIN-HALF_WIDTH+Number.MIN_VALUE,startPos];return(0,_reactNativeReanimated.interpolate)(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 (46:28)";return _f;}(),[loop,data,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="/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;
2
2
  //# sourceMappingURL=useOffsetX.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["useOffsetX.ts"],"names":["useOffsetX","opts","visibleRanges","handlerOffset","index","size","loop","data","type","viewCount","Math","round","length","ITEM_LENGTH","VALID_LENGTH","TOTAL_WIDTH","HALF_WIDTH","positiveCount","startPos","MAX","MIN","x","value","negativeRange","positiveRange","Number","MAX_SAFE_INTEGER","inputRange","MIN_VALUE","outputRange","Extrapolate","CLAMP","interpolate"],"mappings":"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,IALF,CAQIN,IARJ,CAKEM,IALF,YAQIN,IARJ,CAMEO,IANF,CAMEA,IANF,qBAMS,UANT,4BAQIP,IARJ,CAOEQ,SAPF,CAOEA,SAPF,0BAOcC,IAAI,CAACC,KAAL,CAAW,CAACJ,IAAI,CAACK,MAAL,CAAc,CAAf,EAAoB,CAA/B,CAPd,iBAUA,GAAMC,CAAAA,WAAW,CAAGN,IAAI,CAACK,MAAzB,CACA,GAAME,CAAAA,YAAY,CAAGD,WAAW,CAAG,CAAnC,CACA,GAAME,CAAAA,WAAW,CAAGV,IAAI,CAAGQ,WAA3B,CACA,GAAMG,CAAAA,UA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FR,CAGlBR,GAAG,CAAGJ,UAHY,CAIlBE,QAJkB,CAKlBC,GAAG,CAAGH,UALY,CAMlBI,GAAG,CAAGJ,UAAN,CAAmBS,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,4BAxCNF,aAwCM,OA/B0BE,KA+B1B,MArCNE,IAqCM,aApCuLS,WAoCvL,KAnC0GK,GAmC1G,YAnCgHJ,UAmChH,UAnC+IE,QAmC/I,KAnCwFC,GAmCxF,aAlCDa,kCAkCC,eA/BH7B,aA+BG,oBAlCyD2B,mCAAYC,KAkCrE,OA/BmB1B,IA+BnB,w9BAsCP,CAACC,IAAD,CAAOC,IAAP,CAAaE,SAAb,CAAwBD,IAAxB,CAA8BH,IAA9B,CAAoCH,aAApC,CAtCO,CAAV,CAwCA,MAAOmB,CAAAA,CAAP,CACD,CAnEM,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 data: unknown[]\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 data,\n type = \"positive\",\n viewCount = Math.round((data.length - 1) / 2),\n } = opts;\n\n const ITEM_LENGTH = data.length;\n const VALID_LENGTH = ITEM_LENGTH - 1;\n const TOTAL_WIDTH = size * ITEM_LENGTH;\n const HALF_WIDTH = 0.5 * size;\n\n const positiveCount\n = type === \"positive\" ? viewCount : VALID_LENGTH - viewCount;\n\n let startPos = size * index;\n if (index > positiveCount)\n startPos = (index - ITEM_LENGTH) * size;\n\n 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, data, 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,CA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A,MAAM,CAACC,gBAAd,CAEF,GAAIpB,IAAJ,CAAU,CACR,GAAMqB,CAAAA,UAAU,CAAG,CACjB,CAACd,WADgB,CAEjBO,GAAG,CAAGN,UAAN,CAAmBI,QAAnB,CAA8BO,MAAM,CAACG,SAFpB,CAGjBR,GAAG,CAAGN,UAAN,CAAmBI,QAHF,CAIjB,CAJiB,CAKjBC,GAAG,CAAGL,UAAN,CAAmBI,QALF,CAMjBC,GAAG,CAAGL,UAAN,CAAmBI,QAAnB,CAA8BO,MAAM,CAACG,SANpB,CAOjBf,WAPiB,CAAnB,CAUA,GAAMgB,CAAAA,WAAW,CAAG,CAClBX,QADkB,CAElBC,GAAG,CAAGL,UAAN,CAAmBW,MAAM,CAACG,SAFR,CAGlBR,GAAG,CAAGN,UAHY,CAIlBI,QAJkB,CAKlBC,GAAG,CAAGL,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,w9BAsCP,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,rawData=opts.rawData,size=opts.size,onProgressChange=opts.onProgressChange;var rawDataLength=rawData.length;(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return offsetX.value;};_f._closure={offsetX:offsetX};_f.asString="function _f(){const{offsetX}=jsThis._closure;{return offsetX.value;}}";_f.__workletHash=11091407603539;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts (25: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 (26: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="/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]);}
2
2
  //# sourceMappingURL=useOnProgressChange.js.map