UNPKG

react-native-reanimated-carousel

Version:

Simple carousel component.fully implemented using Reanimated 2.Infinitely scrolling, very smooth.

2 lines 5.57 kB
Object.defineProperty(exports,"__esModule",{value:true});exports.omitZero=exports.computeNewIndexWhenDataChanges=void 0;var _worklet_2585996741034_init_data={code:"function omitZero(a, b) {\n if (a === 0) return 0;\n return b;\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/computeNewIndexWhenDataChanges.ts",sourceMap:"{\"version\":3,\"names\":[\"omitZero\",\"a\",\"b\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/computeNewIndexWhenDataChanges.ts\"],\"mappings\":\"AAAO,SAAAA,QAASA,CAASC,CAAC,EAAQC,CAAG,EAAQ;EAE3C,IAAID,CAAC,KAAK,CAAC,EACT,OAAO,CAAC;EAEV,OAAOC,CAAC;AACV\"}"};var omitZero=function(){var _e=[new global.Error(),1,-27];var _f=function _f(a,b){if(a===0)return 0;return b;};_f._closure={};_f.__initData=_worklet_2585996741034_init_data;_f.__workletHash=2585996741034;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}();exports.omitZero=omitZero;var _worklet_1218774587822_init_data={code:"function computeNewIndexWhenDataChanges(params) {\n const {\n omitZero\n } = this._closure;\n const {\n direction: direction,\n handlerOffset: _handlerOffset,\n size: size,\n previousLength: previousLength,\n currentLength: currentLength\n } = params;\n let handlerOffset = _handlerOffset;\n let positionIndex;\n let round;\n const isPositive = direction < 0;\n if (isPositive) {\n positionIndex = Math.abs(handlerOffset) / size;\n round = parseInt(String(omitZero(previousLength, positionIndex / previousLength)));\n } else {\n positionIndex = (Math.abs(handlerOffset) - size) / size;\n round = parseInt(String(omitZero(previousLength, positionIndex / previousLength))) + 1;\n }\n const prevOffset = omitZero(previousLength, positionIndex % previousLength);\n const prevIndex = isPositive ? prevOffset : previousLength - prevOffset - 1;\n const changedLength = round * (currentLength - previousLength);\n const changedOffset = changedLength * size;\n if (prevIndex > currentLength - 1 && currentLength < previousLength) {\n if (isPositive) handlerOffset = (currentLength - 1) * size * direction;else handlerOffset = (currentLength - 1) * size * -1;\n } else {\n handlerOffset += changedOffset * direction;\n }\n return handlerOffset;\n}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/computeNewIndexWhenDataChanges.ts",sourceMap:"{\"version\":3,\"names\":[\"computeNewIndexWhenDataChanges\",\"params\",\"omitZero\",\"_closure\",\"direction\",\"handlerOffset\",\"_handlerOffset\",\"size\",\"previousLength\",\"currentLength\",\"positionIndex\",\"round\",\"isPositive\",\"Math\",\"abs\",\"parseInt\",\"String\",\"prevOffset\",\"prevIndex\",\"changedLength\",\"changedOffset\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/hooks/computeNewIndexWhenDataChanges.ts\"],\"mappings\":\"AAQO,SAAAA,8BAASA,CAA+BC,MAAA,EAM9C;EAAA;IAAAC;EAAA,SAAAC,QAAA;EAEC,MAAM;IAAEC,SAAS,EAATA,SAAS;IAAEC,aAAa,EAAEC,cAAc;IAAEC,IAAI,EAAJA,IAAI;IAAEC,cAAc,EAAdA,cAAc;IAAEC,aAAA,EAAAA;EAAc,CAAC,GAAGR,MAAM;EAEhG,IAAII,aAAa,GAAGC,cAAc;EAClC,IAAII,aAAa;EACjB,IAAIC,KAAK;EAET,MAAMC,UAAU,GAAGR,SAAS,GAAG,CAAC;EAEhC,IAAIQ,UAAU,EAAE;IACdF,aAAa,GAAIG,IAAI,CAACC,GAAG,CAACT,aAAa,CAAC,GAAIE,IAAI;IAChDI,KAAK,GAAGI,QAAQ,CAACC,MAAM,CAACd,QAAQ,CAACM,cAAc,EAAEE,aAAa,GAAGF,cAAc,CAAC,CAAC,CAAC;EACpF,CAAC,MACI;IACHE,aAAa,GAAG,CAACG,IAAI,CAACC,GAAG,CAACT,aAAa,CAAC,GAAGE,IAAI,IAAIA,IAAI;IACvDI,KAAK,GAAGI,QAAQ,CAACC,MAAM,CAACd,QAAQ,CAACM,cAAc,EAAEE,aAAa,GAAGF,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC;EACxF;EAEA,MAAMS,UAAU,GAAGf,QAAQ,CAACM,cAAc,EAAEE,aAAa,GAAGF,cAAc,CAAC;EAC3E,MAAMU,SAAS,GAAGN,UAAU,GAAGK,UAAU,GAAGT,cAAc,GAAGS,UAAU,GAAG,CAAC;EAC3E,MAAME,aAAa,GAAGR,KAAK,IAAIF,aAAa,GAAGD,cAAc,CAAC;EAC9D,MAAMY,aAAa,GAAGD,aAAa,GAAGZ,IAAI;EAC1C,IAAIW,SAAS,GAAGT,aAAa,GAAG,CAAC,IAAIA,aAAa,GAAGD,cAAc,EAAE;IACnE,IAAII,UAAU,EACZP,aAAa,GAAG,CAACI,aAAa,GAAG,CAAC,IAAIF,IAAI,GAAGH,SAAS,CAAC,KAGvDC,aAAa,GAAG,CAACI,aAAa,GAAG,CAAC,IAAIF,IAAI,GAAG,CAAC,CAAC;EACnD,CAAC,MACI;IACHF,aAAa,IAAIe,aAAa,GAAGhB,SAAS;EAC5C;EAEA,OAAOC,aAAa;AACtB\"}"};var computeNewIndexWhenDataChanges=function(){var _e=[new global.Error(),-2,-27];var _f=function _f(params){var direction=params.direction,_handlerOffset=params.handlerOffset,size=params.size,previousLength=params.previousLength,currentLength=params.currentLength;var handlerOffset=_handlerOffset;var positionIndex;var round;var isPositive=direction<0;if(isPositive){positionIndex=Math.abs(handlerOffset)/size;round=parseInt(String(omitZero(previousLength,positionIndex/previousLength)));}else{positionIndex=(Math.abs(handlerOffset)-size)/size;round=parseInt(String(omitZero(previousLength,positionIndex/previousLength)))+1;}var prevOffset=omitZero(previousLength,positionIndex%previousLength);var prevIndex=isPositive?prevOffset:previousLength-prevOffset-1;var changedLength=round*(currentLength-previousLength);var changedOffset=changedLength*size;if(prevIndex>currentLength-1&&currentLength<previousLength){if(isPositive)handlerOffset=(currentLength-1)*size*direction;else handlerOffset=(currentLength-1)*size*-1;}else{handlerOffset+=changedOffset*direction;}return handlerOffset;};_f._closure={omitZero:omitZero};_f.__initData=_worklet_1218774587822_init_data;_f.__workletHash=1218774587822;_f.__stackDetails=_e;_f.__version="3.3.0";return _f;}();exports.computeNewIndexWhenDataChanges=computeNewIndexWhenDataChanges; //# sourceMappingURL=computeNewIndexWhenDataChanges.js.map