react-native-reanimated-carousel 3.4.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/Carousel.js +1 -1
- package/lib/commonjs/Carousel.js.map +1 -1
- package/lib/commonjs/LazyView.js +1 -1
- package/lib/commonjs/LazyView.js.map +1 -1
- package/lib/commonjs/ScrollViewGesture.js +1 -1
- package/lib/commonjs/ScrollViewGesture.js.map +1 -1
- package/lib/commonjs/hooks/computeNewIndexWhenDataChanges.js +1 -1
- package/lib/commonjs/hooks/computeNewIndexWhenDataChanges.js.map +1 -1
- package/lib/commonjs/hooks/index.test.js +1 -1
- package/lib/commonjs/hooks/index.test.js.map +1 -1
- package/lib/commonjs/hooks/useAutoPlay.js.map +1 -1
- package/lib/commonjs/hooks/useCarouselController.js +1 -1
- package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
- package/lib/commonjs/hooks/useInitProps.js +1 -1
- package/lib/commonjs/hooks/useInitProps.js.map +1 -1
- package/lib/commonjs/hooks/useOffsetX.js +1 -1
- package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layouts/BaseLayout.js +1 -1
- package/lib/commonjs/layouts/BaseLayout.js.map +1 -1
- package/lib/commonjs/layouts/ParallaxLayout.js +1 -1
- package/lib/commonjs/layouts/ParallaxLayout.js.map +1 -1
- package/lib/commonjs/layouts/normal.js +1 -1
- package/lib/commonjs/layouts/normal.js.map +1 -1
- package/lib/commonjs/layouts/parallax.js +1 -1
- package/lib/commonjs/layouts/parallax.js.map +1 -1
- package/lib/commonjs/layouts/stack.js +1 -1
- package/lib/commonjs/layouts/stack.js.map +1 -1
- package/lib/commonjs/utils/computedWithAutoFillData.js +1 -1
- package/lib/commonjs/utils/computedWithAutoFillData.js.map +1 -1
- package/lib/commonjs/utils/dealWithAnimation.js +1 -1
- package/lib/commonjs/utils/dealWithAnimation.js.map +1 -1
- package/lib/commonjs/utils/handlerOffsetDirection.js +1 -1
- package/lib/commonjs/utils/handlerOffsetDirection.js.map +1 -1
- package/lib/commonjs/utils/log.js +1 -1
- package/lib/commonjs/utils/log.js.map +1 -1
- package/lib/module/Carousel.js +3 -2
- package/lib/module/Carousel.js.map +1 -1
- package/lib/module/LazyView.js.map +1 -1
- package/lib/module/ScrollViewGesture.js.map +1 -1
- package/lib/module/hooks/useAutoPlay.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/layouts/ParallaxLayout.js.map +1 -1
- package/lib/typescript/LazyView.d.ts +2 -1
- package/lib/typescript/ScrollViewGesture.d.ts +2 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/layouts/ParallaxLayout.d.ts +3 -2
- package/lib/typescript/types.d.ts +0 -1
- package/package.json +12 -10
- package/src/Carousel.tsx +28 -25
- package/src/LazyView.tsx +2 -1
- package/src/ScrollViewGesture.tsx +3 -4
- package/src/hooks/useAutoPlay.ts +1 -1
- package/src/index.tsx +2 -0
- package/src/layouts/ParallaxLayout.tsx +3 -4
|
@@ -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,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="/home/runner/work/react-native-reanimated-carousel/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="/home/runner/work/react-native-reanimated-carousel/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="/home/runner/work/react-native-reanimated-carousel/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="/home/runner/work/react-native-reanimated-carousel/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="/home/runner/work/react-native-reanimated-carousel/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;}};}
|
|
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;}var _worklet_11883385583138_init_data={code:"function anonymous() {\n const {\n handlerOffset,\n round,\n size,\n dataInfo,\n convertToSharedIndex,\n loop,\n autoFillData\n } = this._closure;\n const handlerOffsetValue = handlerOffset.value;\n const toInt = round(handlerOffsetValue / size) % dataInfo.length;\n const isPositive = handlerOffsetValue <= 0;\n const i = isPositive ? Math.abs(toInt) : Math.abs(toInt > 0 ? dataInfo.length - toInt : 0);\n const newSharedIndexValue = convertToSharedIndex({\n loop: loop,\n rawDataLength: dataInfo.originalLength,\n autoFillData: autoFillData,\n index: i\n });\n return {\n i: i,\n newSharedIndexValue: newSharedIndexValue\n };\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"handlerOffset\",\"round\",\"size\",\"dataInfo\",\"convertToSharedIndex\",\"loop\",\"autoFillData\",\"_closure\",\"handlerOffsetValue\",\"value\",\"toInt\",\"length\",\"isPositive\",\"i\",\"Math\",\"abs\",\"newSharedIndexValue\",\"rawDataLength\",\"originalLength\",\"index\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx\"],\"mappings\":\"AAmFI,SAAAA,SAAMA,CAAA;EAAA;IAAAC,aAAA;IAAAC,KAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,oBAAA;IAAAC,IAAA;IAAAC;EAAA,SAAAC,QAAA;EACJ,MAAMC,kBAAkB,GAAGR,aAAa,CAACS,KAAK;EAC9C,MAAMC,KAAK,GAAGT,KAAK,CAACO,kBAAkB,GAAGN,IAAI,CAAC,GAAGC,QAAQ,CAACQ,MAAM;EAChE,MAAMC,UAAU,GAAGJ,kBAAkB,IAAI,CAAC;EAC1C,MAAMK,CAAC,GAAGD,UAAU,GAChBE,IAAI,CAACC,GAAG,CAACL,KAAK,CAAC,GACfI,IAAI,CAACC,GAAG,CAACL,KAAK,GAAG,CAAC,GAAGP,QAAQ,CAACQ,MAAM,GAAGD,KAAK,GAAG,CAAC,CAAC;EAErD,MAAMM,mBAAmB,GAAGZ,oBAAoB,CAAC;IAC/CC,IAAI,EAAJA,IAAI;IACJY,aAAa,EAAEd,QAAQ,CAACe,cAAc;IACtCZ,YAAY,EAAEA,YAAa;IAC3Ba,KAAK,EAAEN;EACT,CAAC,CAAC;EAEF,OAAO;IACLA,CAAC,EAADA,CAAC;IACDG,mBAAA,EAAAA;EACF,CAAC;AACH\"}"};var _worklet_6063199752963_init_data={code:"function anonymous({\n i: i,\n newSharedIndexValue: newSharedIndexValue\n}) {\n const {\n index,\n runOnJS,\n setSharedIndex\n } = this._closure;\n index.value = i;\n runOnJS(setSharedIndex)(newSharedIndexValue);\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"i\",\"newSharedIndexValue\",\"index\",\"runOnJS\",\"setSharedIndex\",\"_closure\",\"value\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx\"],\"mappings\":\"AAuGI,SAACA,UAAA;EAAEC,CAAC,EAADA,CAAC;EAAEC,mBAAA,EAAAA;AAAoB,CAAC,EAAK;EAAA;IAAAC,KAAA;IAAAC,OAAA;IAAAC;EAAA,SAAAC,QAAA;EAC9BH,KAAK,CAACI,KAAK,GAAGN,CAAC;EACfG,OAAO,CAACC,cAAc,CAAC,CAACH,mBAAmB,CAAC;AAC9C\"}"};var _worklet_8876815392037_init_data={code:"function anonymous(toValue, onFinished) {\n const {\n runOnJS,\n onScrollEnd,\n duration,\n Easing,\n dealWithAnimation,\n withAnimation\n } = this._closure;\n var _withAnimation;\n const callback = function (isFinished) {\n \"worklet\";\n\n if (isFinished) {\n runOnJS(onScrollEnd)();\n onFinished && runOnJS(onFinished)();\n }\n };\n const defaultWithAnimation = {\n type: \"timing\",\n config: {\n duration: duration,\n easing: Easing.easeOutQuart\n }\n };\n return dealWithAnimation((_withAnimation = withAnimation) !== null && _withAnimation !== void 0 ? _withAnimation : defaultWithAnimation)(toValue, callback);\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"toValue\",\"onFinished\",\"runOnJS\",\"onScrollEnd\",\"duration\",\"Easing\",\"dealWithAnimation\",\"withAnimation\",\"_closure\",\"_withAnimation\",\"callback\",\"isFinished\",\"defaultWithAnimation\",\"type\",\"config\",\"easing\",\"easeOutQuart\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx\"],\"mappings\":\"AA+II,SAACA,SAAeA,CAAAC,OAAE,EAAAC,UAA4B;EAAA;IAAAC,OAAA;IAAAC,WAAA;IAAAC,QAAA;IAAAC,MAAA;IAAAC,iBAAA;IAAAC;EAAA,SAAAC,QAAA;EAAA,IAAAC,cAAA;EAE5C,MAAMC,QAAQ,GAAG,SAAAA,CAACC,UAAmB,EAAK;IACxC,SAAS;;IACT,IAAIA,UAAU,EAAE;MACdT,OAAO,CAACC,WAAW,CAAC,CAAC,CAAC;MACtBF,UAAU,IAAIC,OAAO,CAACD,UAAU,CAAC,CAAC,CAAC;IACrC;EACF,CAAC;EAED,MAAMW,oBAAyC,GAAG;IAChDC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;MAAEV,QAAQ,EAARA,QAAQ;MAAEW,MAAM,EAAEV,MAAM,CAACW;IAAa;EAClD,CAAC;EAED,OAAOV,iBAAiB,EAAAG,cAAA,GAACF,aAAa,cAAAE,cAAA,cAAAA,cAAA,GAAIG,oBAAoB,CAAC,CAC7DZ,OAAO,EACPU,QACF,CAAC;AACH\"}"};var _worklet_1856840040824_init_data={code:"function anonymous(isFinished) {\n const {\n runOnJS,\n onScrollEnd,\n onFinished\n } = this._closure;\n if (isFinished) {\n runOnJS(onScrollEnd)();\n onFinished && runOnJS(onFinished)();\n }\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"isFinished\",\"runOnJS\",\"onScrollEnd\",\"onFinished\",\"_closure\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx\"],\"mappings\":\"AAiJuB,SAACA,UAAAC,UAAwB;EAAA;IAAAC,OAAA;IAAAC,WAAA;IAAAC;EAAA,SAAAC,QAAA;EAExC,IAAIJ,UAAU,EAAE;IACdC,OAAO,CAACC,WAAW,CAAC,CAAC,CAAC;IACtBC,UAAU,IAAIF,OAAO,CAACE,UAAU,CAAC,CAAC,CAAC;EACrC;AACF\"}"};var _worklet_7037612364285_init_data={code:"function anonymous(opts = {}) {\n const {\n canSliding,\n loop,\n index,\n dataInfo,\n onScrollBegin,\n currentFixedPage,\n handlerOffset,\n scrollWithTiming,\n size\n } = this._closure;\n var _onScrollBegin;\n const {\n count = 1,\n animated = true,\n onFinished: onFinished\n } = opts;\n if (!canSliding() || !loop && index.value >= dataInfo.length - 1) return;\n (_onScrollBegin = onScrollBegin) === null || _onScrollBegin === void 0 ? void 0 : _onScrollBegin();\n const nextPage = currentFixedPage() + count;\n index.value = nextPage;\n if (animated) {\n handlerOffset.value = scrollWithTiming(-nextPage * size, onFinished);\n } else {\n handlerOffset.value = -nextPage * size;\n onFinished === null || onFinished === void 0 ? void 0 : onFinished();\n }\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"opts\",\"canSliding\",\"loop\",\"index\",\"dataInfo\",\"onScrollBegin\",\"currentFixedPage\",\"handlerOffset\",\"scrollWithTiming\",\"size\",\"_closure\",\"_onScrollBegin\",\"count\",\"animated\",\"onFinished\",\"value\",\"length\",\"nextPage\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCarouselController.tsx\"],\"mappings\":\"AAuKI,SAACA,SAAgCA,CAACC,IAAK;EAAA;IAAAC,UAAA;IAAAC,IAAA;IAAAC,KAAA;IAAAC,QAAA;IAAAC,aAAA;IAAAC,gBAAA;IAAAC,aAAA;IAAAC,gBAAA;IAAAC;EAAA,SAAAC,QAAA;EAAA,IAAAC,cAAA;EAErC,MAAM;IAAEC,KAAK,GAAG,CAAC;IAAEC,QAAQ,GAAG,IAAI;IAAEC,UAAA,EAAAA;EAAW,CAAC,GAAGd,IAAI;EACvD,IAAI,CAACC,UAAU,CAAC,CAAC,IAAK,CAACC,IAAI,IAAIC,KAAK,CAACY,KAAK,IAAIX,QAAQ,CAACY,MAAM,GAAG,CAAE,EAChE;EAEF,CAAAL,cAAA,GAAAN,aAAa,cAAAM,cAAA,uBAAbA,cAAA,CAAgB,CAAC;EAEjB,MAAMM,QAAQ,GAAGX,gBAAgB,CAAC,CAAC,GAAGM,KAAK;EAC3CT,KAAK,CAACY,KAAK,GAAGE,QAAQ;EAEtB,IAAIJ,QAAQ,EAAE;IACZN,aAAa,CAACQ,KAAK,GAAGP,gBAAgB,CACpC,CAACS,QAAQ,GAAGR,IAAI,EAChBK,UACF,CAAQ;EACV,CAAC,MACI;IACHP,aAAa,CAACQ,KAAK,GAAG,CAACE,QAAQ,GAAGR,IAAI;IACtCK,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAG,CAAC;EAChB;AACF\"}"};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 _e=[new global.Error(),-8,-27];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.__initData=_worklet_11883385583138_init_data;_f.__workletHash=11883385583138;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),function(){var _e=[new global.Error(),-4,-27];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.__initData=_worklet_6063199752963_init_data;_f.__workletHash=6063199752963;_f.__stackDetails=_e;_f.__version="3.3.0";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 _e=[new global.Error(),-7,-27];var _f=function _f(toValue,onFinished){var callback=function(){var _e=[new global.Error(),-4,-27];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.__initData=_worklet_1856840040824_init_data;_f.__workletHash=1856840040824;_f.__stackDetails=_e;_f.__version="3.3.0";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:_constants.Easing,dealWithAnimation:_dealWithAnimation.dealWithAnimation,withAnimation:withAnimation};_f.__initData=_worklet_8876815392037_init_data;_f.__workletHash=8876815392037;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),[duration,withAnimation,onScrollEnd]);var next=_react.default.useCallback(function(){var _e=[new global.Error(),-10,-27];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.__initData=_worklet_7037612364285_init_data;_f.__workletHash=7037612364285;_f.__stackDetails=_e;_f.__version="3.3.0";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","loop","dataLength","handlerOffset","withAnimation","defaultIndex","duration","autoFillData","dataInfo","React","useMemo","length","disable","originalLength","index","sharedIndex","sharedPreIndex","currentFixedPage","useCallback","Math","round","value","fixed","abs","setSharedIndex","newSharedIndex","current","handlerOffsetValue","toInt","isPositive","i","newSharedIndexValue","rawDataLength","convertToSharedIndex","runOnJS","getCurrentIndex","realIndex","canSliding","onScrollEnd","onScrollBegin","scrollWithTiming","toValue","onFinished","callback","isFinished","defaultWithAnimation","type","config","easing","Easing","easeOutQuart","dealWithAnimation","next","opts","count","animated","nextPage","prev","prevPage","to","direction","offset","totalSize","isCloseToNextLoop","finalOffset","floor","scrollTo","n","getSharedIndex"],"mappings":"6GAAA,qDAEA,8DAMA,uCAMA,2EACA,6DACA,uEACA,iC,0/BAuBO,QAASA,CAAAA,qBAAT,CAA+BC,OAA/B,CAAoE,CACzE,GACEC,CAAAA,IADF,CASID,OATJ,CACEC,IADF,CAEEC,IAFF,CASIF,OATJ,CAEEE,IAFF,CAGEC,UAHF,CASIH,OATJ,CAGEG,UAHF,CAIEC,aAJF,CASIJ,OATJ,CAIEI,aAJF,CAKEC,aALF,CASIL,OATJ,CAKEK,aALF,uBASIL,OATJ,CAMEM,YANF,CAMEA,YANF,gCAMiB,CANjB,uBAOEC,QAPF,CASIP,OATJ,CAOEO,QAPF,CAQEC,YARF,CASIR,OATJ,CAQEQ,YARF,CAWA,GAAMC,CAAAA,QAAQ,CAAGC,eAAMC,OAAN,CACf,iBAAO,CACLC,MAAM,CAAET,UADH,CAELU,OAAO,CAAE,CAACV,UAFL,CAGLW,cAAc,CAAEX,UAHX,CAAP,EADe,CAMf,CAACA,UAAD,CANe,CAAjB,CASA,GAAMY,CAAAA,KAAK,CAAG,0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AAC,CAAE7B,CAAC,CAADA,CAAF,CAAKyB,QAAQ,CAARA,QAAL,CAAeb,UAAU,CAAVA,UAAf,CAAD,CAAF,CACA,OACD,CAED,GAAI,CAACY,KAAL,CACE,OAEF,GAAMa,CAAAA,CAAC,CAAGhD,IAAI,CAACC,KAAL,CAAWkC,KAAX,CAAV,CAEA,GAAIa,CAAC,CAAG,CAAR,CACEV,IAAI,CAAC,CAAEH,KAAK,CAAEnC,IAAI,CAACI,GAAL,CAAS4C,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,CAIL/B,eAAe,CAAfA,eAJK,CAKLiC,cAAc,CAAE,gCAAMrD,CAAAA,WAAW,CAACW,OAAlB,EALX,CAAP,CAOD","sourcesContent":["import React, { useRef } from \"react\";\nimport type Animated from \"react-native-reanimated\";\nimport {\n runOnJS,\n useAnimatedReaction,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { Easing } from \"../constants\";\nimport type {\n TCarouselActionOptions,\n TCarouselProps,\n WithTimingAnimation,\n} from \"../types\";\nimport { computedRealIndexWithAutoFillData, convertToSharedIndex } from \"../utils/computedWithAutoFillData\";\nimport { dealWithAnimation } from \"../utils/dealWithAnimation\";\nimport { handlerOffsetDirection } from \"../utils/handlerOffsetDirection\";\nimport { round } from \"../utils/log\";\n\ninterface IOpts {\n loop: boolean\n size: number\n dataLength: number\n autoFillData: TCarouselProps[\"autoFillData\"]\n handlerOffset: Animated.SharedValue<number>\n withAnimation?: TCarouselProps[\"withAnimation\"]\n duration?: number\n defaultIndex?: number\n onScrollBegin?: () => void\n onScrollEnd?: () => void\n}\n\nexport interface ICarouselController {\n getSharedIndex: () => number\n prev: (opts?: TCarouselActionOptions) => void\n next: (opts?: TCarouselActionOptions) => void\n getCurrentIndex: () => number\n scrollTo: (opts?: TCarouselActionOptions) => void\n}\n\nexport function useCarouselController(options: IOpts): ICarouselController {\n const {\n size,\n loop,\n dataLength,\n handlerOffset,\n withAnimation,\n defaultIndex = 0,\n duration,\n autoFillData,\n } = options;\n\n const dataInfo = React.useMemo(\n () => ({\n length: dataLength,\n disable: !dataLength,\n originalLength: dataLength,\n }),\n [dataLength],\n );\n\n const index = useSharedValue<number>(defaultIndex);\n // The Index displayed to the user\n const sharedIndex = useRef<number>(defaultIndex);\n const sharedPreIndex = useRef<number>(defaultIndex);\n\n const currentFixedPage = React.useCallback(() => {\n if (loop)\n return -Math.round(handlerOffset.value / size);\n\n const fixed = (handlerOffset.value / size) % dataInfo.length;\n return Math.round(\n handlerOffset.value <= 0\n ? Math.abs(fixed)\n : Math.abs(fixed > 0 ? dataInfo.length - fixed : 0),\n );\n }, [handlerOffset, dataInfo, size, loop]);\n\n function setSharedIndex(newSharedIndex: number) {\n sharedIndex.current = newSharedIndex;\n }\n\n useAnimatedReaction(\n () => {\n const handlerOffsetValue = handlerOffset.value;\n const toInt = round(handlerOffsetValue / size) % dataInfo.length;\n const isPositive = handlerOffsetValue <= 0;\n const i = isPositive\n ? Math.abs(toInt)\n : Math.abs(toInt > 0 ? dataInfo.length - toInt : 0);\n\n const newSharedIndexValue = convertToSharedIndex({\n loop,\n rawDataLength: dataInfo.originalLength,\n autoFillData: autoFillData!,\n index: i,\n });\n\n return {\n i,\n newSharedIndexValue,\n };\n },\n ({ i, newSharedIndexValue }) => {\n index.value = i;\n runOnJS(setSharedIndex)(newSharedIndexValue);\n },\n [\n sharedPreIndex,\n sharedIndex,\n size,\n dataInfo,\n index,\n loop,\n autoFillData,\n handlerOffset,\n ],\n );\n\n const getCurrentIndex = React.useCallback(() => {\n const realIndex = computedRealIndexWithAutoFillData({\n index: index.value,\n dataLength: dataInfo.originalLength,\n loop,\n autoFillData: autoFillData!,\n });\n\n return realIndex;\n }, [index, autoFillData, dataInfo, loop]);\n\n const canSliding = React.useCallback(() => {\n return !dataInfo.disable;\n }, [dataInfo]);\n\n const onScrollEnd = React.useCallback(() => {\n options.onScrollEnd?.();\n }, [options]);\n\n const onScrollBegin = React.useCallback(() => {\n options.onScrollBegin?.();\n }, [options]);\n\n const scrollWithTiming = React.useCallback(\n (toValue: number, onFinished?: () => void) => {\n \"worklet\";\n const callback = (isFinished: boolean) => {\n \"worklet\";\n if (isFinished) {\n runOnJS(onScrollEnd)();\n onFinished && runOnJS(onFinished)();\n }\n };\n\n const defaultWithAnimation: WithTimingAnimation = {\n type: \"timing\",\n config: { duration, easing: Easing.easeOutQuart },\n };\n\n return dealWithAnimation(withAnimation ?? defaultWithAnimation)(\n toValue,\n callback,\n );\n },\n [duration, withAnimation, onScrollEnd],\n );\n\n const next = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n \"worklet\";\n const { count = 1, animated = true, onFinished } = opts;\n if (!canSliding() || (!loop && index.value >= dataInfo.length - 1))\n return;\n\n onScrollBegin?.();\n\n const nextPage = currentFixedPage() + count;\n index.value = nextPage;\n\n if (animated) {\n handlerOffset.value = scrollWithTiming(\n -nextPage * size,\n onFinished,\n ) as any;\n }\n else {\n handlerOffset.value = -nextPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n dataInfo,\n onScrollBegin,\n handlerOffset,\n size,\n scrollWithTiming,\n currentFixedPage,\n ],\n );\n\n const prev = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n const { count = 1, animated = true, onFinished } = opts;\n if (!canSliding() || (!loop && index.value <= 0)) return;\n\n onScrollBegin?.();\n\n const prevPage = currentFixedPage() - count;\n index.value = prevPage;\n\n if (animated) {\n handlerOffset.value = scrollWithTiming(\n -prevPage * size,\n onFinished,\n );\n }\n else {\n handlerOffset.value = -prevPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n onScrollBegin,\n handlerOffset,\n size,\n scrollWithTiming,\n currentFixedPage,\n ],\n );\n\n const to = React.useCallback(\n (opts: { i: number; animated: boolean; onFinished?: () => void }) => {\n const { i, animated = false, onFinished } = opts;\n if (i === index.value) return;\n if (!canSliding()) return;\n\n onScrollBegin?.();\n // direction -> 1 | -1\n const direction = handlerOffsetDirection(handlerOffset);\n\n // target offset\n const offset = i * size * direction;\n // page width size * page count\n const totalSize = dataInfo.length * size;\n\n let isCloseToNextLoop = false;\n\n if (loop) {\n isCloseToNextLoop\n = Math.abs(handlerOffset.value % totalSize) / totalSize\n >= 0.5;\n }\n\n const finalOffset\n = (Math.floor(Math.abs(handlerOffset.value / totalSize))\n + (isCloseToNextLoop ? 1 : 0))\n * totalSize\n * direction\n + offset;\n\n if (animated) {\n index.value = i;\n handlerOffset.value = scrollWithTiming(finalOffset, onFinished);\n }\n else {\n handlerOffset.value = finalOffset;\n index.value = i;\n onFinished?.();\n }\n },\n [\n index,\n canSliding,\n onScrollBegin,\n handlerOffset,\n size,\n dataInfo.length,\n loop,\n scrollWithTiming,\n ],\n );\n\n const scrollTo = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n const { index: i, count, animated = false, onFinished } = opts;\n if (typeof i === \"number\" && i > -1) {\n to({ i, animated, onFinished });\n return;\n }\n\n if (!count)\n return;\n\n const n = Math.round(count);\n\n if (n < 0)\n prev({ count: Math.abs(n), animated, onFinished });\n\n else\n next({ count: n, animated, onFinished });\n },\n [prev, next, to],\n );\n\n return {\n next,\n prev,\n scrollTo,\n getCurrentIndex,\n getSharedIndex: () => sharedIndex.current,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["useCarouselController.tsx"],"names":["useCarouselController","options","size","loop","dataLength","handlerOffset","withAnimation","defaultIndex","duration","autoFillData","dataInfo","React","useMemo","length","disable","originalLength","index","sharedIndex","sharedPreIndex","currentFixedPage","useCallback","Math","round","value","fixed","abs","setSharedIndex","newSharedIndex","current","handlerOffsetValue","toInt","isPositive","i","newSharedIndexValue","rawDataLength","convertToSharedIndex","runOnJS","getCurrentIndex","realIndex","canSliding","onScrollEnd","onScrollBegin","scrollWithTiming","toValue","onFinished","callback","isFinished","defaultWithAnimation","type","config","easing","Easing","easeOutQuart","dealWithAnimation","next","opts","count","animated","nextPage","prev","prevPage","to","direction","offset","totalSize","isCloseToNextLoop","finalOffset","floor","scrollTo","n","getSharedIndex"],"mappings":"6GAAA,qDAEA,8DAMA,uCAMA,2EACA,6DACA,uEACA,iC,ypRAuBO,QAASA,CAAAA,qBAAT,CAA+BC,OAA/B,CAAoE,CACzE,GACEC,CAAAA,IADF,CASID,OATJ,CACEC,IADF,CAEEC,IAFF,CASIF,OATJ,CAEEE,IAFF,CAGEC,UAHF,CASIH,OATJ,CAGEG,UAHF,CAIEC,aAJF,CASIJ,OATJ,CAIEI,aAJF,CAKEC,aALF,CASIL,OATJ,CAKEK,aALF,uBASIL,OATJ,CAMEM,YANF,CAMEA,YANF,gCAMiB,CANjB,uBAOEC,QAPF,CASIP,OATJ,CAOEO,QAPF,CAQEC,YARF,CASIR,OATJ,CAQEQ,YARF,CAWA,GAAMC,CAAAA,QAAQ,CAAGC,eAAMC,OAAN,CACf,iBAAO,CACLC,MAAM,CAAET,UADH,CAELU,OAAO,CAAE,CAACV,UAFL,CAGLW,cAAc,CAAEX,UAHX,CAAP,EADe,CAMf,CAACA,UAAD,CANe,CAAjB,CASA,GAAMY,CAAAA,KAAK,CAAG,0CAAuBT,YAAvB,CAAd,CAEA,GAAMU,CAAAA,WAAW,CAAG,kBAAeV,YAAf,CAApB,CACA,GAAMW,CAAAA,cAAc,CAAG,kBAAeX,YAAf,CAAvB,CAEA,GAAMY,CAAAA,gBAAgB,CAAGR,eAAMS,WAAN,CAAkB,UAAM,CAC/C,GAAIjB,IAAJ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,CAAG,CAAR,CACEV,IAAI,CAAC,CAAEH,KAAK,CAAEnC,IAAI,CAACI,GAAL,CAAS4C,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,CAIL/B,eAAe,CAAfA,eAJK,CAKLiC,cAAc,CAAE,gCAAMrD,CAAAA,WAAW,CAACW,OAAlB,EALX,CAAP,CAOD","sourcesContent":["import React, { useRef } from \"react\";\nimport type Animated from \"react-native-reanimated\";\nimport {\n runOnJS,\n useAnimatedReaction,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { Easing } from \"../constants\";\nimport type {\n TCarouselActionOptions,\n TCarouselProps,\n WithTimingAnimation,\n} from \"../types\";\nimport { computedRealIndexWithAutoFillData, convertToSharedIndex } from \"../utils/computedWithAutoFillData\";\nimport { dealWithAnimation } from \"../utils/dealWithAnimation\";\nimport { handlerOffsetDirection } from \"../utils/handlerOffsetDirection\";\nimport { round } from \"../utils/log\";\n\ninterface IOpts {\n loop: boolean\n size: number\n dataLength: number\n autoFillData: TCarouselProps[\"autoFillData\"]\n handlerOffset: Animated.SharedValue<number>\n withAnimation?: TCarouselProps[\"withAnimation\"]\n duration?: number\n defaultIndex?: number\n onScrollBegin?: () => void\n onScrollEnd?: () => void\n}\n\nexport interface ICarouselController {\n getSharedIndex: () => number\n prev: (opts?: TCarouselActionOptions) => void\n next: (opts?: TCarouselActionOptions) => void\n getCurrentIndex: () => number\n scrollTo: (opts?: TCarouselActionOptions) => void\n}\n\nexport function useCarouselController(options: IOpts): ICarouselController {\n const {\n size,\n loop,\n dataLength,\n handlerOffset,\n withAnimation,\n defaultIndex = 0,\n duration,\n autoFillData,\n } = options;\n\n const dataInfo = React.useMemo(\n () => ({\n length: dataLength,\n disable: !dataLength,\n originalLength: dataLength,\n }),\n [dataLength],\n );\n\n const index = useSharedValue<number>(defaultIndex);\n // The Index displayed to the user\n const sharedIndex = useRef<number>(defaultIndex);\n const sharedPreIndex = useRef<number>(defaultIndex);\n\n const currentFixedPage = React.useCallback(() => {\n if (loop)\n return -Math.round(handlerOffset.value / size);\n\n const fixed = (handlerOffset.value / size) % dataInfo.length;\n return Math.round(\n handlerOffset.value <= 0\n ? Math.abs(fixed)\n : Math.abs(fixed > 0 ? dataInfo.length - fixed : 0),\n );\n }, [handlerOffset, dataInfo, size, loop]);\n\n function setSharedIndex(newSharedIndex: number) {\n sharedIndex.current = newSharedIndex;\n }\n\n useAnimatedReaction(\n () => {\n const handlerOffsetValue = handlerOffset.value;\n const toInt = round(handlerOffsetValue / size) % dataInfo.length;\n const isPositive = handlerOffsetValue <= 0;\n const i = isPositive\n ? Math.abs(toInt)\n : Math.abs(toInt > 0 ? dataInfo.length - toInt : 0);\n\n const newSharedIndexValue = convertToSharedIndex({\n loop,\n rawDataLength: dataInfo.originalLength,\n autoFillData: autoFillData!,\n index: i,\n });\n\n return {\n i,\n newSharedIndexValue,\n };\n },\n ({ i, newSharedIndexValue }) => {\n index.value = i;\n runOnJS(setSharedIndex)(newSharedIndexValue);\n },\n [\n sharedPreIndex,\n sharedIndex,\n size,\n dataInfo,\n index,\n loop,\n autoFillData,\n handlerOffset,\n ],\n );\n\n const getCurrentIndex = React.useCallback(() => {\n const realIndex = computedRealIndexWithAutoFillData({\n index: index.value,\n dataLength: dataInfo.originalLength,\n loop,\n autoFillData: autoFillData!,\n });\n\n return realIndex;\n }, [index, autoFillData, dataInfo, loop]);\n\n const canSliding = React.useCallback(() => {\n return !dataInfo.disable;\n }, [dataInfo]);\n\n const onScrollEnd = React.useCallback(() => {\n options.onScrollEnd?.();\n }, [options]);\n\n const onScrollBegin = React.useCallback(() => {\n options.onScrollBegin?.();\n }, [options]);\n\n const scrollWithTiming = React.useCallback(\n (toValue: number, onFinished?: () => void) => {\n \"worklet\";\n const callback = (isFinished: boolean) => {\n \"worklet\";\n if (isFinished) {\n runOnJS(onScrollEnd)();\n onFinished && runOnJS(onFinished)();\n }\n };\n\n const defaultWithAnimation: WithTimingAnimation = {\n type: \"timing\",\n config: { duration, easing: Easing.easeOutQuart },\n };\n\n return dealWithAnimation(withAnimation ?? defaultWithAnimation)(\n toValue,\n callback,\n );\n },\n [duration, withAnimation, onScrollEnd],\n );\n\n const next = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n \"worklet\";\n const { count = 1, animated = true, onFinished } = opts;\n if (!canSliding() || (!loop && index.value >= dataInfo.length - 1))\n return;\n\n onScrollBegin?.();\n\n const nextPage = currentFixedPage() + count;\n index.value = nextPage;\n\n if (animated) {\n handlerOffset.value = scrollWithTiming(\n -nextPage * size,\n onFinished,\n ) as any;\n }\n else {\n handlerOffset.value = -nextPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n dataInfo,\n onScrollBegin,\n handlerOffset,\n size,\n scrollWithTiming,\n currentFixedPage,\n ],\n );\n\n const prev = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n const { count = 1, animated = true, onFinished } = opts;\n if (!canSliding() || (!loop && index.value <= 0)) return;\n\n onScrollBegin?.();\n\n const prevPage = currentFixedPage() - count;\n index.value = prevPage;\n\n if (animated) {\n handlerOffset.value = scrollWithTiming(\n -prevPage * size,\n onFinished,\n );\n }\n else {\n handlerOffset.value = -prevPage * size;\n onFinished?.();\n }\n },\n [\n canSliding,\n loop,\n index,\n onScrollBegin,\n handlerOffset,\n size,\n scrollWithTiming,\n currentFixedPage,\n ],\n );\n\n const to = React.useCallback(\n (opts: { i: number; animated: boolean; onFinished?: () => void }) => {\n const { i, animated = false, onFinished } = opts;\n if (i === index.value) return;\n if (!canSliding()) return;\n\n onScrollBegin?.();\n // direction -> 1 | -1\n const direction = handlerOffsetDirection(handlerOffset);\n\n // target offset\n const offset = i * size * direction;\n // page width size * page count\n const totalSize = dataInfo.length * size;\n\n let isCloseToNextLoop = false;\n\n if (loop) {\n isCloseToNextLoop\n = Math.abs(handlerOffset.value % totalSize) / totalSize\n >= 0.5;\n }\n\n const finalOffset\n = (Math.floor(Math.abs(handlerOffset.value / totalSize))\n + (isCloseToNextLoop ? 1 : 0))\n * totalSize\n * direction\n + offset;\n\n if (animated) {\n index.value = i;\n handlerOffset.value = scrollWithTiming(finalOffset, onFinished);\n }\n else {\n handlerOffset.value = finalOffset;\n index.value = i;\n onFinished?.();\n }\n },\n [\n index,\n canSliding,\n onScrollBegin,\n handlerOffset,\n size,\n dataInfo.length,\n loop,\n scrollWithTiming,\n ],\n );\n\n const scrollTo = React.useCallback(\n (opts: TCarouselActionOptions = {}) => {\n const { index: i, count, animated = false, onFinished } = opts;\n if (typeof i === \"number\" && i > -1) {\n to({ i, animated, onFinished });\n return;\n }\n\n if (!count)\n return;\n\n const n = Math.round(count);\n\n if (n < 0)\n prev({ count: Math.abs(n), animated, onFinished });\n\n else\n next({ count: n, animated, onFinished });\n },\n [prev, next, to],\n );\n\n return {\n next,\n prev,\n scrollTo,\n getCurrentIndex,\n getSharedIndex: () => sharedIndex.current,\n };\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useCommonVariables=useCommonVariables;var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=require("react-native-reanimated");var _computeNewIndexWhenDataChanges=require("./computeNewIndexWhenDataChanges");var _handlerOffsetDirection=require("../utils/handlerOffsetDirection");function useCommonVariables(props){var vertical=props.vertical,height=props.height,width=props.width,dataLength=props.dataLength,defaultIndex=props.defaultIndex,defaultScrollOffsetValue=props.defaultScrollOffsetValue,loop=props.loop;var size=vertical?height:width;var validLength=dataLength-1;var defaultHandlerOffsetValue=-Math.abs(defaultIndex*size);var _handlerOffset=(0,_reactNativeReanimated.useSharedValue)(defaultHandlerOffsetValue);var handlerOffset=defaultScrollOffsetValue!=null?defaultScrollOffsetValue:_handlerOffset;var prevDataLength=(0,_reactNativeReanimated.useSharedValue)(dataLength);_react.default.useEffect(function(){handlerOffset.value=defaultHandlerOffsetValue;},[vertical,handlerOffset,defaultHandlerOffsetValue]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){var previousLength=prevDataLength.value;var currentLength=dataLength;var isLengthChanged=previousLength!==currentLength;var shouldComputed=isLengthChanged&&loop;if(shouldComputed)prevDataLength.value=dataLength;return{shouldComputed:shouldComputed,previousLength:previousLength,currentLength:currentLength};};_f._closure={prevDataLength:prevDataLength,dataLength:dataLength,loop:loop};_f.
|
|
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");var _worklet_10652703225927_init_data={code:"function anonymous() {\n const {\n prevDataLength,\n dataLength,\n loop\n } = this._closure;\n const previousLength = prevDataLength.value;\n const currentLength = dataLength;\n const isLengthChanged = previousLength !== currentLength;\n const shouldComputed = isLengthChanged && loop;\n if (shouldComputed) prevDataLength.value = dataLength;\n return {\n shouldComputed: shouldComputed,\n previousLength: previousLength,\n currentLength: currentLength\n };\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCommonVariables.ts",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"prevDataLength\",\"dataLength\",\"loop\",\"_closure\",\"previousLength\",\"value\",\"currentLength\",\"isLengthChanged\",\"shouldComputed\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCommonVariables.ts\"],\"mappings\":\"AAsCsB,SAAAA,SAAMA,CAAA;EAAA;IAAAC,cAAA;IAAAC,UAAA;IAAAC;EAAA,SAAAC,QAAA;EACxB,MAAMC,cAAc,GAAGJ,cAAc,CAACK,KAAK;EAC3C,MAAMC,aAAa,GAAGL,UAAU;EAChC,MAAMM,eAAe,GAAGH,cAAc,KAAKE,aAAa;EACxD,MAAME,cAAc,GAAGD,eAAe,IAAIL,IAAI;EAE9C,IAAIM,cAAc,EAChBR,cAAc,CAACK,KAAK,GAAGJ,UAAU;EAEnC,OAAO;IACLO,cAAc,EAAdA,cAAc;IACdJ,cAAc,EAAdA,cAAc;IACdE,aAAA,EAAAA;EACF,CAAC;AACH\"}"};var _worklet_17314307749108_init_data={code:"function anonymous({\n shouldComputed: shouldComputed,\n previousLength: previousLength,\n currentLength: currentLength\n}) {\n const {\n handlerOffsetDirection,\n handlerOffset,\n computeNewIndexWhenDataChanges,\n size\n } = this._closure;\n if (shouldComputed) {\n const direction = handlerOffsetDirection(handlerOffset);\n handlerOffset.value = computeNewIndexWhenDataChanges({\n direction: direction,\n previousLength: previousLength,\n currentLength: currentLength,\n size: size,\n handlerOffset: handlerOffset.value\n });\n }\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCommonVariables.ts",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"shouldComputed\",\"previousLength\",\"currentLength\",\"handlerOffsetDirection\",\"handlerOffset\",\"computeNewIndexWhenDataChanges\",\"size\",\"_closure\",\"direction\",\"value\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useCommonVariables.ts\"],\"mappings\":\"AAoDK,SAACA,UAAA;EAAEC,cAAc,EAAdA,cAAc;EAAEC,cAAc,EAAdA,cAAc;EAAEC,aAAA,EAAAA;AAAc,CAAC,EAAK;EAAA;IAAAC,sBAAA;IAAAC,aAAA;IAAAC,8BAAA;IAAAC;EAAA,SAAAC,QAAA;EACxD,IAAIP,cAAc,EAAE;IAElB,MAAMQ,SAAS,GAAGL,sBAAsB,CAACC,aAAa,CAAC;IAEvDA,aAAa,CAACK,KAAK,GAAGJ,8BAA8B,CAAC;MACnDG,SAAS,EAATA,SAAS;MACTP,cAAc,EAAdA,cAAc;MACdC,aAAa,EAAbA,aAAa;MACbI,IAAI,EAAJA,IAAI;MACJF,aAAa,EAAEA,aAAa,CAACK;IAC/B,CAAC,CAAC;EACJ;AACF\"}"};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 _e=[new global.Error(),-4,-27];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.__initData=_worklet_10652703225927_init_data;_f.__workletHash=10652703225927;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),function(){var _e=[new global.Error(),-5,-27];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.__initData=_worklet_17314307749108_init_data;_f.__workletHash=17314307749108;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),[dataLength,loop]);return{size:size,validLength:validLength,handlerOffset:handlerOffset};}
|
|
2
2
|
//# sourceMappingURL=useCommonVariables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCommonVariables.ts"],"names":["useCommonVariables","props","vertical","height","width","dataLength","defaultIndex","defaultScrollOffsetValue","loop","size","validLength","defaultHandlerOffsetValue","Math","abs","_handlerOffset","handlerOffset","prevDataLength","React","useEffect","value","previousLength","currentLength","isLengthChanged","shouldComputed","direction","handlerOffsetDirection","computeNewIndexWhenDataChanges"],"mappings":"0LAAA,oDAEA,8DAEA,gFAGA,
|
|
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,uE,y2FAQO,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,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CAElB,GAAMC,CAAAA,SAAS,CAAG,mDAAuBT,aAAvB,CAAlB,CAEAA,aAAa,CAACI,KAAd,CAAsB,mEAA+B,CACnDK,SAAS,CAATA,SADmD,CAEnDJ,cAAc,CAAdA,cAFmD,CAGnDC,aAAa,CAAbA,aAHmD,CAInDZ,IAAI,CAAJA,IAJmD,CAKnDM,aAAa,CAAEA,aAAa,CAACI,KALsB,CAA/B,CAAtB,CAOD,CACF,CA3BD,qCA/BoBM,8CA+BpB,eAzBmBV,aAyBnB,gCA9BwBW,8DA8BxB,MA1BIjB,IA0BJ,0IA2BG,CAACJ,UAAD,CAAaG,IAAb,CA3BH,EA6BA,MAAO,CACLC,IAAI,CAAJA,IADK,CAELC,WAAW,CAAXA,WAFK,CAGLK,aAAa,CAAbA,aAHK,CAAP,CAKD","sourcesContent":["import React from \"react\";\nimport type Animated from \"react-native-reanimated\";\nimport { useSharedValue, useAnimatedReaction } from \"react-native-reanimated\";\n\nimport { computeNewIndexWhenDataChanges } from \"./computeNewIndexWhenDataChanges\";\nimport type { TInitializeCarouselProps } from \"./useInitProps\";\n\nimport { handlerOffsetDirection } from \"../utils/handlerOffsetDirection\";\n\ninterface ICommonVariables {\n size: number\n validLength: number\n handlerOffset: Animated.SharedValue<number>\n}\n\nexport function useCommonVariables(\n props: TInitializeCarouselProps<any>,\n): ICommonVariables {\n const {\n vertical,\n height,\n width,\n dataLength,\n defaultIndex,\n defaultScrollOffsetValue,\n loop,\n } = props;\n const size = vertical ? height : width;\n const validLength = dataLength - 1;\n const defaultHandlerOffsetValue = -Math.abs(defaultIndex * size);\n const _handlerOffset = useSharedValue<number>(defaultHandlerOffsetValue);\n const handlerOffset = defaultScrollOffsetValue ?? _handlerOffset;\n const prevDataLength = useSharedValue(dataLength);\n\n React.useEffect(() => {\n handlerOffset.value = defaultHandlerOffsetValue;\n }, [vertical, handlerOffset, defaultHandlerOffsetValue]);\n\n useAnimatedReaction(() => {\n const previousLength = prevDataLength.value;\n const currentLength = dataLength;\n const isLengthChanged = previousLength !== currentLength;\n const shouldComputed = isLengthChanged && loop;\n\n if (shouldComputed)\n prevDataLength.value = dataLength;\n\n return {\n shouldComputed,\n previousLength,\n currentLength,\n };\n }, ({ shouldComputed, previousLength, currentLength }) => {\n if (shouldComputed) {\n // direction -> 1 | -1\n const direction = handlerOffsetDirection(handlerOffset);\n\n handlerOffset.value = computeNewIndexWhenDataChanges({\n direction,\n previousLength,\n currentLength,\n size,\n handlerOffset: handlerOffset.value,\n });\n }\n }, [dataLength, loop]);\n\n return {\n size,\n validLength,\n handlerOffset,\n };\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useInitProps=useInitProps;var
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useInitProps=useInitProps;var _react=_interopRequireDefault(require("react"));var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");function useInitProps(props){var _props$enableSnap;var _props$defaultIndex=props.defaultIndex,defaultIndex=_props$defaultIndex===void 0?0:_props$defaultIndex,_props$data=props.data,rawData=_props$data===void 0?[]:_props$data,_props$loop=props.loop,loop=_props$loop===void 0?true:_props$loop,_props$autoPlayInterv=props.autoPlayInterval,_autoPlayInterval=_props$autoPlayInterv===void 0?1000:_props$autoPlayInterv,_props$scrollAnimatio=props.scrollAnimationDuration,scrollAnimationDuration=_props$scrollAnimatio===void 0?500:_props$scrollAnimatio,_props$style=props.style,style=_props$style===void 0?{}:_props$style,_props$panGestureHand=props.panGestureHandlerProps,panGestureHandlerProps=_props$panGestureHand===void 0?{}:_props$panGestureHand,_props$autoFillData=props.autoFillData,autoFillData=_props$autoFillData===void 0?true:_props$autoFillData,_props$enabled=props.enabled,enabled=_props$enabled===void 0?true:_props$enabled,_props$pagingEnabled=props.pagingEnabled,pagingEnabled=_props$pagingEnabled===void 0?true:_props$pagingEnabled,_props$overscrollEnab=props.overscrollEnabled,overscrollEnabled=_props$overscrollEnab===void 0?true:_props$overscrollEnab,_props$snapEnabled=props.snapEnabled,snapEnabled=_props$snapEnabled===void 0?(_props$enableSnap=props.enableSnap)!=null?_props$enableSnap:true:_props$snapEnabled,_width=props.width,_height=props.height;var width=Math.round(_width||0);var height=Math.round(_height||0);var autoPlayInterval=Math.max(_autoPlayInterval,0);var data=_react.default.useMemo(function(){return(0,_computedWithAutoFillData.computedFillDataWithAutoFillData)({loop:loop,autoFillData:autoFillData,data:rawData,dataLength:rawData.length});},[rawData,loop,autoFillData]);var dataLength=data.length;var rawDataLength=rawData.length;if(props.mode==="vertical-stack"||props.mode==="horizontal-stack"){var _props$modeConfig$sho,_props$modeConfig;if(!props.modeConfig)props.modeConfig={};props.modeConfig.showLength=(_props$modeConfig$sho=(_props$modeConfig=props.modeConfig)==null?void 0:_props$modeConfig.showLength)!=null?_props$modeConfig$sho:dataLength-1;}return Object.assign({},props,{defaultIndex:defaultIndex,autoFillData:autoFillData,data:data,dataLength:dataLength,rawData:rawData,rawDataLength:rawDataLength,loop:loop,enabled:enabled,autoPlayInterval:autoPlayInterval,scrollAnimationDuration:scrollAnimationDuration,style:style,panGestureHandlerProps:panGestureHandlerProps,pagingEnabled:pagingEnabled,snapEnabled:snapEnabled,overscrollEnabled:overscrollEnabled,width:width,height:height});}
|
|
2
2
|
//# sourceMappingURL=useInitProps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useInitProps.ts"],"names":["useInitProps","props","defaultIndex","data","rawData","loop","autoPlayInterval","_autoPlayInterval","scrollAnimationDuration","style","panGestureHandlerProps","autoFillData","enabled","pagingEnabled","overscrollEnabled","snapEnabled","enableSnap","_width","width","_height","height","Math","round","max","React","useMemo","dataLength","length","rawDataLength","mode","modeConfig","showLength"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["useInitProps.ts"],"names":["useInitProps","props","defaultIndex","data","rawData","loop","autoPlayInterval","_autoPlayInterval","scrollAnimationDuration","style","panGestureHandlerProps","autoFillData","enabled","pagingEnabled","overscrollEnabled","snapEnabled","enableSnap","_width","width","_height","height","Math","round","max","React","useMemo","dataLength","length","rawDataLength","mode","modeConfig","showLength"],"mappings":"8KAAA,oDAGA,2EAuBO,QAASA,CAAAA,YAAT,CACLC,KADK,CAEwB,uBAC7B,wBAgBIA,KAhBJ,CACEC,YADF,CACEA,YADF,8BACiB,CADjB,iCAgBID,KAhBJ,CAEEE,IAFF,CAEQC,OAFR,sBAEkB,EAFlB,yBAgBIH,KAhBJ,CAGEI,IAHF,CAGEA,IAHF,sBAGS,IAHT,mCAgBIJ,KAhBJ,CAIEK,gBAJF,CAIoBC,iBAJpB,gCAIwC,IAJxC,6CAgBIN,KAhBJ,CAKEO,uBALF,CAKEA,uBALF,gCAK4B,GAL5B,oCAgBIP,KAhBJ,CAMEQ,KANF,CAMEA,KANF,uBAMU,EANV,oCAgBIR,KAhBJ,CAOES,sBAPF,CAOEA,sBAPF,gCAO2B,EAP3B,2CAgBIT,KAhBJ,CAQEU,YARF,CAQEA,YARF,8BAQiB,IARjB,oCAgBIV,KAhBJ,CAUEW,OAVF,CAUEA,OAVF,yBAUY,IAVZ,qCAgBIX,KAhBJ,CAWEY,aAXF,CAWEA,aAXF,+BAWkB,IAXlB,4CAgBIZ,KAhBJ,CAYEa,iBAZF,CAYEA,iBAZF,gCAYsB,IAZtB,0CAgBIb,KAhBJ,CAaEc,WAbF,CAaEA,WAbF,gDAagBd,KAAK,CAACe,UAbtB,0BAaoC,IAbpC,oBAcSC,MAdT,CAgBIhB,KAhBJ,CAcEiB,KAdF,CAeUC,OAfV,CAgBIlB,KAhBJ,CAeEmB,MAfF,CAkBA,GAAMF,CAAAA,KAAK,CAAGG,IAAI,CAACC,KAAL,CAAWL,MAAM,EAAI,CAArB,CAAd,CACA,GAAMG,CAAAA,MAAM,CAAGC,IAAI,CAACC,KAAL,CAAWH,OAAO,EAAI,CAA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ED,iBAAiB,CAAjBA,iBApBF,CAqBEI,KAAK,CAALA,KArBF,CAsBEE,MAAM,CAANA,MAtBF,GAwBD","sourcesContent":["import React from \"react\";\n\nimport type { TCarouselProps } from \"../types\";\nimport { computedFillDataWithAutoFillData } from \"../utils/computedWithAutoFillData\";\n\ntype TGetRequiredProps<P extends keyof TCarouselProps> = Record<\nP,\nRequired<TCarouselProps>[P]\n>;\n\nexport type TInitializeCarouselProps<T> = TCarouselProps<T> &\nTGetRequiredProps<\n| \"defaultIndex\"\n| \"loop\"\n| \"width\"\n| \"height\"\n| \"scrollAnimationDuration\"\n| \"autoPlayInterval\"\n| \"autoFillData\"\n> & {\n // Raw data that has not been processed\n rawData: T[]\n dataLength: number\n rawDataLength: number\n};\n\nexport function useInitProps<T>(\n props: TCarouselProps<T>,\n): TInitializeCarouselProps<T> {\n const {\n defaultIndex = 0,\n data: rawData = [],\n loop = true,\n autoPlayInterval: _autoPlayInterval = 1000,\n scrollAnimationDuration = 500,\n style = {},\n panGestureHandlerProps = {},\n autoFillData = true,\n // switchers\n enabled = true,\n pagingEnabled = true,\n overscrollEnabled = true,\n snapEnabled = props.enableSnap ?? true,\n width: _width,\n height: _height,\n } = props;\n\n const width = Math.round(_width || 0);\n const height = Math.round(_height || 0);\n const autoPlayInterval = Math.max(_autoPlayInterval, 0);\n\n const data = React.useMemo<T[]>(\n () => {\n return computedFillDataWithAutoFillData<T>({\n loop,\n autoFillData,\n data: rawData,\n dataLength: rawData.length,\n });\n },\n [rawData, loop, autoFillData],\n );\n\n const dataLength = data.length;\n const rawDataLength = rawData.length;\n\n if (props.mode === \"vertical-stack\" || props.mode === \"horizontal-stack\") {\n if (!props.modeConfig)\n props.modeConfig = {};\n\n props.modeConfig.showLength = props.modeConfig?.showLength ?? dataLength - 1;\n }\n\n return {\n ...props,\n defaultIndex,\n autoFillData,\n // Fill data with autoFillData\n data,\n // Length of fill data\n dataLength,\n // Raw data that has not been processed\n rawData,\n // Length of raw data\n rawDataLength,\n loop,\n enabled,\n autoPlayInterval,\n scrollAnimationDuration,\n style,\n panGestureHandlerProps,\n pagingEnabled,\n snapEnabled,\n overscrollEnabled,\n width,\n height,\n };\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.useOffsetX=void 0;var _reactNativeReanimated=require("react-native-reanimated");var useOffsetX=function useOffsetX(opts,visibleRanges){var handlerOffset=opts.handlerOffset,index=opts.index,size=opts.size,loop=opts.loop,dataLength=opts.dataLength,_opts$type=opts.type,type=_opts$type===void 0?"positive":_opts$type,_viewCount=opts.viewCount;var ITEM_LENGTH=dataLength;var VALID_LENGTH=ITEM_LENGTH-1;var TOTAL_WIDTH=size*ITEM_LENGTH;var HALF_WIDTH=0.5*size;var viewCount=_viewCount!=null?_viewCount:Math.round((ITEM_LENGTH-1)/2);var positiveCount=type==="positive"?viewCount:VALID_LENGTH-viewCount;var startPos=size*index;if(index>positiveCount)startPos=(index-ITEM_LENGTH)*size;var MAX=positiveCount*size;var MIN=-((VALID_LENGTH-positiveCount)*size);var x=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var _visibleRanges$value=visibleRanges.value,negativeRange=_visibleRanges$value.negativeRange,positiveRange=_visibleRanges$value.positiveRange;if((index<negativeRange[0]||index>negativeRange[1])&&(index<positiveRange[0]||index>positiveRange[1]))return Number.MAX_SAFE_INTEGER;if(loop){var inputRange=[-TOTAL_WIDTH,MIN-HALF_WIDTH-startPos-Number.MIN_VALUE,MIN-HALF_WIDTH-startPos,0,MAX+HALF_WIDTH-startPos,MAX+HALF_WIDTH-startPos+Number.MIN_VALUE,TOTAL_WIDTH];var outputRange=[startPos,MAX+HALF_WIDTH-Number.MIN_VALUE,MIN-HALF_WIDTH,startPos,MAX+HALF_WIDTH,MIN-HALF_WIDTH+Number.MIN_VALUE,startPos];return(0,_reactNativeReanimated.interpolate)(handlerOffset.value,inputRange,outputRange,_reactNativeReanimated.Extrapolate.CLAMP);}return handlerOffset.value+size*index;};_f._closure={visibleRanges:visibleRanges,index:index,loop:loop,TOTAL_WIDTH:TOTAL_WIDTH,MIN:MIN,HALF_WIDTH:HALF_WIDTH,startPos:startPos,MAX:MAX,interpolate:_reactNativeReanimated.interpolate,handlerOffset:handlerOffset,Extrapolate:
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useOffsetX=void 0;var _reactNativeReanimated=require("react-native-reanimated");var _worklet_63816918029_init_data={code:"function anonymous() {\n const {\n visibleRanges,\n index,\n loop,\n TOTAL_WIDTH,\n MIN,\n HALF_WIDTH,\n startPos,\n MAX,\n interpolate,\n handlerOffset,\n Extrapolate,\n size\n } = this._closure;\n const {\n negativeRange: negativeRange,\n positiveRange: positiveRange\n } = visibleRanges.value;\n if ((index < negativeRange[0] || index > negativeRange[1]) && (index < positiveRange[0] || index > positiveRange[1])) return Number.MAX_SAFE_INTEGER;\n if (loop) {\n 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];\n const outputRange = [startPos, MAX + HALF_WIDTH - Number.MIN_VALUE, MIN - HALF_WIDTH, startPos, MAX + HALF_WIDTH, MIN - HALF_WIDTH + Number.MIN_VALUE, startPos];\n return interpolate(handlerOffset.value, inputRange, outputRange, Extrapolate.CLAMP);\n }\n return handlerOffset.value + size * index;\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useOffsetX.ts",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"visibleRanges\",\"index\",\"loop\",\"TOTAL_WIDTH\",\"MIN\",\"HALF_WIDTH\",\"startPos\",\"MAX\",\"interpolate\",\"handlerOffset\",\"Extrapolate\",\"size\",\"_closure\",\"negativeRange\",\"positiveRange\",\"value\",\"Number\",\"MAX_SAFE_INTEGER\",\"inputRange\",\"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a,CAACM,KAAK,EACnBG,UAAU,EACVE,WAAW,EACXV,WAAW,CAACW,KACd,CAAC;EACH;EAEA,OAAOZ,aAAa,CAACM,KAAK,GAAGJ,IAAI,GAAGV,KAAK;AAC3C\"}"};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 _e=[new global.Error(),-13,-27];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:_reactNativeReanimated.Extrapolate,size:size};_f.__initData=_worklet_63816918029_init_data;_f.__workletHash=63816918029;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),[loop,dataLength,viewCount,type,size,visibleRanges]);return x;};exports.useOffsetX=useOffsetX;
|
|
2
2
|
//# sourceMappingURL=useOffsetX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useOffsetX.ts"],"names":["useOffsetX","opts","visibleRanges","handlerOffset","index","size","loop","dataLength","type","_viewCount","viewCount","ITEM_LENGTH","VALID_LENGTH","TOTAL_WIDTH","HALF_WIDTH","Math","round","positiveCount","startPos","MAX","MIN","x","value","negativeRange","positiveRange","Number","MAX_SAFE_INTEGER","inputRange","MIN_VALUE","outputRange","Extrapolate","CLAMP","interpolate"],"mappings":"mFACA,
|
|
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,8D,qsFAkBO,GAAMA,CAAAA,UAAU,CAAG,QAAbA,CAAAA,UAAa,CAACC,IAAD,CAAcC,aAAd,CAAgD,CACxE,GACEC,CAAAA,aADF,CAQIF,IARJ,CACEE,aADF,CAEEC,KAFF,CAQIH,IARJ,CAEEG,KAFF,CAGEC,IAHF,CAQIJ,IARJ,CAGEI,IAHF,CAIEC,IAJF,CAQIL,IARJ,CAIEK,IAJF,CAKEC,UALF,CAQIN,IARJ,CAKEM,UALF,YAQIN,IARJ,CAMEO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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,4BA1CNF,aA0CM,OAnC0BE,KAmC1B,MAxCNE,IAwCM,aAvCuLO,WAuCvL,KAtC0GO,GAsC1G,YAtCgHN,UAsChH,UAtC+II,QAsC/I,KAtCwFC,GAsCxF,aArCDa,kCAqCC,eAnCH7B,aAmCG,aArCyD2B,kCAqCzD,MAnCmBzB,IAmCnB,oIAsCP,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");
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useOnProgressChange=useOnProgressChange;var _reactNativeReanimated=require("react-native-reanimated");var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");var _worklet_15415777011180_init_data={code:"function anonymous() {\n const {\n offsetX\n } = this._closure;\n return offsetX.value;\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"offsetX\",\"_closure\",\"value\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts\"],\"mappings\":\"AAsBI,SAAAA,UAAA;EAAA;IAAAC;EAAA,SAAAC,QAAA;EAAA,OAAMD,OAAQ,CAAAE,KAAA;AAAA\"}"};var _worklet_2512862808065_init_data={code:"function anonymous(_value) {\n const {\n computedOffsetXValueWithAutoFillData,\n rawDataLength,\n size,\n autoFillData,\n loop,\n onProgressChange,\n runOnJS\n } = this._closure;\n let value = computedOffsetXValueWithAutoFillData({\n value: _value,\n rawDataLength: rawDataLength,\n size: size,\n autoFillData: autoFillData,\n loop: loop\n });\n if (!loop) {\n value = Math.max(-((rawDataLength - 1) * size), Math.min(value, 0));\n }\n let absoluteProgress = Math.abs(value / size);\n if (value > 0) absoluteProgress = rawDataLength - absoluteProgress;\n if (onProgressChange) runOnJS(onProgressChange)(value, absoluteProgress);\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"_value\",\"computedOffsetXValueWithAutoFillData\",\"rawDataLength\",\"size\",\"autoFillData\",\"loop\",\"onProgressChange\",\"runOnJS\",\"_closure\",\"value\",\"Math\",\"max\",\"min\",\"absoluteProgress\",\"abs\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts\"],\"mappings\":\"AAuBK,SAAAA,SAAMA,CAAKC,MAAA;EAAA;IAAAC,oCAAA;IAAAC,aAAA;IAAAC,IAAA;IAAAC,YAAA;IAAAC,IAAA;IAAAC,gBAAA;IAAAC;EAAA,SAAAC,QAAA;EACV,IAAIC,KAAK,GAAGR,oCAAoC,CAAC;IAC/CQ,KAAK,EAAET,MAAM;IACbE,aAAa,EAAbA,aAAa;IACbC,IAAI,EAAJA,IAAI;IACJC,YAAY,EAAZA,YAAY;IACZC,IAAA,EAAAA;EACF,CAAC,CAAC;EAEF,IAAI,CAACA,IAAI,EAAE;IACTI,KAAK,GAAGC,IAAI,CAACC,GAAG,CACd,EAAE,CAACT,aAAa,GAAG,CAAC,IAAIC,IAAI,CAAC,EAC7BO,IAAI,CAACE,GAAG,CAACH,KAAK,EAAE,CAAC,CACnB,CAAC;EACH;EAEA,IAAII,gBAAgB,GAAGH,IAAI,CAACI,GAAG,CAACL,KAAK,GAAGN,IAAI,CAAC;EAE7C,IAAIM,KAAK,GAAG,CAAC,EACXI,gBAAgB,GAAGX,aAAa,GAAGW,gBAAgB;EAErD,IAAIP,gBAAgB,EAClBC,OAAO,CAACD,gBAAgB,CAAC,CAACG,KAAK,EAAEI,gBAAgB,CAAC;AACtD\"}"};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 _e=[new global.Error(),-2,-27];var _f=function _f(){return offsetX.value;};_f._closure={offsetX:offsetX};_f.__initData=_worklet_15415777011180_init_data;_f.__workletHash=15415777011180;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),function(){var _e=[new global.Error(),-8,-27];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.__initData=_worklet_2512862808065_init_data;_f.__workletHash=2512862808065;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),[loop,autoFillData,rawDataLength,onProgressChange]);}
|
|
2
2
|
//# sourceMappingURL=useOnProgressChange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useOnProgressChange.ts"],"names":["useOnProgressChange","opts","autoFillData","loop","offsetX","size","rawDataLength","onProgressChange","value","_value","Math","max","min","absoluteProgress","abs","computedOffsetXValueWithAutoFillData","runOnJS"],"mappings":"yGACA,8DAMA,
|
|
1
|
+
{"version":3,"sources":["useOnProgressChange.ts"],"names":["useOnProgressChange","opts","autoFillData","loop","offsetX","size","rawDataLength","onProgressChange","value","_value","Math","max","min","absoluteProgress","abs","computedOffsetXValueWithAutoFillData","runOnJS"],"mappings":"yGACA,8DAMA,2E,49EAEO,QAASA,CAAAA,mBAAT,CACLC,IADK,CAQL,CACA,GAAQC,CAAAA,YAAR,CACQD,IADR,CAAQC,YAAR,CAAsBC,IAAtB,CACQF,IADR,CAAsBE,IAAtB,CAA4BC,OAA5B,CACQH,IADR,CAA4BG,OAA5B,CAAqCC,IAArC,CACQJ,IADR,CAAqCI,IAArC,CAA2CC,aAA3C,CACQL,IADR,CAA2CK,aAA3C,CAA0DC,gBAA1D,CACQN,IADR,CAA0DM,gBAA1D,CAGA,oGACE,oBAAMH,CAAAA,OAAO,CAACI,KAAd,EADF,sBArBKJ,OAqBL,2MAEGK,MAFH,CAEc,CACV,GAAID,CAAAA,KAAK,CAAG,mEAAqC,CAC/CA,KAAK,CAAEC,MADwC,CAE/CH,aAAa,CAAbA,aAF+C,CAG/CD,IAAI,CAAJA,IAH+C,CAI/CH,YAAY,CAAZA,YAJ+C,CAK/CC,IAAI,CAAJA,IAL+C,CAArC,CAAZ,CAQA,GAAI,CAACA,IAAL,CAAW,CACTK,KAAK,CAAGE,IAAI,CAACC,GAAL,CACN,EAAE,CAACL,aAAa,CAAG,CAAjB,EAAsBD,IAAxB,CADM,CAENK,IAAI,CAACE,GAAL,CAASJ,KAAT,CAAgB,CAAhB,CAFM,CAAR,CAID,CAED,GAAIK,CAAAA,gBAAgB,CAAGH,IAAI,CAACI,GAAL,CAASN,KAAK,CAAGH,IAAjB,CAAvB,CAEA,GAAIG,KAAK,CAAG,CAAZ,CACEK,gBAAgB,CAAGP,aAAa,CAAGO,gBAAnC,CAEF,GAAIN,gBAAJ,CACE,mCAAQA,gBAAR,EAA0BC,KAA1B,CAAiCK,gBAAjC,EACH,CAzBH,mDApBYE,8DAoBZ,eATkCT,aASlC,MAVwCD,IAUxC,cAhBEH,YAgBF,MAbKC,IAaL,kBAR8BI,gBAQ9B,SARsBS,8BAQtB,wIA0BE,CAACb,IAAD,CAAOD,YAAP,CAAqBI,aAArB,CAAoCC,gBAApC,CA1BF,EA4BD","sourcesContent":["import type Animated from \"react-native-reanimated\";\nimport {\n runOnJS,\n useAnimatedReaction,\n} from \"react-native-reanimated\";\n\nimport type { TCarouselProps } from \"../types\";\nimport { computedOffsetXValueWithAutoFillData } from \"../utils/computedWithAutoFillData\";\n\nexport function useOnProgressChange(\n opts: {\n size: number\n autoFillData: boolean\n loop: boolean\n offsetX: Animated.SharedValue<number>\n rawDataLength: number\n } & Pick<TCarouselProps, \"onProgressChange\">,\n) {\n const { autoFillData, loop, offsetX, size, rawDataLength, onProgressChange }\n = opts;\n\n useAnimatedReaction(\n () => offsetX.value,\n (_value) => {\n let value = computedOffsetXValueWithAutoFillData({\n value: _value,\n rawDataLength,\n size,\n autoFillData,\n loop,\n });\n\n if (!loop) {\n value = Math.max(\n -((rawDataLength - 1) * size),\n Math.min(value, 0),\n );\n }\n\n let absoluteProgress = Math.abs(value / size);\n\n if (value > 0)\n absoluteProgress = rawDataLength - absoluteProgress;\n\n if (onProgressChange)\n runOnJS(onProgressChange)(value, absoluteProgress);\n },\n [loop, autoFillData, rawDataLength, onProgressChange],\n );\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.useVisibleRanges=useVisibleRanges;var _reactNativeReanimated=require("react-native-reanimated");function
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useVisibleRanges=useVisibleRanges;var _reactNativeReanimated=require("react-native-reanimated");var _worklet_1686155145629_init_data={code:"function anonymous() {\n const {\n windowSize,\n translation,\n viewSize,\n total\n } = this._closure;\n const positiveCount = Math.round(windowSize / 2);\n const negativeCount = windowSize - positiveCount;\n let curIndex = Math.round(-translation.value / viewSize);\n curIndex = curIndex < 0 ? curIndex % total + total : curIndex;\n const negativeRange = [(curIndex - negativeCount + total) % total, (curIndex - 1 + total) % total];\n const positiveRange = [(curIndex + total) % total, (curIndex + positiveCount + total) % total];\n if (negativeRange[0] < total && negativeRange[0] > negativeRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n if (positiveRange[0] > positiveRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n return {\n negativeRange: negativeRange,\n positiveRange: positiveRange\n };\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/useVisibleRanges.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"windowSize\",\"translation\",\"viewSize\",\"total\",\"_closure\",\"positiveCount\",\"Math\",\"round\",\"negativeCount\",\"curIndex\",\"value\",\"negativeRange\",\"positiveRange\"],\"sources\":[\"/home/runner/work/react-native-reanimated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AAC;AACzC\"}"};function useVisibleRanges(options){var _options$total=options.total,total=_options$total===void 0?0:_options$total,viewSize=options.viewSize,translation=options.translation,_options$windowSize=options.windowSize,_windowSize=_options$windowSize===void 0?0:_options$windowSize;var windowSize=total<=_windowSize?total:_windowSize;var ranges=(0,_reactNativeReanimated.useDerivedValue)(function(){var _e=[new global.Error(),-5,-27];var _f=function _f(){var positiveCount=Math.round(windowSize/2);var negativeCount=windowSize-positiveCount;var curIndex=Math.round(-translation.value/viewSize);curIndex=curIndex<0?curIndex%total+total:curIndex;var negativeRange=[(curIndex-negativeCount+total)%total,(curIndex-1+total)%total];var positiveRange=[(curIndex+total)%total,(curIndex+positiveCount+total)%total];if(negativeRange[0]<total&&negativeRange[0]>negativeRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}if(positiveRange[0]>positiveRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}return{negativeRange:negativeRange,positiveRange:positiveRange};};_f._closure={windowSize:windowSize,translation:translation,viewSize:viewSize,total:total};_f.__initData=_worklet_1686155145629_init_data;_f.__workletHash=1686155145629;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),[total,windowSize,translation]);return ranges;}
|
|
2
2
|
//# sourceMappingURL=useVisibleRanges.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useVisibleRanges.tsx"],"names":["useVisibleRanges","options","total","viewSize","translation","windowSize","_windowSize","ranges","positiveCount","Math","round","negativeCount","curIndex","value","negativeRange","positiveRange"],"mappings":"mGACA,
|
|
1
|
+
{"version":3,"sources":["useVisibleRanges.tsx"],"names":["useVisibleRanges","options","total","viewSize","translation","windowSize","_windowSize","ranges","positiveCount","Math","round","negativeCount","curIndex","value","negativeRange","positiveRange"],"mappings":"mGACA,8D,m5EAOO,QAASA,CAAAA,gBAAT,CAA0BC,OAA1B,CAKY,CACjB,mBAKIA,OALJ,CACEC,KADF,CACEA,KADF,yBACU,CADV,gBAEEC,QAFF,CAKIF,OALJ,CAEE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AAmBZ,KAAK,CAAG,CAA3B,CACAa,aAAa,CAAC,CAAD,CAAb,CAAmB,CAAnB,CACD,CACD,MAAO,CAAED,aAAa,CAAbA,aAAF,CAAiBC,aAAa,CAAbA,aAAjB,CAAP,CACD,CAtBc,yBArBOV,UAqBP,aApBYD,WAoBZ,UApBgCD,QAoBhC,OAXMD,KAWN,wIAsBZ,CAACA,KAAD,CAAQG,UAAR,CAAoBD,WAApB,CAtBY,CAAf,CAwBA,MAAOG,CAAAA,MAAP,CACD","sourcesContent":["import type Animated from \"react-native-reanimated\";\nimport { useDerivedValue } from \"react-native-reanimated\";\n\nexport type IVisibleRanges = Animated.SharedValue<{\n negativeRange: number[]\n positiveRange: number[]\n}>;\n\nexport function useVisibleRanges(options: {\n total: number\n viewSize: number\n windowSize?: number\n translation: Animated.SharedValue<number>\n}): IVisibleRanges {\n const {\n total = 0,\n viewSize,\n translation,\n windowSize: _windowSize = 0,\n } = options;\n\n const windowSize = total <= _windowSize ? total : _windowSize;\n\n const ranges = useDerivedValue(() => {\n const positiveCount = Math.round(windowSize / 2);\n const negativeCount = windowSize - positiveCount;\n let curIndex = Math.round(-translation.value / viewSize);\n curIndex = curIndex < 0 ? (curIndex % total) + total : curIndex;\n const negativeRange = [\n (curIndex - negativeCount + total) % total,\n (curIndex - 1 + total) % total,\n ];\n const positiveRange = [\n (curIndex + total) % total,\n (curIndex + positiveCount + total) % total,\n ];\n if (negativeRange[0] < total && negativeRange[0] > negativeRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n if (positiveRange[0] > positiveRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n return { negativeRange, positiveRange };\n }, [total, windowSize, translation]);\n\n return ranges;\n}\n"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _Carousel=_interopRequireDefault(require("./Carousel"));var _default=_Carousel.default;exports.default=_default;
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"ILayoutConfig",{enumerable:true,get:function get(){return _stack.ILayoutConfig;}});exports.default=void 0;var _Carousel=_interopRequireDefault(require("./Carousel"));var _stack=require("./layouts/stack");var _default=_Carousel.default;exports.default=_default;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["Carousel"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["Carousel"],"mappings":"qRAAA,4DAOA,sC,aAEeA,iB","sourcesContent":["import Carousel from \"./Carousel\";\nexport type {\n TCarouselProps,\n ICarouselInstance,\n IComputedDirectionTypes,\n CarouselRenderItem,\n} from \"./types\";\nexport { ILayoutConfig } from \"./layouts/stack\";\n\nexport default Carousel;\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.BaseLayout=void 0;var
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.BaseLayout=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useCheckMounted=require("../hooks/useCheckMounted");var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _store=require("../store");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var _worklet_3217166169285_init_data={code:"function anonymous() {\n const {\n x,\n size\n } = this._closure;\n return x.value / size;\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"x\",\"size\",\"_closure\",\"value\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx\"],\"mappings\":\"AAyEyC,SAAAA,UAAA;EAAA;IAAAC,CAAA;IAAAC;EAAA,SAAAC,QAAA;EAAA,OAAOF,CAAC,CAAAG,KAAK,GAAGF,IAAA;AAAA\"}"};var _worklet_11301275444738_init_data={code:"function anonymous() {\n const {\n animationStyle,\n x,\n size\n } = this._closure;\n return animationStyle(x.value / size);\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"animationStyle\",\"x\",\"size\",\"_closure\",\"value\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx\"],\"mappings\":\"AA2EI,SAAAA,UAAA;EAAA;IAAAC,cAAA;IAAAC,CAAA;IAAAC;EAAA,SAAAC,QAAA;EAAA,OAAMH,cAAe,CAACC,CAAC,CAAAG,KAAK,GAAGF,IAAI;AAAA\"}"};var _worklet_11113070436332_init_data={code:"function anonymous() {\n const {\n visibleRanges\n } = this._closure;\n return visibleRanges.value;\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"visibleRanges\",\"_closure\",\"value\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx\"],\"mappings\":\"AA2FI,SAAAA,UAAA;EAAA;IAAAC;EAAA,SAAAC,QAAA;EAAA,OAAMD,aAAc,CAAAE,KAAA;AAAA\"}"};var _worklet_15128277149381_init_data={code:"function anonymous() {\n const {\n runOnJS,\n updateView,\n visibleRanges\n } = this._closure;\n runOnJS(updateView)(visibleRanges.value.negativeRange, visibleRanges.value.positiveRange);\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"runOnJS\",\"updateView\",\"visibleRanges\",\"_closure\",\"value\",\"negativeRange\",\"positiveRange\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx\"],\"mappings\":\"AA4FI,SAAAA,SAAMA,CAAA;EAAA;IAAAC,OAAA;IAAAC,UAAA;IAAAC;EAAA,SAAAC,QAAA;EACJH,OAAO,CAACC,UAAU,CAAC,CACjBC,aAAa,CAACE,KAAK,CAACC,aAAa,EACjCH,aAAa,CAACE,KAAK,CAACE,aACtB,CAAC;AACH\"}"};var BaseLayout=function BaseLayout(props){var mounted=(0,_useCheckMounted.useCheckMounted)();var handlerOffset=props.handlerOffset,index=props.index,children=props.children,visibleRanges=props.visibleRanges,animationStyle=props.animationStyle;var context=_react.default.useContext(_store.CTX);var _context$props=context.props,loop=_context$props.loop,dataLength=_context$props.dataLength,width=_context$props.width,height=_context$props.height,vertical=_context$props.vertical,customConfig=_context$props.customConfig,mode=_context$props.mode,modeConfig=_context$props.modeConfig;var size=vertical?height:width;var _React$useState=_react.default.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),shouldUpdate=_React$useState2[0],setShouldUpdate=_React$useState2[1];var offsetXConfig=Object.assign({handlerOffset:handlerOffset,index:index,size:size,dataLength:dataLength,loop:loop},typeof customConfig==="function"?customConfig():{});if(mode==="horizontal-stack"){var _ref=modeConfig,snapDirection=_ref.snapDirection,showLength=_ref.showLength;offsetXConfig={handlerOffset:handlerOffset,index:index,size:size,dataLength:dataLength,loop:loop,type:snapDirection==="right"?"negative":"positive",viewCount:showLength};}var x=(0,_useOffsetX.useOffsetX)(offsetXConfig,visibleRanges);var animationValue=(0,_reactNativeReanimated.useDerivedValue)(function(){var _e=[new global.Error(),-3,-27];var _f=function _f(){return x.value/size;};_f._closure={x:x,size:size};_f.__initData=_worklet_3217166169285_init_data;_f.__workletHash=3217166169285;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),[x,size]);var animatedStyle=(0,_reactNativeReanimated.useAnimatedStyle)(function(){var _e=[new global.Error(),-4,-27];var _f=function _f(){return animationStyle(x.value/size);};_f._closure={animationStyle:animationStyle,x:x,size:size};_f.__initData=_worklet_11301275444738_init_data;_f.__workletHash=11301275444738;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),[animationStyle]);var updateView=_react.default.useCallback(function(negativeRange,positiveRange){mounted.current&&setShouldUpdate(index>=negativeRange[0]&&index<=negativeRange[1]||index>=positiveRange[0]&&index<=positiveRange[1]);},[index,mounted]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _e=[new global.Error(),-2,-27];var _f=function _f(){return visibleRanges.value;};_f._closure={visibleRanges:visibleRanges};_f.__initData=_worklet_11113070436332_init_data;_f.__workletHash=11113070436332;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),function(){var _e=[new global.Error(),-4,-27];var _f=function _f(){(0,_reactNativeReanimated.runOnJS)(updateView)(visibleRanges.value.negativeRange,visibleRanges.value.positiveRange);};_f._closure={runOnJS:_reactNativeReanimated.runOnJS,updateView:updateView,visibleRanges:visibleRanges};_f.__initData=_worklet_15128277149381_init_data;_f.__workletHash=15128277149381;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),[visibleRanges.value]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{width:width||"100%",height:height||"100%",position:"absolute"},animatedStyle],testID:`__CAROUSEL_ITEM_${index}_${shouldUpdate?"READY":"NOT_READY"}__`,children:(0,_jsxRuntime.jsx)(_LazyView.LazyView,{shouldUpdate:shouldUpdate,children:children({animationValue:animationValue})})});};exports.BaseLayout=BaseLayout;
|
|
2
2
|
//# sourceMappingURL=BaseLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["BaseLayout.tsx"],"names":["BaseLayout","props","mounted","handlerOffset","index","children","visibleRanges","animationStyle","context","React","useContext","CTX","loop","dataLength","width","height","vertical","customConfig","mode","modeConfig","size","useState","shouldUpdate","setShouldUpdate","offsetXConfig","snapDirection","showLength","type","viewCount","x","animationValue","value","animatedStyle","updateView","useCallback","negativeRange","positiveRange","current","runOnJS","position"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["BaseLayout.tsx"],"names":["BaseLayout","props","mounted","handlerOffset","index","children","visibleRanges","animationStyle","context","React","useContext","CTX","loop","dataLength","width","height","vertical","customConfig","mode","modeConfig","size","useState","shouldUpdate","setShouldUpdate","offsetXConfig","snapDirection","showLength","type","viewCount","x","animationValue","value","animatedStyle","updateView","useCallback","negativeRange","positiveRange","current","runOnJS","position"],"mappings":"kQAAA,oDAGA,uFASA,yDAEA,+CAEA,qCACA,+B,22HAIO,GAAMA,CAAAA,UAQX,CAAG,QARQA,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D3B,aAyFvD,0IAQE,CAACA,aAAa,CAACyB,KAAf,CARF,EAWA,MACE,oBAAC,8BAAD,CAAU,IAAV,EACE,KAAK,CAAE,CACL,CACEjB,KAAK,CAAEA,KAAK,EAAI,MADlB,CAEEC,MAAM,CAAEA,MAAM,EAAI,MAFpB,CAGEwB,QAAQ,CAAE,UAHZ,CADK,CAMLP,aANK,CADT,CAcE,MAAM,CAAG,mBAAkB5B,KAAM,IAAGkB,YAAY,CAAG,OAAH,CAAa,WAAY,IAd3E,UAgBE,oBAAC,kBAAD,EAAU,YAAY,CAAEA,YAAxB,UACGjB,QAAQ,CAAC,CAAEyB,cAAc,CAAdA,cAAF,CAAD,CADX,EAhBF,EADF,CAsBD,CAtGM,C","sourcesContent":["import React from \"react\";\nimport type { ViewStyle } from \"react-native\";\nimport type { AnimatedStyleProp } from \"react-native-reanimated\";\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n useDerivedValue,\n} from \"react-native-reanimated\";\n\nimport type { ILayoutConfig } from \"./stack\";\n\nimport { useCheckMounted } from \"../hooks/useCheckMounted\";\nimport type { IOpts } from \"../hooks/useOffsetX\";\nimport { useOffsetX } from \"../hooks/useOffsetX\";\nimport type { IVisibleRanges } from \"../hooks/useVisibleRanges\";\nimport { LazyView } from \"../LazyView\";\nimport { CTX } from \"../store\";\n\nexport type TAnimationStyle = (value: number) => AnimatedStyleProp<ViewStyle>;\n\nexport const BaseLayout: React.FC<{\n index: number\n handlerOffset: Animated.SharedValue<number>\n visibleRanges: IVisibleRanges\n animationStyle: TAnimationStyle\n children: (ctx: {\n animationValue: Animated.SharedValue<number>\n }) => React.ReactElement\n}> = (props) => {\n const mounted = useCheckMounted();\n const { handlerOffset, index, children, visibleRanges, animationStyle }\n = props;\n\n const context = React.useContext(CTX);\n const {\n props: {\n loop,\n dataLength,\n width,\n height,\n vertical,\n customConfig,\n mode,\n modeConfig,\n },\n } = context;\n const size = vertical ? height : width;\n const [shouldUpdate, setShouldUpdate] = React.useState(false);\n let offsetXConfig: IOpts = {\n handlerOffset,\n index,\n size,\n dataLength,\n loop,\n ...(typeof customConfig === \"function\" ? customConfig() : {}),\n };\n\n if (mode === \"horizontal-stack\") {\n const { snapDirection, showLength } = modeConfig as ILayoutConfig;\n\n offsetXConfig = {\n handlerOffset,\n index,\n size,\n dataLength,\n loop,\n type: snapDirection === \"right\" ? \"negative\" : \"positive\",\n viewCount: showLength,\n };\n }\n\n const x = useOffsetX(offsetXConfig, visibleRanges);\n const animationValue = useDerivedValue(() => x.value / size, [x, size]);\n const animatedStyle = useAnimatedStyle(\n () => animationStyle(x.value / size),\n [animationStyle],\n );\n\n const updateView = React.useCallback(\n (negativeRange: number[], positiveRange: number[]) => {\n mounted.current\n && setShouldUpdate(\n (index >= negativeRange[0] && index <= negativeRange[1])\n || (index >= positiveRange[0] && index <= positiveRange[1]),\n );\n },\n [index, mounted],\n );\n\n useAnimatedReaction(\n () => visibleRanges.value,\n () => {\n runOnJS(updateView)(\n visibleRanges.value.negativeRange,\n visibleRanges.value.positiveRange,\n );\n },\n [visibleRanges.value],\n );\n\n return (\n <Animated.View\n style={[\n {\n width: width || \"100%\",\n height: height || \"100%\",\n position: \"absolute\",\n },\n animatedStyle,\n ]}\n /**\n * We use this testID to know when the carousel item is ready to be tested in test.\n * e.g.\n * The testID of first item will be changed to __CAROUSEL_ITEM_0_READY__ from __CAROUSEL_ITEM_0_NOT_READY__ when the item is ready.\n * */\n testID={`__CAROUSEL_ITEM_${index}_${shouldUpdate ? \"READY\" : \"NOT_READY\"}__`}\n >\n <LazyView shouldUpdate={shouldUpdate}>\n {children({ animationValue })}\n </LazyView>\n </Animated.View>\n );\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ParallaxLayout=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _this=this,_jsxFileName="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var ParallaxLayout=function ParallaxLayout(props){var handlerOffset=props.handlerOffset,_props$parallaxScroll=props.parallaxScrollingOffset,parallaxScrollingOffset=_props$parallaxScroll===void 0?100:_props$parallaxScroll,_props$parallaxScroll2=props.parallaxScrollingScale,parallaxScrollingScale=_props$parallaxScroll2===void 0?0.8:_props$parallaxScroll2,_props$parallaxAdjace=props.parallaxAdjacentItemScale,parallaxAdjacentItemScale=_props$parallaxAdjace===void 0?
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ParallaxLayout=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var _worklet_2396750619736_init_data={code:"function anonymous() {\n const {\n x,\n size,\n interpolate,\n parallaxScrollingOffset,\n Extrapolate,\n parallaxAdjacentItemScale,\n parallaxScrollingScale,\n vertical\n } = this._closure;\n const value = x.value / size;\n const translate = interpolate(value, [-1, 0, 1], [-size + parallaxScrollingOffset, 0, size - parallaxScrollingOffset], Extrapolate.EXTEND);\n const zIndex = interpolate(value, [-1, 0, 1], [0, size, 0], Extrapolate.CLAMP);\n const scale = interpolate(value, [-1, 0, 1], [parallaxAdjacentItemScale, parallaxScrollingScale, parallaxAdjacentItemScale], Extrapolate.CLAMP);\n return {\n transform: [vertical ? {\n translateY: translate\n } : {\n translateX: translate\n }, {\n scale: scale\n }],\n zIndex: zIndex\n };\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"x\",\"size\",\"interpolate\",\"parallaxScrollingOffset\",\"Extrapolate\",\"parallaxAdjacentItemScale\",\"parallaxScrollingScale\",\"vertical\",\"_closure\",\"value\",\"translate\",\"EXTEND\",\"zIndex\",\"CLAMP\",\"scale\",\"transform\",\"translateY\",\"translateX\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx\"],\"mappings\":\"AAwDwC,SAAAA,SAAMA,CAAA;EAAA;IAAAC,CAAA;IAAAC,IAAA;IAAAC,WAAA;IAAAC,uBAAA;IAAAC,WAAA;IAAAC,yBAAA;IAAAC,sBAAA;IAAAC;EAAA,SAAAC,QAAA;EAC1C,MAAMC,KAAK,GAAGT,CAAC,CAACS,KAAK,GAAGR,IAAI;EAE5B,MAAMS,SAAS,GAAGR,WAAW,CAC3BO,KAAK,EACL,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACV,CACE,CAACR,IAAI,GAAGE,uBAAuB,EAC/B,CAAC,EACDF,IAAI,GAAGE,uBAAuB,CAC/B,EACDC,WAAW,CAACO,MACd,CAAC;EAED,MAAMC,MAAM,GAAGV,WAAW,CACxBO,KAAK,EACL,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACV,CAAC,CAAC,EAAER,IAAI,EAAE,CAAC,CAAC,EACZG,WAAW,CAACS,KACd,CAAC;EAED,MAAMC,KAAK,GAAGZ,WAAW,CACvBO,KAAK,EACL,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACV,CACEJ,yBAAyB,EACzBC,sBAAsB,EACtBD,yBAAyB,CAC1B,EACDD,WAAW,CAACS,KACd,CAAC;EAED,OAAO;IACLE,SAAS,EAAE,CACTR,QAAQ,GACJ;MACAS,UAAU,EAAEN;IACd,CAAC,GACC;MACAO,UAAU,EAAEP;IACd,CAAC,EACH;MACEI,KAAA,EAAAA;IACF,CAAC,CACF;IACDF,MAAA,EAAAA;EACF,CAAC;AACH\"}"};var _worklet_11113070436332_init_data={code:"function anonymous() {\n const {\n visibleRanges\n } = this._closure;\n return visibleRanges.value;\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"visibleRanges\",\"_closure\",\"value\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx\"],\"mappings\":\"AAoHI,SAAAA,UAAA;EAAA;IAAAC;EAAA,SAAAC,QAAA;EAAA,OAAMD,aAAc,CAAAE,KAAA;AAAA\"}"};var _worklet_15128277149381_init_data={code:"function anonymous() {\n const {\n runOnJS,\n updateView,\n visibleRanges\n } = this._closure;\n runOnJS(updateView)(visibleRanges.value.negativeRange, visibleRanges.value.positiveRange);\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx",sourceMap:"{\"version\":3,\"names\":[\"anonymous\",\"runOnJS\",\"updateView\",\"visibleRanges\",\"_closure\",\"value\",\"negativeRange\",\"positiveRange\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx\"],\"mappings\":\"AAqHI,SAAAA,SAAMA,CAAA;EAAA;IAAAC,OAAA;IAAAC,UAAA;IAAAC;EAAA,SAAAC,QAAA;EACJH,OAAO,CAACC,UAAU,CAAC,CACjBC,aAAa,CAACE,KAAK,CAACC,aAAa,EACjCH,aAAa,CAACE,KAAK,CAACE,aACtB,CAAC;AACH\"}"};var ParallaxLayout=function ParallaxLayout(props){var handlerOffset=props.handlerOffset,_props$parallaxScroll=props.parallaxScrollingOffset,parallaxScrollingOffset=_props$parallaxScroll===void 0?100:_props$parallaxScroll,_props$parallaxScroll2=props.parallaxScrollingScale,parallaxScrollingScale=_props$parallaxScroll2===void 0?0.8:_props$parallaxScroll2,_props$parallaxAdjace=props.parallaxAdjacentItemScale,parallaxAdjacentItemScale=_props$parallaxAdjace===void 0?parallaxScrollingScale**2:_props$parallaxAdjace,index=props.index,width=props.width,height=props.height,loop=props.loop,dataLength=props.dataLength,children=props.children,visibleRanges=props.visibleRanges,vertical=props.vertical;var _React$useState=_react.default.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),shouldUpdate=_React$useState2[0],setShouldUpdate=_React$useState2[1];var size=props.vertical?props.height:props.width;var x=(0,_useOffsetX.useOffsetX)({handlerOffset:handlerOffset,index:index,size:size,dataLength:dataLength,loop:loop},visibleRanges);var offsetXStyle=(0,_reactNativeReanimated.useAnimatedStyle)(function(){var _e=[new global.Error(),-9,-27];var _f=function _f(){var value=x.value/size;var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset],_reactNativeReanimated.Extrapolate.EXTEND);var zIndex=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[0,size,0],_reactNativeReanimated.Extrapolate.CLAMP);var scale=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],_reactNativeReanimated.Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};};_f._closure={x:x,size:size,interpolate:_reactNativeReanimated.interpolate,parallaxScrollingOffset:parallaxScrollingOffset,Extrapolate:_reactNativeReanimated.Extrapolate,parallaxAdjacentItemScale:parallaxAdjacentItemScale,parallaxScrollingScale:parallaxScrollingScale,vertical:vertical};_f.__initData=_worklet_2396750619736_init_data;_f.__workletHash=2396750619736;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),[loop,vertical,parallaxScrollingOffset]);var updateView=_react.default.useCallback(function(negativeRange,positiveRange){setShouldUpdate(index>=negativeRange[0]&&index<=negativeRange[1]||index>=positiveRange[0]&&index<=positiveRange[1]);},[index]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _e=[new global.Error(),-2,-27];var _f=function _f(){return visibleRanges.value;};_f._closure={visibleRanges:visibleRanges};_f.__initData=_worklet_11113070436332_init_data;_f.__workletHash=11113070436332;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),function(){var _e=[new global.Error(),-4,-27];var _f=function _f(){(0,_reactNativeReanimated.runOnJS)(updateView)(visibleRanges.value.negativeRange,visibleRanges.value.positiveRange);};_f._closure={runOnJS:_reactNativeReanimated.runOnJS,updateView:updateView,visibleRanges:visibleRanges};_f.__initData=_worklet_15128277149381_init_data;_f.__workletHash=15128277149381;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}(),[visibleRanges.value]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{width:width||"100%",height:height||"100%",position:"absolute"},offsetXStyle],children:(0,_jsxRuntime.jsx)(_LazyView.LazyView,{shouldUpdate:shouldUpdate,children:children})});};exports.ParallaxLayout=ParallaxLayout;
|
|
2
2
|
//# sourceMappingURL=ParallaxLayout.js.map
|