react-native-reanimated-carousel 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- 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/constants/index.js.map +1 -1
- package/lib/commonjs/hooks/computeNewIndexWhenDataChanges.js +2 -0
- package/lib/commonjs/hooks/computeNewIndexWhenDataChanges.js.map +1 -0
- package/lib/commonjs/hooks/index.test.js +2 -0
- package/lib/commonjs/hooks/index.test.js.map +1 -0
- package/lib/commonjs/hooks/useAutoPlay.js +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/useCheckMounted.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/useLayoutConfig.js +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -1
- package/lib/commonjs/hooks/useOffsetX.js +1 -1
- package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
- package/lib/commonjs/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/index.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/store/index.js.map +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 +2 -0
- package/lib/commonjs/utils/handlerOffsetDirection.js.map +1 -0
- package/lib/commonjs/utils/log.js +1 -1
- package/lib/commonjs/utils/log.js.map +1 -1
- package/lib/module/Carousel.js +24 -33
- package/lib/module/Carousel.js.map +1 -1
- package/lib/module/LazyView.js +2 -6
- package/lib/module/LazyView.js.map +1 -1
- package/lib/module/ScrollViewGesture.js +23 -39
- package/lib/module/ScrollViewGesture.js.map +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/hooks/computeNewIndexWhenDataChanges.js +43 -0
- package/lib/module/hooks/computeNewIndexWhenDataChanges.js.map +1 -0
- package/lib/module/hooks/index.test.js +72 -0
- package/lib/module/hooks/index.test.js.map +1 -0
- package/lib/module/hooks/useAutoPlay.js +5 -19
- package/lib/module/hooks/useAutoPlay.js.map +1 -1
- package/lib/module/hooks/useCarouselController.js +24 -36
- package/lib/module/hooks/useCarouselController.js.map +1 -1
- package/lib/module/hooks/useCheckMounted.js +1 -1
- package/lib/module/hooks/useCheckMounted.js.map +1 -1
- package/lib/module/hooks/useCommonVariables.js +39 -3
- package/lib/module/hooks/useCommonVariables.js.map +1 -1
- package/lib/module/hooks/useInitProps.js +4 -7
- package/lib/module/hooks/useInitProps.js.map +1 -1
- package/lib/module/hooks/useLayoutConfig.js +5 -5
- package/lib/module/hooks/useLayoutConfig.js.map +1 -1
- package/lib/module/hooks/useOffsetX.js +5 -12
- package/lib/module/hooks/useOffsetX.js.map +1 -1
- package/lib/module/hooks/useOnProgressChange.js +4 -8
- package/lib/module/hooks/useOnProgressChange.js.map +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js +6 -6
- package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/module/hooks/useVisibleRanges.js +1 -1
- package/lib/module/hooks/useVisibleRanges.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layouts/BaseLayout.js +15 -16
- package/lib/module/layouts/BaseLayout.js.map +1 -1
- package/lib/module/layouts/ParallaxLayout.js +9 -9
- package/lib/module/layouts/ParallaxLayout.js.map +1 -1
- package/lib/module/layouts/index.js +3 -3
- package/lib/module/layouts/index.js.map +1 -1
- package/lib/module/layouts/normal.js +2 -2
- package/lib/module/layouts/normal.js.map +1 -1
- package/lib/module/layouts/parallax.js +3 -3
- package/lib/module/layouts/parallax.js.map +1 -1
- package/lib/module/layouts/stack.js +20 -28
- package/lib/module/layouts/stack.js.map +1 -1
- package/lib/module/store/index.js +1 -1
- package/lib/module/store/index.js.map +1 -1
- package/lib/module/utils/computedWithAutoFillData.js +4 -4
- package/lib/module/utils/computedWithAutoFillData.js.map +1 -1
- package/lib/module/utils/dealWithAnimation.js +4 -4
- package/lib/module/utils/dealWithAnimation.js.map +1 -1
- package/lib/module/utils/handlerOffsetDirection.js +9 -0
- package/lib/module/utils/handlerOffsetDirection.js.map +1 -0
- package/lib/module/utils/log.js +2 -1
- package/lib/module/utils/log.js.map +1 -1
- package/lib/typescript/Carousel.d.ts +2 -2
- package/lib/typescript/LazyView.d.ts +1 -1
- package/lib/typescript/ScrollViewGesture.d.ts +3 -3
- package/lib/typescript/constants/index.d.ts +1 -1
- package/lib/typescript/hooks/computeNewIndexWhenDataChanges.d.ts +8 -0
- package/lib/typescript/hooks/index.test.d.ts +1 -0
- package/lib/typescript/hooks/useAutoPlay.d.ts +1 -1
- package/lib/typescript/hooks/useCarouselController.d.ts +5 -5
- package/lib/typescript/hooks/useCheckMounted.d.ts +1 -1
- package/lib/typescript/hooks/useCommonVariables.d.ts +2 -2
- package/lib/typescript/hooks/useInitProps.d.ts +2 -2
- package/lib/typescript/hooks/useLayoutConfig.d.ts +2 -2
- package/lib/typescript/hooks/useOffsetX.d.ts +3 -3
- package/lib/typescript/hooks/useOnProgressChange.d.ts +4 -4
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +1 -1
- package/lib/typescript/hooks/useVisibleRanges.d.ts +1 -1
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/layouts/BaseLayout.d.ts +5 -4
- package/lib/typescript/layouts/ParallaxLayout.d.ts +5 -5
- package/lib/typescript/layouts/index.d.ts +4 -4
- package/lib/typescript/layouts/parallax.d.ts +15 -15
- package/lib/typescript/layouts/stack.d.ts +15 -15
- package/lib/typescript/store/index.d.ts +2 -2
- package/lib/typescript/types.d.ts +112 -112
- package/lib/typescript/utils/dealWithAnimation.d.ts +1 -1
- package/lib/typescript/utils/handlerOffsetDirection.d.ts +2 -0
- package/package.json +9 -5
- package/src/Carousel.tsx +228 -229
- package/src/LazyView.tsx +6 -7
- package/src/ScrollViewGesture.tsx +251 -257
- package/src/constants/index.ts +10 -9
- package/src/hooks/computeNewIndexWhenDataChanges.ts +51 -0
- package/src/hooks/index.test.ts +82 -0
- package/src/hooks/useAutoPlay.ts +59 -59
- package/src/hooks/useCarouselController.tsx +296 -299
- package/src/hooks/useCheckMounted.ts +9 -9
- package/src/hooks/useCommonVariables.ts +64 -27
- package/src/hooks/useInitProps.ts +71 -70
- package/src/hooks/useLayoutConfig.ts +21 -19
- package/src/hooks/useOffsetX.ts +71 -71
- package/src/hooks/useOnProgressChange.ts +48 -47
- package/src/hooks/usePropsErrorBoundary.ts +27 -26
- package/src/hooks/useVisibleRanges.tsx +39 -39
- package/src/index.tsx +5 -5
- package/src/layouts/BaseLayout.tsx +103 -101
- package/src/layouts/ParallaxLayout.tsx +126 -124
- package/src/layouts/index.tsx +8 -8
- package/src/layouts/normal.ts +16 -16
- package/src/layouts/parallax.ts +62 -61
- package/src/layouts/stack.ts +320 -315
- package/src/store/index.ts +8 -7
- package/src/types.ts +111 -110
- package/src/utils/computedWithAutoFillData.ts +60 -60
- package/src/utils/dealWithAnimation.ts +19 -18
- package/src/utils/handlerOffsetDirection.ts +15 -0
- package/src/utils/log.ts +4 -3
- package/CHANGELOG.md +0 -610
- package/src/.DS_Store +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCommonVariables.ts"],"names":["useCommonVariables","props","vertical","height","width","data","defaultIndex","defaultScrollOffsetValue","size","validLength","length","defaultHandlerOffsetValue","Math","abs","_handlerOffset","handlerOffset","React","useEffect","value"],"mappings":"0LAAA,
|
|
1
|
+
{"version":3,"sources":["useCommonVariables.ts"],"names":["useCommonVariables","props","vertical","height","width","data","defaultIndex","defaultScrollOffsetValue","loop","size","validLength","length","defaultHandlerOffsetValue","Math","abs","_handlerOffset","handlerOffset","prevData","React","useEffect","value","_data","slice","previousLength","currentLength","isLengthChanged","shouldComputed","direction","handlerOffsetDirection","computeNewIndexWhenDataChanges"],"mappings":"0LAAA,oDAEA,8DAEA,gFAGA,uEAQO,QAASA,CAAAA,kBAAT,CACLC,KADK,CAEa,CAClB,GACEC,CAAAA,QADF,CAQID,KARJ,CACEC,QADF,CAEEC,MAFF,CAQIF,KARJ,CAEEE,MAFF,CAGEC,KAHF,CAQIH,KARJ,CAGEG,KAHF,CAIEC,IAJF,CAQIJ,KARJ,CAIEI,IAJF,CAKEC,YALF,CAQIL,K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AoC,CAApBC,aAAoB,MAApBA,aAAoB,CACxD,GAAIE,cAAJ,CAAoB,CAElB,GAAMC,CAAAA,SAAS,CAAG,mDAAuBX,aAAvB,CAAlB,CAEAA,aAAa,CAACI,KAAd,CAAsB,mEAA+B,CACnDO,SAAS,CAATA,SADmD,CAEnDJ,cAAc,CAAdA,cAFmD,CAGnDC,aAAa,CAAbA,aAHmD,CAInDf,IAAI,CAAJA,IAJmD,CAKnDO,aAAa,CAAEA,aAAa,CAACI,KALsB,CAA/B,CAAtB,CAOD,CACF,CA5BD,qCA9BoBQ,8CA8BpB,eAxBmBZ,aAwBnB,gCA7BwBa,8DA6BxB,MAzBIpB,IAyBJ,ynBA4BG,CAACJ,IAAD,CAAOG,IAAP,CA5BH,EA8BA,MAAO,CACLC,IAAI,CAAJA,IADK,CAELC,WAAW,CAAXA,WAFK,CAGLM,aAAa,CAAbA,aAHK,CAAP,CAKD","sourcesContent":["import React from \"react\";\nimport type Animated from \"react-native-reanimated\";\nimport { useSharedValue, useAnimatedReaction } from \"react-native-reanimated\";\n\nimport { computeNewIndexWhenDataChanges } from \"./computeNewIndexWhenDataChanges\";\nimport type { TInitializeCarouselProps } from \"./useInitProps\";\n\nimport { handlerOffsetDirection } from \"../utils/handlerOffsetDirection\";\n\ninterface ICommonVariables {\n size: number\n validLength: number\n handlerOffset: Animated.SharedValue<number>\n}\n\nexport function useCommonVariables(\n props: TInitializeCarouselProps<any>,\n): ICommonVariables {\n const {\n vertical,\n height,\n width,\n data,\n defaultIndex,\n defaultScrollOffsetValue,\n loop,\n } = props;\n const size = vertical ? height : width;\n const validLength = data.length - 1;\n const defaultHandlerOffsetValue = -Math.abs(defaultIndex * size);\n const _handlerOffset = useSharedValue<number>(defaultHandlerOffsetValue);\n const handlerOffset = defaultScrollOffsetValue ?? _handlerOffset;\n const prevData = useSharedValue(data);\n\n React.useEffect(() => {\n handlerOffset.value = defaultHandlerOffsetValue;\n }, [vertical, handlerOffset, defaultHandlerOffsetValue]);\n\n useAnimatedReaction(() => {\n const _data = data.slice();\n const previousLength = prevData.value.length;\n const currentLength = _data.length;\n const isLengthChanged = previousLength !== currentLength;\n const shouldComputed = isLengthChanged && loop;\n\n if (shouldComputed)\n prevData.value = _data;\n\n return {\n shouldComputed,\n previousLength,\n currentLength,\n };\n }, ({ shouldComputed, previousLength, currentLength }) => {\n if (shouldComputed) {\n // direction -> 1 | -1\n const direction = handlerOffsetDirection(handlerOffset);\n\n handlerOffset.value = computeNewIndexWhenDataChanges({\n direction,\n previousLength,\n currentLength,\n size,\n handlerOffset: handlerOffset.value,\n });\n }\n }, [data, loop]);\n\n return {\n size,\n validLength,\n handlerOffset,\n };\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useInitProps=useInitProps;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useInitProps=useInitProps;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireDefault(require("react"));var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}function useInitProps(props){var _props$enableSnap;var _props$defaultIndex=props.defaultIndex,defaultIndex=_props$defaultIndex===void 0?0:_props$defaultIndex,_props$data=props.data,rawData=_props$data===void 0?[]:_props$data,_props$loop=props.loop,loop=_props$loop===void 0?true:_props$loop,_props$enabled=props.enabled,enabled=_props$enabled===void 0?true:_props$enabled,_props$autoPlayInterv=props.autoPlayInterval,_autoPlayInterval=_props$autoPlayInterv===void 0?1000:_props$autoPlayInterv,_props$scrollAnimatio=props.scrollAnimationDuration,scrollAnimationDuration=_props$scrollAnimatio===void 0?500:_props$scrollAnimatio,_props$style=props.style,style=_props$style===void 0?{}:_props$style,_props$panGestureHand=props.panGestureHandlerProps,panGestureHandlerProps=_props$panGestureHand===void 0?{}:_props$panGestureHand,_props$pagingEnabled=props.pagingEnabled,pagingEnabled=_props$pagingEnabled===void 0?true:_props$pagingEnabled,_props$autoFillData=props.autoFillData,autoFillData=_props$autoFillData===void 0?true:_props$autoFillData,_props$snapEnabled=props.snapEnabled,snapEnabled=_props$snapEnabled===void 0?(_props$enableSnap=props.enableSnap)!=null?_props$enableSnap:true:_props$snapEnabled,_width=props.width,_height=props.height;var width=Math.round(_width||0);var height=Math.round(_height||0);var autoPlayInterval=Math.max(_autoPlayInterval,0);var data=_react.default.useMemo(function(){return(0,_computedWithAutoFillData.computedFillDataWithAutoFillData)({loop:loop,autoFillData:autoFillData,data:rawData,dataLength:rawData.length});},[rawData,loop,autoFillData]);if(props.mode==="vertical-stack"||props.mode==="horizontal-stack"){var _props$modeConfig$sho,_props$modeConfig;if(!props.modeConfig)props.modeConfig={};props.modeConfig.showLength=(_props$modeConfig$sho=(_props$modeConfig=props.modeConfig)==null?void 0:_props$modeConfig.showLength)!=null?_props$modeConfig$sho:data.length-1;}return _objectSpread(_objectSpread({},props),{},{defaultIndex:defaultIndex,autoFillData:autoFillData,data:data,rawData:rawData,loop:loop,enabled:enabled,autoPlayInterval:autoPlayInterval,scrollAnimationDuration:scrollAnimationDuration,style:style,panGestureHandlerProps:panGestureHandlerProps,pagingEnabled:pagingEnabled,snapEnabled:snapEnabled,width:width,height:height});}
|
|
2
2
|
//# sourceMappingURL=useInitProps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useInitProps.ts"],"names":["useInitProps","props","defaultIndex","data","rawData","loop","enabled","autoPlayInterval","_autoPlayInterval","scrollAnimationDuration","style","panGestureHandlerProps","pagingEnabled","autoFillData","snapEnabled","enableSnap","_width","width","_height","height","Math","round","max","React","useMemo","dataLength","length","mode","modeConfig","showLength"],"mappings":"4QAAA,
|
|
1
|
+
{"version":3,"sources":["useInitProps.ts"],"names":["useInitProps","props","defaultIndex","data","rawData","loop","enabled","autoPlayInterval","_autoPlayInterval","scrollAnimationDuration","style","panGestureHandlerProps","pagingEnabled","autoFillData","snapEnabled","enableSnap","_width","width","_height","height","Math","round","max","React","useMemo","dataLength","length","mode","modeConfig","showLength"],"mappings":"4QAAA,oDAGA,2E,kxBAqBO,QAASA,CAAAA,YAAT,CACLC,KADK,CAEwB,uBAC7B,wBAcIA,KAdJ,CACEC,YADF,CACEA,YADF,8BACiB,CADjB,iCAcID,KAdJ,CAEEE,IAFF,CAEQC,OAFR,sBAEkB,EAFlB,yBAcIH,KAdJ,CAGEI,IAHF,CAGEA,IAHF,sBAGS,IAHT,4BAcIJ,KAdJ,CAIEK,OAJF,CAIEA,OAJF,yBAIY,IAJZ,sCAcIL,KAdJ,CAKEM,gBALF,CAKoBC,iBALpB,gCAKwC,IALxC,6CAcIP,KAdJ,CAMEQ,uBANF,CAMEA,uBANF,gCAM4B,GAN5B,oCAcIR,KAdJ,CAOES,KAPF,CAOEA,KAPF,uBAOU,EAPV,oCAcIT,KAdJ,CAQEU,sBARF,CAQEA,sBARF,gCAQ2B,EAR3B,4CAcIV,KAdJ,CASEW,aATF,CASEA,aATF,+BASkB,IATlB,0CAcIX,KAdJ,CAUEY,YAVF,CAUEA,YAVF,8BAUiB,IAVjB,wCAcIZ,KAdJ,CAW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uBATF,CAUEC,KAAK,CAALA,KAVF,CAWEC,sBAAsB,CAAtBA,sBAXF,CAYEC,aAAa,CAAbA,aAZF,CAaEE,WAAW,CAAXA,WAbF,CAcEG,KAAK,CAALA,KAdF,CAeEE,MAAM,CAANA,MAfF,GAiBD","sourcesContent":["import React from \"react\";\n\nimport type { TCarouselProps } from \"../types\";\nimport { computedFillDataWithAutoFillData } from \"../utils/computedWithAutoFillData\";\n\ntype TGetRequiredProps<P extends keyof TCarouselProps> = Record<\nP,\nRequired<TCarouselProps>[P]\n>;\n\nexport type TInitializeCarouselProps<T> = TCarouselProps<T> &\nTGetRequiredProps<\n| \"defaultIndex\"\n| \"loop\"\n| \"width\"\n| \"height\"\n| \"scrollAnimationDuration\"\n| \"autoPlayInterval\"\n| \"autoFillData\"\n> & {\n // Raw data that has not been processed\n rawData: T[]\n};\n\nexport function useInitProps<T>(\n props: TCarouselProps<T>,\n): TInitializeCarouselProps<T> {\n const {\n defaultIndex = 0,\n data: rawData = [],\n loop = true,\n enabled = true,\n autoPlayInterval: _autoPlayInterval = 1000,\n scrollAnimationDuration = 500,\n style = {},\n panGestureHandlerProps = {},\n pagingEnabled = true,\n autoFillData = true,\n snapEnabled = props.enableSnap ?? true,\n width: _width,\n height: _height,\n } = props;\n\n const width = Math.round(_width || 0);\n const height = Math.round(_height || 0);\n const autoPlayInterval = Math.max(_autoPlayInterval, 0);\n\n const data = React.useMemo<T[]>(\n () =>\n computedFillDataWithAutoFillData<T>({\n loop,\n autoFillData,\n data: rawData,\n dataLength: rawData.length,\n }),\n [rawData, loop, autoFillData],\n );\n\n if (props.mode === \"vertical-stack\" || props.mode === \"horizontal-stack\") {\n if (!props.modeConfig)\n props.modeConfig = {};\n\n props.modeConfig.showLength\n = props.modeConfig?.showLength ?? data.length - 1;\n }\n return {\n ...props,\n defaultIndex,\n autoFillData,\n data,\n rawData,\n loop,\n enabled,\n autoPlayInterval,\n scrollAnimationDuration,\n style,\n panGestureHandlerProps,\n pagingEnabled,\n snapEnabled,\n width,\n height,\n };\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useLayoutConfig=useLayoutConfig;var _react=_interopRequireDefault(require("react"));var _layouts=require("../layouts");function useLayoutConfig(opts){var _ref=opts,size=_ref.size,vertical=_ref.vertical;return _react.default.useMemo(function(){var baseConfig={size:size,vertical:vertical};switch(opts.mode){case
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.useLayoutConfig=useLayoutConfig;var _react=_interopRequireDefault(require("react"));var _layouts=require("../layouts");function useLayoutConfig(opts){var _ref=opts,size=_ref.size,vertical=_ref.vertical;return _react.default.useMemo(function(){var baseConfig={size:size,vertical:vertical};switch(opts.mode){case"parallax":return _layouts.Layouts.parallax(baseConfig,opts.modeConfig);case"horizontal-stack":return _layouts.Layouts.horizontalStack(opts.modeConfig);case"vertical-stack":return _layouts.Layouts.verticalStack(opts.modeConfig);default:return _layouts.Layouts.normal(baseConfig);}},[opts.mode,opts.modeConfig,size,vertical]);}
|
|
2
2
|
//# sourceMappingURL=useLayoutConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useLayoutConfig.ts"],"names":["useLayoutConfig","opts","size","vertical","React","useMemo","baseConfig","mode","Layouts","parallax","modeConfig","horizontalStack","verticalStack","normal"],"mappings":"oLAAA,
|
|
1
|
+
{"version":3,"sources":["useLayoutConfig.ts"],"names":["useLayoutConfig","opts","size","vertical","React","useMemo","baseConfig","mode","Layouts","parallax","modeConfig","horizontalStack","verticalStack","normal"],"mappings":"oLAAA,oDAIA,mCAKO,QAASA,CAAAA,eAAT,CACLC,IADK,CAEY,CACjB,SAA2BA,IAA3B,CAAQC,IAAR,MAAQA,IAAR,CAAcC,QAAd,MAAcA,QAAd,CAEA,MAAOC,gBAAMC,OAAN,CAAc,UAAM,CACzB,GAAMC,CAAAA,UAAU,CAAG,CAAEJ,IAAI,CAAJA,IAAF,CAAQC,QAAQ,CAARA,QAAR,CAAnB,CACA,OAAQF,IAAI,CAACM,IAAb,EACE,IAAK,UAAL,CACE,MAAOC,kBAAQC,QAAR,CAAiBH,UAAjB,CAA6BL,IAAI,CAACS,UAAlC,CAAP,CACF,IAAK,kBAAL,CACE,MAAOF,kBAAQG,eAAR,CAAwBV,IAAI,CAACS,UAA7B,CAAP,CACF,IAAK,gBAAL,CACE,MAAOF,kBAAQI,aAAR,CAAsBX,IAAI,CAACS,UAA3B,CAAP,CACF,QACE,MAAOF,kBAAQK,MAAR,CAAeP,UAAf,CAAP,CARJ,CAUD,CAZM,CAYJ,CAACL,IAAI,CAACM,IAAN,CAAYN,IAAI,CAACS,UAAjB,CAA6BR,IAA7B,CAAmCC,QAAnC,CAZI,CAAP,CAaD","sourcesContent":["import React from \"react\";\n\nimport type { TInitializeCarouselProps } from \"./useInitProps\";\n\nimport { Layouts } from \"../layouts\";\nimport type { TAnimationStyle } from \"../layouts/BaseLayout\";\n\ntype TLayoutConfigOpts<T> = TInitializeCarouselProps<T> & { size: number };\n\nexport function useLayoutConfig<T>(\n opts: TLayoutConfigOpts<T>,\n): TAnimationStyle {\n const { size, vertical } = opts as Required<TLayoutConfigOpts<T>>;\n\n return React.useMemo(() => {\n const baseConfig = { size, vertical };\n switch (opts.mode) {\n case \"parallax\":\n return Layouts.parallax(baseConfig, opts.modeConfig);\n case \"horizontal-stack\":\n return Layouts.horizontalStack(opts.modeConfig);\n case \"vertical-stack\":\n return Layouts.verticalStack(opts.modeConfig);\n default:\n return Layouts.normal(baseConfig);\n }\n }, [opts.mode, opts.modeConfig, size, vertical]);\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.useOffsetX=void 0;var _reactNativeReanimated=require("react-native-reanimated");var useOffsetX=function useOffsetX(opts,visibleRanges){var handlerOffset=opts.handlerOffset,index=opts.index,size=opts.size,loop=opts.loop,data=opts.data,_opts$type=opts.type,type=_opts$type===void 0?
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useOffsetX=void 0;var _reactNativeReanimated=require("react-native-reanimated");var useOffsetX=function useOffsetX(opts,visibleRanges){var handlerOffset=opts.handlerOffset,index=opts.index,size=opts.size,loop=opts.loop,data=opts.data,_opts$type=opts.type,type=_opts$type===void 0?"positive":_opts$type,_opts$viewCount=opts.viewCount,viewCount=_opts$viewCount===void 0?Math.round((data.length-1)/2):_opts$viewCount;var ITEM_LENGTH=data.length;var VALID_LENGTH=ITEM_LENGTH-1;var TOTAL_WIDTH=size*ITEM_LENGTH;var HALF_WIDTH=0.5*size;var positiveCount=type==="positive"?viewCount:VALID_LENGTH-viewCount;var startPos=size*index;if(index>positiveCount)startPos=(index-ITEM_LENGTH)*size;var MAX=positiveCount*size;var MIN=-((VALID_LENGTH-positiveCount)*size);var x=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var _visibleRanges$value=visibleRanges.value,negativeRange=_visibleRanges$value.negativeRange,positiveRange=_visibleRanges$value.positiveRange;if((index<negativeRange[0]||index>negativeRange[1])&&(index<positiveRange[0]||index>positiveRange[1]))return Number.MAX_SAFE_INTEGER;if(loop){var inputRange=[-TOTAL_WIDTH,MIN-HALF_WIDTH-startPos-Number.MIN_VALUE,MIN-HALF_WIDTH-startPos,0,MAX+HALF_WIDTH-startPos,MAX+HALF_WIDTH-startPos+Number.MIN_VALUE,TOTAL_WIDTH];var outputRange=[startPos,MAX+HALF_WIDTH-Number.MIN_VALUE,MIN-HALF_WIDTH,startPos,MAX+HALF_WIDTH,MIN-HALF_WIDTH+Number.MIN_VALUE,startPos];return(0,_reactNativeReanimated.interpolate)(handlerOffset.value,inputRange,outputRange,_reactNativeReanimated.Extrapolate.CLAMP);}return handlerOffset.value+size*index;};_f._closure={visibleRanges:visibleRanges,index:index,loop:loop,TOTAL_WIDTH:TOTAL_WIDTH,MIN:MIN,HALF_WIDTH:HALF_WIDTH,startPos:startPos,MAX:MAX,interpolate:_reactNativeReanimated.interpolate,handlerOffset:handlerOffset,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},size:size};_f.asString="function _f(){const{visibleRanges,index,loop,TOTAL_WIDTH,MIN,HALF_WIDTH,startPos,MAX,interpolate,handlerOffset,Extrapolate,size}=jsThis._closure;{const{negativeRange:negativeRange,positiveRange:positiveRange}=visibleRanges.value;if((index<negativeRange[0]||index>negativeRange[1])&&(index<positiveRange[0]||index>positiveRange[1]))return Number.MAX_SAFE_INTEGER;if(loop){const inputRange=[-TOTAL_WIDTH,MIN-HALF_WIDTH-startPos-Number.MIN_VALUE,MIN-HALF_WIDTH-startPos,0,MAX+HALF_WIDTH-startPos,MAX+HALF_WIDTH-startPos+Number.MIN_VALUE,TOTAL_WIDTH];const outputRange=[startPos,MAX+HALF_WIDTH-Number.MIN_VALUE,MIN-HALF_WIDTH,startPos,MAX+HALF_WIDTH,MIN-HALF_WIDTH+Number.MIN_VALUE,startPos];return interpolate(handlerOffset.value,inputRange,outputRange,Extrapolate.CLAMP);}return handlerOffset.value+size*index;}}";_f.__workletHash=3599227485688;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOffsetX.ts (46:28)";return _f;}(),[loop,data,viewCount,type,size,visibleRanges]);return x;};exports.useOffsetX=useOffsetX;
|
|
2
2
|
//# sourceMappingURL=useOffsetX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useOffsetX.ts"],"names":["useOffsetX","opts","visibleRanges","handlerOffset","index","size","loop","data","type","viewCount","Math","round","length","ITEM_LENGTH","VALID_LENGTH","TOTAL_WIDTH","HALF_WIDTH","positiveCount","startPos","MAX","MIN","x","value","negativeRange","positiveRange","Number","MAX_SAFE_INTEGER","inputRange","MIN_VALUE","outputRange","Extrapolate","CLAMP","interpolate"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["useOffsetX.ts"],"names":["useOffsetX","opts","visibleRanges","handlerOffset","index","size","loop","data","type","viewCount","Math","round","length","ITEM_LENGTH","VALID_LENGTH","TOTAL_WIDTH","HALF_WIDTH","positiveCount","startPos","MAX","MIN","x","value","negativeRange","positiveRange","Number","MAX_SAFE_INTEGER","inputRange","MIN_VALUE","outputRange","Extrapolate","CLAMP","interpolate"],"mappings":"mFACA,8DAkBO,GAAMA,CAAAA,UAAU,CAAG,QAAbA,CAAAA,UAAa,CAACC,IAAD,CAAcC,aAAd,CAAgD,CACxE,GACEC,CAAAA,aADF,CAQIF,IARJ,CACEE,aADF,CAEEC,KAFF,CAQIH,IARJ,CAEEG,KAFF,CAGEC,IAHF,CAQIJ,IARJ,CAGEI,IAHF,CAIEC,IAJF,CAQIL,IARJ,CAIEK,IAJF,CAKEC,IALF,CAQIN,IARJ,CAKEM,IALF,YAQIN,IARJ,CAMEO,IANF,CAMEA,IANF,qBAMS,UANT,4BAQIP,IARJ,CAOEQ,SAPF,CAOEA,SAPF,0BAOcC,IAAI,CAACC,KAAL,CAAW,CAACJ,IAAI,CAACK,MAAL,CAAc,CAAf,EAAoB,CAA/B,CAPd,iBAUA,GAAMC,CAAAA,WAAW,CAAGN,IAAI,CAACK,MAAzB,CACA,GAAME,CAAAA,YAAY,CAAGD,WAAW,CAAG,CAAnC,CACA,GAAME,CAAAA,WAAW,CAAGV,IAAI,CAAGQ,WAA3B,CACA,GAAMG,CAAAA,UAAU,CAAG,IAAMX,IAAzB,CAEA,GAAMY,CAAAA,aAAa,CACXT,IAAI,GAAK,UAAT,CAAsBC,SAAtB,CAAkCK,YAAY,CAAGL,SADzD,CAGA,GAAIS,CAAAA,QAAQ,CAAGb,IAAI,CAAGD,KAAtB,CACA,GAAIA,KAAK,CAAGa,aAAZ,CACEC,QAAQ,CAAG,CAACd,KAAK,CAAGS,WAAT,EAAwBR,IAAnC,CAEF,GAAMc,CAAAA,GAAG,CAAGF,aAAa,CAAGZ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C,CACD,CAtCS,4BAxCNF,aAwCM,OA/B0BE,KA+B1B,MArCNE,IAqCM,aApCuLS,WAoCvL,KAnC0GK,GAmC1G,YAnCgHJ,UAmChH,UAnC+IE,QAmC/I,KAnCwFC,GAmCxF,aAlCDa,kCAkCC,eA/BH7B,aA+BG,oBAlCyD2B,mCAAYC,KAkCrE,OA/BmB1B,IA+BnB,w9BAsCP,CAACC,IAAD,CAAOC,IAAP,CAAaE,SAAb,CAAwBD,IAAxB,CAA8BH,IAA9B,CAAoCH,aAApC,CAtCO,CAAV,CAwCA,MAAOmB,CAAAA,CAAP,CACD,CAnEM,C","sourcesContent":["import type Animated from \"react-native-reanimated\";\nimport {\n Extrapolate,\n interpolate,\n useDerivedValue,\n} from \"react-native-reanimated\";\n\nimport type { IVisibleRanges } from \"./useVisibleRanges\";\n\nexport interface IOpts {\n index: number\n size: number\n handlerOffset: Animated.SharedValue<number>\n data: unknown[]\n type?: \"positive\" | \"negative\"\n viewCount?: number\n loop?: boolean\n}\n\nexport const useOffsetX = (opts: IOpts, visibleRanges: IVisibleRanges) => {\n const {\n handlerOffset,\n index,\n size,\n loop,\n data,\n type = \"positive\",\n viewCount = Math.round((data.length - 1) / 2),\n } = opts;\n\n const ITEM_LENGTH = data.length;\n const VALID_LENGTH = ITEM_LENGTH - 1;\n const TOTAL_WIDTH = size * ITEM_LENGTH;\n const HALF_WIDTH = 0.5 * size;\n\n const positiveCount\n = type === \"positive\" ? viewCount : VALID_LENGTH - viewCount;\n\n let startPos = size * index;\n if (index > positiveCount)\n startPos = (index - ITEM_LENGTH) * size;\n\n const MAX = positiveCount * size;\n const MIN = -((VALID_LENGTH - positiveCount) * size);\n\n const x = useDerivedValue(() => {\n const { negativeRange, positiveRange } = visibleRanges.value;\n if (\n (index < negativeRange[0] || index > negativeRange[1])\n && (index < positiveRange[0] || index > positiveRange[1])\n )\n return Number.MAX_SAFE_INTEGER;\n\n if (loop) {\n const inputRange = [\n -TOTAL_WIDTH,\n MIN - HALF_WIDTH - startPos - Number.MIN_VALUE,\n MIN - HALF_WIDTH - startPos,\n 0,\n MAX + HALF_WIDTH - startPos,\n MAX + HALF_WIDTH - startPos + Number.MIN_VALUE,\n TOTAL_WIDTH,\n ];\n\n const outputRange = [\n startPos,\n MAX + HALF_WIDTH - Number.MIN_VALUE,\n MIN - HALF_WIDTH,\n startPos,\n MAX + HALF_WIDTH,\n MIN - HALF_WIDTH + Number.MIN_VALUE,\n startPos,\n ];\n\n return interpolate(\n handlerOffset.value,\n inputRange,\n outputRange,\n Extrapolate.CLAMP,\n );\n }\n\n return handlerOffset.value + size * index;\n }, [loop, data, viewCount, type, size, visibleRanges]);\n\n return x;\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.useOnProgressChange=useOnProgressChange;var _reactNativeReanimated=require("react-native-reanimated");var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");function useOnProgressChange(opts){var autoFillData=opts.autoFillData,loop=opts.loop,offsetX=opts.offsetX,rawData=opts.rawData,size=opts.size,onProgressChange=opts.onProgressChange;var rawDataLength=rawData.length;(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return offsetX.value;};_f._closure={offsetX:offsetX};_f.asString="function _f(){const{offsetX}=jsThis._closure;{return offsetX.value;}}";_f.__workletHash=11091407603539;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts (
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useOnProgressChange=useOnProgressChange;var _reactNativeReanimated=require("react-native-reanimated");var _computedWithAutoFillData=require("../utils/computedWithAutoFillData");function useOnProgressChange(opts){var autoFillData=opts.autoFillData,loop=opts.loop,offsetX=opts.offsetX,rawData=opts.rawData,size=opts.size,onProgressChange=opts.onProgressChange;var rawDataLength=rawData.length;(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return offsetX.value;};_f._closure={offsetX:offsetX};_f.asString="function _f(){const{offsetX}=jsThis._closure;{return offsetX.value;}}";_f.__workletHash=11091407603539;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts (25:4)";return _f;}(),function(){var _f=function _f(_value){var value=(0,_computedWithAutoFillData.computedOffsetXValueWithAutoFillData)({value:_value,rawDataLength:rawDataLength,size:size,autoFillData:autoFillData,loop:loop});if(!loop){value=Math.max(-((rawDataLength-1)*size),Math.min(value,0));}var absoluteProgress=Math.abs(value/size);if(value>0)absoluteProgress=rawDataLength-absoluteProgress;if(onProgressChange)(0,_reactNativeReanimated.runOnJS)(onProgressChange)(value,absoluteProgress);};_f._closure={computedOffsetXValueWithAutoFillData:_computedWithAutoFillData.computedOffsetXValueWithAutoFillData,rawDataLength:rawDataLength,size:size,autoFillData:autoFillData,loop:loop,onProgressChange:onProgressChange,runOnJS:_reactNativeReanimated.runOnJS};_f.asString="function _f(_value){const{computedOffsetXValueWithAutoFillData,rawDataLength,size,autoFillData,loop,onProgressChange,runOnJS}=jsThis._closure;{let value=computedOffsetXValueWithAutoFillData({value:_value,rawDataLength:rawDataLength,size:size,autoFillData:autoFillData,loop:loop});if(!loop){value=Math.max(-((rawDataLength-1)*size),Math.min(value,0));}let absoluteProgress=Math.abs(value/size);if(value>0)absoluteProgress=rawDataLength-absoluteProgress;if(onProgressChange)runOnJS(onProgressChange)(value,absoluteProgress);}}";_f.__workletHash=4815839705374;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useOnProgressChange.ts (26:4)";return _f;}(),[loop,autoFillData,rawDataLength,onProgressChange]);}
|
|
2
2
|
//# sourceMappingURL=useOnProgressChange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useOnProgressChange.ts"],"names":["useOnProgressChange","opts","autoFillData","loop","offsetX","rawData","size","onProgressChange","rawDataLength","length","value","_value","Math","max","min","absoluteProgress","abs","computedOffsetXValueWithAutoFillData","runOnJS"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["useOnProgressChange.ts"],"names":["useOnProgressChange","opts","autoFillData","loop","offsetX","rawData","size","onProgressChange","rawDataLength","length","value","_value","Math","max","min","absoluteProgress","abs","computedOffsetXValueWithAutoFillData","runOnJS"],"mappings":"yGACA,8DAMA,2EAEO,QAASA,CAAAA,mBAAT,CACLC,IADK,CAQL,CACA,GAAQC,CAAAA,YAAR,CACQD,IADR,CAAQC,YAAR,CAAsBC,IAAtB,CACQF,IADR,CAAsBE,IAAtB,CAA4BC,OAA5B,CACQH,IADR,CAA4BG,OAA5B,CAAqCC,OAArC,CACQJ,IADR,CAAqCI,OAArC,CAA8CC,IAA9C,CACQL,IADR,CAA8CK,IAA9C,CAAoDC,gBAApD,CACQN,IADR,CAAoDM,gBAApD,CAGA,GAAMC,CAAAA,aAAa,CAAGH,OAAO,CAACI,MAA9B,CAEA,iEACE,oBAAML,CAAAA,OAAO,CAACM,KAAd,EADF,sBAtBKN,OAsBL,0RAEGO,MAFH,CAEc,CACV,GAAID,CAAAA,KAAK,CAAG,mEAAqC,CAC/CA,KAAK,CAAEC,MADwC,CAE/CH,aAAa,CAAbA,aAF+C,CAG/CF,IAAI,CAAJA,IAH+C,CAI/CJ,YAAY,CAAZA,YAJ+C,CAK/CC,IAAI,CAAJA,IAL+C,CAArC,CAAZ,CAQA,GAAI,CAACA,IAAL,CAAW,CACTO,KAAK,CAAGE,IAAI,CAACC,GAAL,CACN,EAAE,CAACL,aAAa,CAAG,CAAjB,EAAsBF,IAAxB,CADM,CAENM,IAAI,CAACE,GAAL,CAASJ,KAAT,CAAgB,CAAhB,CAFM,CAAR,CAID,CAED,GAAIK,CAAAA,gBAAgB,CAAGH,IAAI,CAACI,GAAL,CAASN,KAAK,CAAGJ,IAAjB,CAAvB,CAEA,GAAII,KAAK,CAAG,CAAZ,CACEK,gBAAgB,CAAGP,aAAa,CAAGO,gBAAnC,CAEF,GAAIR,gBAAJ,CACE,mCAAQA,gBAAR,EAA0BG,KAA1B,CAAiCK,gBAAjC,EACH,CAzBH,mDArBYE,8DAqBZ,eARkCT,aAQlC,MATwCF,IASxC,cAjBEJ,YAiBF,MAbKC,IAaL,kBAP8BI,gBAO9B,SAPsBW,8BAOtB,ksBA0BE,CAACf,IAAD,CAAOD,YAAP,CAAqBM,aAArB,CAAoCD,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 rawData: TCarouselProps[\"data\"]\n } & Pick<TCarouselProps, \"onProgressChange\">,\n) {\n const { autoFillData, loop, offsetX, rawData, size, onProgressChange }\n = opts;\n\n const rawDataLength = rawData.length;\n\n useAnimatedReaction(\n () => offsetX.value,\n (_value) => {\n let value = computedOffsetXValueWithAutoFillData({\n value: _value,\n rawDataLength,\n size,\n autoFillData,\n loop,\n });\n\n if (!loop) {\n value = Math.max(\n -((rawDataLength - 1) * size),\n Math.min(value, 0),\n );\n }\n\n let absoluteProgress = Math.abs(value / size);\n\n if (value > 0)\n absoluteProgress = rawDataLength - absoluteProgress;\n\n if (onProgressChange)\n runOnJS(onProgressChange)(value, absoluteProgress);\n },\n [loop, autoFillData, rawDataLength, onProgressChange],\n );\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.usePropsErrorBoundary=usePropsErrorBoundary;var _react=_interopRequireDefault(require("react"));function usePropsErrorBoundary(props){_react.default.useEffect(function(){var defaultIndex=props.defaultIndex,data=props.data;var viewCount=data.length;if(typeof defaultIndex===
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.usePropsErrorBoundary=usePropsErrorBoundary;var _react=_interopRequireDefault(require("react"));function usePropsErrorBoundary(props){_react.default.useEffect(function(){var defaultIndex=props.defaultIndex,data=props.data;var viewCount=data.length;if(typeof defaultIndex==="number"&&viewCount>0){if(defaultIndex<0||defaultIndex>=viewCount){throw new Error("DefaultIndex must be in the range of data length.");}}if(!props.mode||props.mode==="parallax"){if(!props.vertical&&!props.width){throw new Error("`width` must be specified for horizontal carousels.");}if(props.vertical&&!props.height){throw new Error("`height` must be specified for vertical carousels.");}}},[props]);}
|
|
2
2
|
//# sourceMappingURL=usePropsErrorBoundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["usePropsErrorBoundary.ts"],"names":["usePropsErrorBoundary","props","React","useEffect","defaultIndex","data","viewCount","length","Error","mode","vertical","width","height"],"mappings":"gMAAA,
|
|
1
|
+
{"version":3,"sources":["usePropsErrorBoundary.ts"],"names":["usePropsErrorBoundary","props","React","useEffect","defaultIndex","data","viewCount","length","Error","mode","vertical","width","height"],"mappings":"gMAAA,oDAIO,QAASA,CAAAA,qBAAT,CAA+BC,KAA/B,CAAsD,CAC3DC,eAAMC,SAAN,CAAgB,UAAM,CACpB,GAAQC,CAAAA,YAAR,CAA+BH,KAA/B,CAAQG,YAAR,CAAsBC,IAAtB,CAA+BJ,KAA/B,CAAsBI,IAAtB,CAEA,GAAMC,CAAAA,SAAS,CAAGD,IAAI,CAACE,MAAvB,CACA,GAAI,MAAOH,CAAAA,YAAP,GAAwB,QAAxB,EAAoCE,SAAS,CAAG,CAApD,CAAuD,CACrD,GAAIF,YAAY,CAAG,CAAf,EAAoBA,YAAY,EAAIE,SAAxC,CAAmD,CACjD,KAAM,IAAIE,CAAAA,KAAJ,CACJ,mDADI,CAAN,CAGD,CACF,CAGD,GAAI,CAACP,KAAK,CAACQ,IAAP,EAAeR,KAAK,CAACQ,IAAN,GAAe,UAAlC,CAA8C,CAC5C,GAAI,CAACR,KAAK,CAACS,QAAP,EAAmB,CAACT,KAAK,CAACU,KAA9B,CAAqC,CACnC,KAAM,IAAIH,CAAAA,KAAJ,CACJ,qDADI,CAAN,CAGD,CACD,GAAIP,KAAK,CAACS,QAAN,EAAkB,CAACT,KAAK,CAACW,MAA7B,CAAqC,CACnC,KAAM,IAAIJ,CAAAA,KAAJ,CACJ,oDADI,CAAN,CAGD,CACF,CACF,CAzBD,CAyBG,CAACP,KAAD,CAzBH,EA0BD","sourcesContent":["import React from \"react\";\n\nimport type { TCarouselProps } from \"../types\";\n\nexport function usePropsErrorBoundary(props: TCarouselProps) {\n React.useEffect(() => {\n const { defaultIndex, data } = props;\n\n const viewCount = data.length;\n if (typeof defaultIndex === \"number\" && viewCount > 0) {\n if (defaultIndex < 0 || defaultIndex >= viewCount) {\n throw new Error(\n \"DefaultIndex must be in the range of data length.\",\n );\n }\n }\n\n // TODO\n if (!props.mode || props.mode === \"parallax\") {\n if (!props.vertical && !props.width) {\n throw new Error(\n \"`width` must be specified for horizontal carousels.\",\n );\n }\n if (props.vertical && !props.height) {\n throw new Error(\n \"`height` must be specified for vertical carousels.\",\n );\n }\n }\n }, [props]);\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.useVisibleRanges=useVisibleRanges;var _reactNativeReanimated=require("react-native-reanimated");function useVisibleRanges(options){var _options$total=options.total,total=_options$total===void 0?0:_options$total,viewSize=options.viewSize,translation=options.translation,_options$windowSize=options.windowSize,_windowSize=_options$windowSize===void 0?0:_options$windowSize;var windowSize=total<=_windowSize?total:_windowSize;var ranges=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var positiveCount=Math.round(windowSize/2);var negativeCount=windowSize-positiveCount;var curIndex=Math.round(-translation.value/viewSize);curIndex=curIndex<0?curIndex%total+total:curIndex;var negativeRange=[(curIndex-negativeCount+total)%total,(curIndex-1+total)%total];var positiveRange=[(curIndex+total)%total,(curIndex+positiveCount+total)%total];if(negativeRange[0]<total&&negativeRange[0]>negativeRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}if(positiveRange[0]>positiveRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}return{negativeRange:negativeRange,positiveRange:positiveRange};};_f._closure={windowSize:windowSize,translation:translation,viewSize:viewSize,total:total};_f.asString="function _f(){const{windowSize,translation,viewSize,total}=jsThis._closure;{const positiveCount=Math.round(windowSize/2);const negativeCount=windowSize-positiveCount;let curIndex=Math.round(-translation.value/viewSize);curIndex=curIndex<0?curIndex%total+total:curIndex;const negativeRange=[(curIndex-negativeCount+total)%total,(curIndex-1+total)%total];const positiveRange=[(curIndex+total)%total,(curIndex+positiveCount+total)%total];if(negativeRange[0]<total&&negativeRange[0]>negativeRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}if(positiveRange[0]>positiveRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}return{negativeRange:negativeRange,positiveRange:positiveRange};}}";_f.__workletHash=15212293827170;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useVisibleRanges.tsx (24:
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.useVisibleRanges=useVisibleRanges;var _reactNativeReanimated=require("react-native-reanimated");function useVisibleRanges(options){var _options$total=options.total,total=_options$total===void 0?0:_options$total,viewSize=options.viewSize,translation=options.translation,_options$windowSize=options.windowSize,_windowSize=_options$windowSize===void 0?0:_options$windowSize;var windowSize=total<=_windowSize?total:_windowSize;var ranges=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){var positiveCount=Math.round(windowSize/2);var negativeCount=windowSize-positiveCount;var curIndex=Math.round(-translation.value/viewSize);curIndex=curIndex<0?curIndex%total+total:curIndex;var negativeRange=[(curIndex-negativeCount+total)%total,(curIndex-1+total)%total];var positiveRange=[(curIndex+total)%total,(curIndex+positiveCount+total)%total];if(negativeRange[0]<total&&negativeRange[0]>negativeRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}if(positiveRange[0]>positiveRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}return{negativeRange:negativeRange,positiveRange:positiveRange};};_f._closure={windowSize:windowSize,translation:translation,viewSize:viewSize,total:total};_f.asString="function _f(){const{windowSize,translation,viewSize,total}=jsThis._closure;{const positiveCount=Math.round(windowSize/2);const negativeCount=windowSize-positiveCount;let curIndex=Math.round(-translation.value/viewSize);curIndex=curIndex<0?curIndex%total+total:curIndex;const negativeRange=[(curIndex-negativeCount+total)%total,(curIndex-1+total)%total];const positiveRange=[(curIndex+total)%total,(curIndex+positiveCount+total)%total];if(negativeRange[0]<total&&negativeRange[0]>negativeRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}if(positiveRange[0]>positiveRange[1]){negativeRange[1]=total-1;positiveRange[0]=0;}return{negativeRange:negativeRange,positiveRange:positiveRange};}}";_f.__workletHash=15212293827170;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/hooks/useVisibleRanges.tsx (24:33)";return _f;}(),[total,windowSize,translation]);return ranges;}
|
|
2
2
|
//# sourceMappingURL=useVisibleRanges.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useVisibleRanges.tsx"],"names":["useVisibleRanges","options","total","viewSize","translation","windowSize","_windowSize","ranges","positiveCount","Math","round","negativeCount","curIndex","value","negativeRange","positiveRange"],"mappings":"mGACA,8DAOO,QAASA,CAAAA,gBAAT,CAA0BC,OAA1B,CAKY,
|
|
1
|
+
{"version":3,"sources":["useVisibleRanges.tsx"],"names":["useVisibleRanges","options","total","viewSize","translation","windowSize","_windowSize","ranges","positiveCount","Math","round","negativeCount","curIndex","value","negativeRange","positiveRange"],"mappings":"mGACA,8DAOO,QAASA,CAAAA,gBAAT,CAA0BC,OAA1B,CAKY,CACjB,mBAKIA,OALJ,CACEC,KADF,CACEA,KADF,yBACU,CADV,gBAEEC,QAFF,CAKIF,OALJ,CAEEE,QAFF,CAGEC,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AAG,CAA3B,CACAa,aAAa,CAAC,CAAD,CAAb,CAAmB,CAAnB,CACD,CACD,MAAO,CAAED,aAAa,CAAbA,aAAF,CAAiBC,aAAa,CAAbA,aAAjB,CAAP,CACD,CAtBc,yBApBOV,UAoBP,aAnBYD,WAmBZ,UAnBgCD,QAmBhC,OARMD,KAQN,y2BAsBZ,CAACA,KAAD,CAAQG,UAAR,CAAoBD,WAApB,CAtBY,CAAf,CAwBA,MAAOG,CAAAA,MAAP,CACD","sourcesContent":["import type Animated from \"react-native-reanimated\";\nimport { useDerivedValue } from \"react-native-reanimated\";\n\nexport type IVisibleRanges = Animated.SharedValue<{\n negativeRange: number[]\n positiveRange: number[]\n}>;\n\nexport function useVisibleRanges(options: {\n total: number\n viewSize: number\n windowSize?: number\n translation: Animated.SharedValue<number>\n}): IVisibleRanges {\n const {\n total = 0,\n viewSize,\n translation,\n windowSize: _windowSize = 0,\n } = options;\n\n const windowSize = total <= _windowSize ? total : _windowSize;\n\n const ranges = useDerivedValue(() => {\n const positiveCount = Math.round(windowSize / 2);\n const negativeCount = windowSize - positiveCount;\n let curIndex = Math.round(-translation.value / viewSize);\n curIndex = curIndex < 0 ? (curIndex % total) + total : curIndex;\n const negativeRange = [\n (curIndex - negativeCount + total) % total,\n (curIndex - 1 + total) % total,\n ];\n const positiveRange = [\n (curIndex + total) % total,\n (curIndex + positiveCount + total) % total,\n ];\n if (negativeRange[0] < total && negativeRange[0] > negativeRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n if (positiveRange[0] > positiveRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n return { negativeRange, positiveRange };\n }, [total, windowSize, translation]);\n\n return ranges;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["Carousel"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["Carousel"],"mappings":"mKAAA,4D,aAOeA,iB","sourcesContent":["import Carousel from \"./Carousel\";\nexport type {\n TCarouselProps,\n ICarouselInstance,\n IComputedDirectionTypes,\n} from \"./types\";\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 _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useCheckMounted=require("../hooks/useCheckMounted");var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _store=require("../store");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var BaseLayout=function BaseLayout(props){var mounted=(0,_useCheckMounted.useCheckMounted)();var handlerOffset=props.handlerOffset,index=props.index,children=props.children,visibleRanges=props.visibleRanges,animationStyle=props.animationStyle;var context=_react.default.useContext(_store.CTX);var _context$props=context.props,loop=_context$props.loop,data=_context$props.data,width=_context$props.width,height=_context$props.height,vertical=_context$props.vertical,customConfig=_context$props.customConfig,mode=_context$props.mode,modeConfig=_context$props.modeConfig;var size=vertical?height:width;var _React$useState=_react.default.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),shouldUpdate=_React$useState2[0],setShouldUpdate=_React$useState2[1];var offsetXConfig=_objectSpread({handlerOffset:handlerOffset,index:index,size:size,data:data,loop:loop},typeof customConfig===
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.BaseLayout=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useCheckMounted=require("../hooks/useCheckMounted");var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _store=require("../store");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var BaseLayout=function BaseLayout(props){var mounted=(0,_useCheckMounted.useCheckMounted)();var handlerOffset=props.handlerOffset,index=props.index,children=props.children,visibleRanges=props.visibleRanges,animationStyle=props.animationStyle;var context=_react.default.useContext(_store.CTX);var _context$props=context.props,loop=_context$props.loop,data=_context$props.data,width=_context$props.width,height=_context$props.height,vertical=_context$props.vertical,customConfig=_context$props.customConfig,mode=_context$props.mode,modeConfig=_context$props.modeConfig;var size=vertical?height:width;var _React$useState=_react.default.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),shouldUpdate=_React$useState2[0],setShouldUpdate=_React$useState2[1];var offsetXConfig=_objectSpread({handlerOffset:handlerOffset,index:index,size:size,data:data,loop:loop},typeof customConfig==="function"?customConfig():{});if(mode==="horizontal-stack"){var _ref=modeConfig,snapDirection=_ref.snapDirection,showLength=_ref.showLength;offsetXConfig={handlerOffset:handlerOffset,index:index,size:size,data:data,loop:loop,type:snapDirection==="right"?"negative":"positive",viewCount:showLength};}var x=(0,_useOffsetX.useOffsetX)(offsetXConfig,visibleRanges);var animationValue=(0,_reactNativeReanimated.useDerivedValue)(function(){var _f=function _f(){return x.value/size;};_f._closure={x:x,size:size};_f.asString="function _f(){const{x,size}=jsThis._closure;{return x.value/size;}}";_f.__workletHash=9077192607952;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (74:41)";return _f;}(),[x,size]);var animatedStyle=(0,_reactNativeReanimated.useAnimatedStyle)(function(){var _f=function _f(){return animationStyle(x.value/size);};_f._closure={animationStyle:animationStyle,x:x,size:size};_f.asString="function _f(){const{animationStyle,x,size}=jsThis._closure;{return animationStyle(x.value/size);}}";_f.__workletHash=3916054905053;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (76:4)";_f.__optimalization=2;return _f;}(),[animationStyle]);var updateView=_react.default.useCallback(function(negativeRange,positiveRange){mounted.current&&setShouldUpdate(index>=negativeRange[0]&&index<=negativeRange[1]||index>=positiveRange[0]&&index<=positiveRange[1]);},[index,mounted]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return visibleRanges.value;};_f._closure={visibleRanges:visibleRanges};_f.asString="function _f(){const{visibleRanges}=jsThis._closure;{return visibleRanges.value;}}";_f.__workletHash=15231519758579;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (92:4)";return _f;}(),function(){var _f=function _f(){(0,_reactNativeReanimated.runOnJS)(updateView)(visibleRanges.value.negativeRange,visibleRanges.value.positiveRange);};_f._closure={runOnJS:_reactNativeReanimated.runOnJS,updateView:updateView,visibleRanges:visibleRanges};_f.asString="function _f(){const{runOnJS,updateView,visibleRanges}=jsThis._closure;{runOnJS(updateView)(visibleRanges.value.negativeRange,visibleRanges.value.positiveRange);}}";_f.__workletHash=6352504350554;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/BaseLayout.tsx (93:4)";return _f;}(),[visibleRanges.value]);return _react.default.createElement(_reactNativeReanimated.default.View,{style:[{width:width||"100%",height:height||"100%",position:"absolute"},animatedStyle],__self:_this,__source:{fileName:_jsxFileName,lineNumber:103,columnNumber:5}},_react.default.createElement(_LazyView.LazyView,{shouldUpdate:shouldUpdate,__self:_this,__source:{fileName:_jsxFileName,lineNumber:113,columnNumber:7}},children({animationValue:animationValue})));};exports.BaseLayout=BaseLayout;
|
|
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","data","width","height","vertical","customConfig","mode","modeConfig","size","useState","shouldUpdate","setShouldUpdate","offsetXConfig","snapDirection","showLength","type","viewCount","x","animationValue","value","animatedStyle","updateView","useCallback","negativeRange","positiveRange","current","runOnJS","position"],"mappings":"gWAAA,
|
|
1
|
+
{"version":3,"sources":["BaseLayout.tsx"],"names":["BaseLayout","props","mounted","handlerOffset","index","children","visibleRanges","animationStyle","context","React","useContext","CTX","loop","data","width","height","vertical","customConfig","mode","modeConfig","size","useState","shouldUpdate","setShouldUpdate","offsetXConfig","snapDirection","showLength","type","viewCount","x","animationValue","value","animatedStyle","updateView","useCallback","negativeRange","positiveRange","current","runOnJS","position"],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EE7B,aAAa,CAACyB,KAAd,CAAoBK,aAFtB,EAID,CAPH,sBAxFAE,8BAwFA,YAxFQL,UAwFR,eAxFuD3B,aAwFvD,kVAQE,CAACA,aAAa,CAACyB,KAAf,CARF,EAWA,MACE,8BAAC,8BAAD,CAAU,IAAV,EACE,KAAK,CAAE,CACL,CACEjB,KAAK,CAAEA,KAAK,EAAI,MADlB,CAEEC,MAAM,CAAEA,MAAM,EAAI,MAFpB,CAGEwB,QAAQ,CAAE,UAHZ,CADK,CAMLP,aANK,CADT,8EAUE,6BAAC,kBAAD,EAAU,YAAY,CAAEV,YAAxB,8EACGjB,QAAQ,CAAC,CAAEyB,cAAc,CAAdA,cAAF,CAAD,CADX,CAVF,CADF,CAgBD,CAhGM,C","sourcesContent":["import React from \"react\";\nimport type { ViewStyle } from \"react-native\";\nimport type { AnimatedStyleProp } from \"react-native-reanimated\";\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n useDerivedValue,\n} from \"react-native-reanimated\";\n\nimport type { ILayoutConfig } from \"./stack\";\n\nimport { useCheckMounted } from \"../hooks/useCheckMounted\";\nimport type { IOpts } from \"../hooks/useOffsetX\";\nimport { useOffsetX } from \"../hooks/useOffsetX\";\nimport type { IVisibleRanges } from \"../hooks/useVisibleRanges\";\nimport { LazyView } from \"../LazyView\";\nimport { CTX } from \"../store\";\n\nexport type TAnimationStyle = (value: number) => AnimatedStyleProp<ViewStyle>;\n\nexport const BaseLayout: React.FC<{\n index: number\n handlerOffset: Animated.SharedValue<number>\n visibleRanges: IVisibleRanges\n animationStyle: TAnimationStyle\n children: (ctx: {\n animationValue: Animated.SharedValue<number>\n }) => React.ReactElement\n}> = (props) => {\n const mounted = useCheckMounted();\n const { handlerOffset, index, children, visibleRanges, animationStyle }\n = props;\n\n const context = React.useContext(CTX);\n const {\n props: {\n loop,\n data,\n width,\n height,\n vertical,\n customConfig,\n mode,\n modeConfig,\n },\n } = context;\n const size = vertical ? height : width;\n const [shouldUpdate, setShouldUpdate] = React.useState(false);\n let offsetXConfig: IOpts = {\n handlerOffset,\n index,\n size,\n data,\n loop,\n ...(typeof customConfig === \"function\" ? customConfig() : {}),\n };\n\n if (mode === \"horizontal-stack\") {\n const { snapDirection, showLength } = modeConfig as ILayoutConfig;\n\n offsetXConfig = {\n handlerOffset,\n index,\n size,\n data,\n loop,\n type: snapDirection === \"right\" ? \"negative\" : \"positive\",\n viewCount: showLength,\n };\n }\n\n const x = useOffsetX(offsetXConfig, visibleRanges);\n const animationValue = useDerivedValue(() => x.value / size, [x, size]);\n const animatedStyle = useAnimatedStyle(\n () => animationStyle(x.value / size),\n [animationStyle],\n );\n\n const updateView = React.useCallback(\n (negativeRange: number[], positiveRange: number[]) => {\n mounted.current\n && setShouldUpdate(\n (index >= negativeRange[0] && index <= negativeRange[1])\n || (index >= positiveRange[0] && index <= positiveRange[1]),\n );\n },\n [index, mounted],\n );\n\n useAnimatedReaction(\n () => visibleRanges.value,\n () => {\n runOnJS(updateView)(\n visibleRanges.value.negativeRange,\n visibleRanges.value.positiveRange,\n );\n },\n [visibleRanges.value],\n );\n\n return (\n <Animated.View\n style={[\n {\n width: width || \"100%\",\n height: height || \"100%\",\n position: \"absolute\",\n },\n animatedStyle,\n ]}\n >\n <LazyView shouldUpdate={shouldUpdate}>\n {children({ animationValue })}\n </LazyView>\n </Animated.View>\n );\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ParallaxLayout=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var ParallaxLayout=function ParallaxLayout(props){var handlerOffset=props.handlerOffset,_props$parallaxScroll=props.parallaxScrollingOffset,parallaxScrollingOffset=_props$parallaxScroll===void 0?100:_props$parallaxScroll,_props$parallaxScroll2=props.parallaxScrollingScale,parallaxScrollingScale=_props$parallaxScroll2===void 0?0.8:_props$parallaxScroll2,_props$parallaxAdjace=props.parallaxAdjacentItemScale,parallaxAdjacentItemScale=_props$parallaxAdjace===void 0?Math.pow(parallaxScrollingScale,2):_props$parallaxAdjace,index=props.index,width=props.width,height=props.height,loop=props.loop,data=props.data,children=props.children,visibleRanges=props.visibleRanges,vertical=props.vertical;var _React$useState=_react.default.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),shouldUpdate=_React$useState2[0],setShouldUpdate=_React$useState2[1];var size=props.vertical?props.height:props.width;var x=(0,_useOffsetX.useOffsetX)({handlerOffset:handlerOffset,index:index,size:size,data:data,loop:loop},visibleRanges);var offsetXStyle=(0,_reactNativeReanimated.useAnimatedStyle)(function(){var _f=function _f(){var value=x.value/size;var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset],_reactNativeReanimated.Extrapolate.EXTEND);var zIndex=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[0,size,0],_reactNativeReanimated.Extrapolate.CLAMP);var scale=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],_reactNativeReanimated.Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};};_f._closure={x:x,size:size,interpolate:_reactNativeReanimated.interpolate,parallaxScrollingOffset:parallaxScrollingOffset,Extrapolate:{EXTEND:_reactNativeReanimated.Extrapolate.EXTEND,CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},parallaxAdjacentItemScale:parallaxAdjacentItemScale,parallaxScrollingScale:parallaxScrollingScale,vertical:vertical};_f.asString="function _f(){const{x,size,interpolate,parallaxScrollingOffset,Extrapolate,parallaxAdjacentItemScale,parallaxScrollingScale,vertical}=jsThis._closure;{const value=x.value/size;const translate=interpolate(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset],Extrapolate.EXTEND);const zIndex=interpolate(value,[-1,0,1],[0,size,0],Extrapolate.CLAMP);const scale=interpolate(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};}}";_f.__workletHash=10412925648231;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ParallaxLayout=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireDefault(require("react"));var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _useOffsetX=require("../hooks/useOffsetX");var _LazyView=require("../LazyView");var _this=this,_jsxFileName="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var ParallaxLayout=function ParallaxLayout(props){var handlerOffset=props.handlerOffset,_props$parallaxScroll=props.parallaxScrollingOffset,parallaxScrollingOffset=_props$parallaxScroll===void 0?100:_props$parallaxScroll,_props$parallaxScroll2=props.parallaxScrollingScale,parallaxScrollingScale=_props$parallaxScroll2===void 0?0.8:_props$parallaxScroll2,_props$parallaxAdjace=props.parallaxAdjacentItemScale,parallaxAdjacentItemScale=_props$parallaxAdjace===void 0?Math.pow(parallaxScrollingScale,2):_props$parallaxAdjace,index=props.index,width=props.width,height=props.height,loop=props.loop,data=props.data,children=props.children,visibleRanges=props.visibleRanges,vertical=props.vertical;var _React$useState=_react.default.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),shouldUpdate=_React$useState2[0],setShouldUpdate=_React$useState2[1];var size=props.vertical?props.height:props.width;var x=(0,_useOffsetX.useOffsetX)({handlerOffset:handlerOffset,index:index,size:size,data:data,loop:loop},visibleRanges);var offsetXStyle=(0,_reactNativeReanimated.useAnimatedStyle)(function(){var _f=function _f(){var value=x.value/size;var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset],_reactNativeReanimated.Extrapolate.EXTEND);var zIndex=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[0,size,0],_reactNativeReanimated.Extrapolate.CLAMP);var scale=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],_reactNativeReanimated.Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};};_f._closure={x:x,size:size,interpolate:_reactNativeReanimated.interpolate,parallaxScrollingOffset:parallaxScrollingOffset,Extrapolate:{EXTEND:_reactNativeReanimated.Extrapolate.EXTEND,CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},parallaxAdjacentItemScale:parallaxAdjacentItemScale,parallaxScrollingScale:parallaxScrollingScale,vertical:vertical};_f.asString="function _f(){const{x,size,interpolate,parallaxScrollingOffset,Extrapolate,parallaxAdjacentItemScale,parallaxScrollingScale,vertical}=jsThis._closure;{const value=x.value/size;const translate=interpolate(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset],Extrapolate.EXTEND);const zIndex=interpolate(value,[-1,0,1],[0,size,0],Extrapolate.CLAMP);const scale=interpolate(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};}}";_f.__workletHash=10412925648231;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (58:40)";_f.__optimalization=3;return _f;}(),[loop,vertical,parallaxScrollingOffset]);var updateView=_react.default.useCallback(function(negativeRange,positiveRange){setShouldUpdate(index>=negativeRange[0]&&index<=negativeRange[1]||index>=positiveRange[0]&&index<=positiveRange[1]);},[index]);(0,_reactNativeReanimated.useAnimatedReaction)(function(){var _f=function _f(){return visibleRanges.value;};_f._closure={visibleRanges:visibleRanges};_f.asString="function _f(){const{visibleRanges}=jsThis._closure;{return visibleRanges.value;}}";_f.__workletHash=15231519758579;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (118:4)";return _f;}(),function(){var _f=function _f(){(0,_reactNativeReanimated.runOnJS)(updateView)(visibleRanges.value.negativeRange,visibleRanges.value.positiveRange);};_f._closure={runOnJS:_reactNativeReanimated.runOnJS,updateView:updateView,visibleRanges:visibleRanges};_f.asString="function _f(){const{runOnJS,updateView,visibleRanges}=jsThis._closure;{runOnJS(updateView)(visibleRanges.value.negativeRange,visibleRanges.value.positiveRange);}}";_f.__workletHash=6352504350554;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/ParallaxLayout.tsx (119:4)";return _f;}(),[visibleRanges.value]);return _react.default.createElement(_reactNativeReanimated.default.View,{style:[{width:width||"100%",height:height||"100%",position:"absolute"},offsetXStyle],__self:_this,__source:{fileName:_jsxFileName,lineNumber:129,columnNumber:5}},_react.default.createElement(_LazyView.LazyView,{shouldUpdate:shouldUpdate,__self:_this,__source:{fileName:_jsxFileName,lineNumber:139,columnNumber:7}},children));};exports.ParallaxLayout=ParallaxLayout;
|
|
2
2
|
//# sourceMappingURL=ParallaxLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ParallaxLayout.tsx"],"names":["ParallaxLayout","props","handlerOffset","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","
|
|
1
|
+
{"version":3,"sources":["ParallaxLayout.tsx"],"names":["ParallaxLayout","props","handlerOffset","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","index","width","height","loop","data","children","visibleRanges","vertical","React","useState","shouldUpdate","setShouldUpdate","size","x","offsetXStyle","value","translate","Extrapolate","EXTEND","zIndex","CLAMP","scale","transform","translateY","translateX","interpolate","updateView","useCallback","negativeRange","positiveRange","runOnJS","position"],"mappings":"sQAAA,oDACA,uFAUA,+CAEA,qC,unCAGO,GAAMA,CAAAA,cAUZ,CAAG,QAVSA,CAAAA,cAUT,CAACC,KAAD,CAAW,CACb,GACEC,CAAAA,aADF,CAaID,KAbJ,CACEC,aADF,uBAaID,KAbJ,CAEEE,uBAFF,CAEEA,uBAFF,gCAE4B,GAF5B,8CAaIF,KAbJ,CAGEG,sBAHF,CAGEA,sBAHF,iCAG2B,GAH3B,8CAaIH,KAbJ,CAIEI,yBAJF,CAIEA,yBAJF,yCAI8BD,sBAJ9B,CAIwD,CAJxD,wBAKEE,KALF,CAaIL,KAbJ,CAKEK,KALF,CAMEC,KANF,CAaIN,KAbJ,CAMEM,KANF,CAOEC,MAPF,CAaIP,KAbJ,CAOEO,MAPF,CAQEC,IARF,CAaIR,KAbJ,CAQEQ,IARF,CASEC,IATF,CAaIT,KAbJ,CASES,IATF,CAUEC,QAVF,CAaIV,KAbJ,CAUEU,QAVF,CAWEC,aAXF,CAaIX,KAbJ,CAWEW,aAXF,CAYEC,QAZF,CAaIZ,KAbJ,CAYEY,QAZF,CAeA,oBAAwCC,eAAMC,QAAN,CAAe,KAAf,CAAxC,iEAAOC,YAAP,qBAAqBC,eAArB,qBAEA,GAAMC,CAAAA,IAAI,CAAGjB,KAAK,CAACY,QAAN,CAAiBZ,KAAK,CAACO,MAAvB,CAAgCP,KAAK,CAACM,KAAnD,CAEA,GAAMY,CAAAA,CAAC,CAAG,2BACR,CACEjB,aAAa,CAAbA,aADF,CAEEI,KAAK,CAALA,KAFF,CAGEY,IAAI,CAAJA,IAHF,CAIER,IAAI,CAAJA,IAJF,CAKED,IAAI,CAAJA,IALF,CADQ,CA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0BC,aAA1B,CAAsD,CACpDlB,eAAe,CACZX,KAAK,EAAI4B,aAAa,CAAC,CAAD,CAAtB,EAA6B5B,KAAK,EAAI4B,aAAa,CAAC,CAAD,CAApD,EACgB5B,KAAK,EAAI6B,aAAa,CAAC,CAAD,CAAtB,EAA6B7B,KAAK,EAAI6B,aAAa,CAAC,CAAD,CAFtD,CAAf,CAID,CANgB,CAOjB,CAAC7B,KAAD,CAPiB,CAAnB,CAUA,iEACE,oBAAMM,CAAAA,aAAa,CAACS,KAApB,EADF,4BAnHKT,aAmHL,sSAEQ,CACJ,mCAAQoB,UAAR,EACEpB,aAAa,CAACS,KAAd,CAAoBa,aADtB,CAEEtB,aAAa,CAACS,KAAd,CAAoBc,aAFtB,EAID,CAPH,sBAlHAC,8BAkHA,YAlHQJ,UAkHR,eAlHuDpB,aAkHvD,uVAQE,CAACA,aAAa,CAACS,KAAf,CARF,EAWA,MACE,8BAAC,8BAAD,CAAU,IAAV,EACE,KAAK,CAAE,CACL,CACEd,KAAK,CAAEA,KAAK,EAAI,MADlB,CAEEC,MAAM,CAAEA,MAAM,EAAI,MAFpB,CAGE6B,QAAQ,CAAE,UAHZ,CADK,CAMLjB,YANK,CADT,8EAUE,6BAAC,kBAAD,EAAU,YAAY,CAAEJ,YAAxB,8EAAuCL,QAAvC,CAVF,CADF,CAcD,CA7HM,C","sourcesContent":["import React from \"react\";\nimport Animated, {\n Extrapolate,\n interpolate,\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n} from \"react-native-reanimated\";\n\nimport type { ILayoutConfig } from \"./parallax\";\n\nimport { useOffsetX } from \"../hooks/useOffsetX\";\nimport type { IVisibleRanges } from \"../hooks/useVisibleRanges\";\nimport { LazyView } from \"../LazyView\";\nimport type { IComputedDirectionTypes } from \"../types\";\n\nexport const ParallaxLayout: React.FC<\nIComputedDirectionTypes<\n{\n loop?: boolean\n handlerOffset: Animated.SharedValue<number>\n index: number\n data: unknown[]\n visibleRanges: IVisibleRanges\n} & ILayoutConfig\n>\n> = (props) => {\n const {\n handlerOffset,\n parallaxScrollingOffset = 100,\n parallaxScrollingScale = 0.8,\n parallaxAdjacentItemScale = parallaxScrollingScale ** 2,\n index,\n width,\n height,\n loop,\n data,\n children,\n visibleRanges,\n vertical,\n } = props;\n\n const [shouldUpdate, setShouldUpdate] = React.useState(false);\n\n const size = props.vertical ? props.height : props.width;\n\n const x = useOffsetX(\n {\n handlerOffset,\n index,\n size,\n data,\n loop,\n },\n visibleRanges,\n );\n\n const offsetXStyle = useAnimatedStyle(() => {\n const value = x.value / size;\n\n const translate = interpolate(\n value,\n [-1, 0, 1],\n [\n -size + parallaxScrollingOffset,\n 0,\n size - parallaxScrollingOffset,\n ],\n Extrapolate.EXTEND,\n );\n\n const zIndex = interpolate(\n value,\n [-1, 0, 1],\n [0, size, 0],\n Extrapolate.CLAMP,\n );\n\n const scale = interpolate(\n value,\n [-1, 0, 1],\n [\n parallaxAdjacentItemScale,\n parallaxScrollingScale,\n parallaxAdjacentItemScale,\n ],\n Extrapolate.CLAMP,\n );\n\n return {\n transform: [\n vertical\n ? {\n translateY: translate,\n }\n : {\n translateX: translate,\n },\n {\n scale,\n },\n ],\n zIndex,\n };\n }, [loop, vertical, parallaxScrollingOffset]);\n\n const updateView = React.useCallback(\n (negativeRange: number[], positiveRange: number[]) => {\n setShouldUpdate(\n (index >= negativeRange[0] && index <= negativeRange[1])\n || (index >= positiveRange[0] && index <= positiveRange[1]),\n );\n },\n [index],\n );\n\n useAnimatedReaction(\n () => visibleRanges.value,\n () => {\n runOnJS(updateView)(\n visibleRanges.value.negativeRange,\n visibleRanges.value.positiveRange,\n );\n },\n [visibleRanges.value],\n );\n\n return (\n <Animated.View\n style={[\n {\n width: width || \"100%\",\n height: height || \"100%\",\n position: \"absolute\",\n },\n offsetXStyle,\n ]}\n >\n <LazyView shouldUpdate={shouldUpdate}>{children}</LazyView>\n </Animated.View>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["Layouts","normal","normalLayout","parallax","parallaxLayout","horizontalStack","horizontalStackLayout","verticalStack","verticalStackLayout"],"mappings":"gFAAA,gCACA,oCACA,8BAIO,GAAMA,CAAAA,OAAO,CAAG,
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["Layouts","normal","normalLayout","parallax","parallaxLayout","horizontalStack","horizontalStackLayout","verticalStack","verticalStackLayout"],"mappings":"gFAAA,gCACA,oCACA,8BAIO,GAAMA,CAAAA,OAAO,CAAG,CACrBC,MAAM,CAAEC,oBADa,CAErBC,QAAQ,CAAEC,wBAFW,CAGrBC,eAAe,CAAEC,4BAHI,CAIrBC,aAAa,CAAEC,0BAJM,CAAhB,C","sourcesContent":["import { normalLayout } from \"./normal\";\nimport { parallaxLayout } from \"./parallax\";\nimport { horizontalStackLayout, verticalStackLayout } from \"./stack\";\n\nexport type TMode = \"parallax\" | \"horizontal-stack\" | \"vertical-stack\";\n\nexport const Layouts = {\n normal: normalLayout,\n parallax: parallaxLayout,\n horizontalStack: horizontalStackLayout,\n verticalStack: verticalStackLayout,\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.normalLayout=normalLayout;var _reactNativeReanimated=require("react-native-reanimated");function normalLayout(opts){var size=opts.size,vertical=opts.vertical;return function(){var _f=function _f(value){var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size,0,size]);return{transform:[vertical?{translateY:translate}:{translateX:translate}]};};_f._closure={interpolate:_reactNativeReanimated.interpolate,size:size,vertical:vertical};_f.asString="function _f(value){const{interpolate,size,vertical}=jsThis._closure;{const translate=interpolate(value,[-1,0,1],[-size,0,size]);return{transform:[vertical?{translateY:translate}:{translateX:translate}]};}}";_f.__workletHash=10942319418565;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/normal.ts (6:
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.normalLayout=normalLayout;var _reactNativeReanimated=require("react-native-reanimated");function normalLayout(opts){var size=opts.size,vertical=opts.vertical;return function(){var _f=function _f(value){var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size,0,size]);return{transform:[vertical?{translateY:translate}:{translateX:translate}]};};_f._closure={interpolate:_reactNativeReanimated.interpolate,size:size,vertical:vertical};_f.asString="function _f(value){const{interpolate,size,vertical}=jsThis._closure;{const translate=interpolate(value,[-1,0,1],[-size,0,size]);return{transform:[vertical?{translateY:translate}:{translateX:translate}]};}}";_f.__workletHash=10942319418565;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/normal.ts (6:9)";return _f;}();}
|
|
2
2
|
//# sourceMappingURL=normal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["normal.ts"],"names":["normalLayout","opts","size","vertical","value","translate","transform","translateY","translateX","interpolate"],"mappings":"2FAAA,8DAEO,QAASA,CAAAA,YAAT,CAAsBC,IAAtB,CAAiE,
|
|
1
|
+
{"version":3,"sources":["normal.ts"],"names":["normalLayout","opts","size","vertical","value","translate","transform","translateY","translateX","interpolate"],"mappings":"2FAAA,8DAEO,QAASA,CAAAA,YAAT,CAAsBC,IAAtB,CAAiE,CACtE,GAAQC,CAAAA,IAAR,CAA2BD,IAA3B,CAAQC,IAAR,CAAcC,QAAd,CAA2BF,IAA3B,CAAcE,QAAd,CAEA,qCAAQC,KAAR,CAA0B,CAExB,GAAMC,CAAAA,SAAS,CAAG,uCAAYD,KAAZ,CAAmB,CAAC,CAAC,CAAF,CAAK,CAAL,CAAQ,CAAR,CAAnB,CAA+B,CAAC,CAACF,IAAF,CAAQ,CAAR,CAAWA,IAAX,CAA/B,CAAlB,CAEA,MAAO,CACLI,SAAS,CAAE,CACTH,QAAQ,CACJ,CACAI,UAAU,CAAEF,SADZ,CADI,CAIJ,CACAG,UAAU,CAAEH,SADZ,CALK,CADN,CAAP,CAWD,CAfD,0BAHkBI,kCAGlB,MAH4DP,IAG5D,UADcC,QACd,wXAgBD","sourcesContent":["import { interpolate } from \"react-native-reanimated\";\n\nexport function normalLayout(opts: { size: number; vertical: boolean }) {\n const { size, vertical } = opts;\n\n return (value: number) => {\n \"worklet\";\n const translate = interpolate(value, [-1, 0, 1], [-size, 0, size]);\n\n return {\n transform: [\n vertical\n ? {\n translateY: translate,\n }\n : {\n translateX: translate,\n },\n ],\n };\n };\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.parallaxLayout=parallaxLayout;var _reactNativeReanimated=require("react-native-reanimated");function parallaxLayout(baseConfig){var modeConfig=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var size=baseConfig.size,vertical=baseConfig.vertical;var _modeConfig$parallaxS=modeConfig.parallaxScrollingOffset,parallaxScrollingOffset=_modeConfig$parallaxS===void 0?100:_modeConfig$parallaxS,_modeConfig$parallaxS2=modeConfig.parallaxScrollingScale,parallaxScrollingScale=_modeConfig$parallaxS2===void 0?0.8:_modeConfig$parallaxS2,_modeConfig$parallaxA=modeConfig.parallaxAdjacentItemScale,parallaxAdjacentItemScale=_modeConfig$parallaxA===void 0?Math.pow(parallaxScrollingScale,2):_modeConfig$parallaxA;return function(){var _f=function _f(value){var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset]);var zIndex=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[0,size,0],_reactNativeReanimated.Extrapolate.CLAMP);var scale=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],_reactNativeReanimated.Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};};_f._closure={interpolate:_reactNativeReanimated.interpolate,size:size,parallaxScrollingOffset:parallaxScrollingOffset,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},parallaxAdjacentItemScale:parallaxAdjacentItemScale,parallaxScrollingScale:parallaxScrollingScale,vertical:vertical};_f.asString="function _f(value){const{interpolate,size,parallaxScrollingOffset,Extrapolate,parallaxAdjacentItemScale,parallaxScrollingScale,vertical}=jsThis._closure;{const translate=interpolate(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset]);const zIndex=interpolate(value,[-1,0,1],[0,size,0],Extrapolate.CLAMP);const scale=interpolate(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};}}";_f.__workletHash=942233491674;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/parallax.ts (
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.parallaxLayout=parallaxLayout;var _reactNativeReanimated=require("react-native-reanimated");function parallaxLayout(baseConfig){var modeConfig=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var size=baseConfig.size,vertical=baseConfig.vertical;var _modeConfig$parallaxS=modeConfig.parallaxScrollingOffset,parallaxScrollingOffset=_modeConfig$parallaxS===void 0?100:_modeConfig$parallaxS,_modeConfig$parallaxS2=modeConfig.parallaxScrollingScale,parallaxScrollingScale=_modeConfig$parallaxS2===void 0?0.8:_modeConfig$parallaxS2,_modeConfig$parallaxA=modeConfig.parallaxAdjacentItemScale,parallaxAdjacentItemScale=_modeConfig$parallaxA===void 0?Math.pow(parallaxScrollingScale,2):_modeConfig$parallaxA;return function(){var _f=function _f(value){var translate=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset]);var zIndex=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[0,size,0],_reactNativeReanimated.Extrapolate.CLAMP);var scale=(0,_reactNativeReanimated.interpolate)(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],_reactNativeReanimated.Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};};_f._closure={interpolate:_reactNativeReanimated.interpolate,size:size,parallaxScrollingOffset:parallaxScrollingOffset,Extrapolate:{CLAMP:_reactNativeReanimated.Extrapolate.CLAMP},parallaxAdjacentItemScale:parallaxAdjacentItemScale,parallaxScrollingScale:parallaxScrollingScale,vertical:vertical};_f.asString="function _f(value){const{interpolate,size,parallaxScrollingOffset,Extrapolate,parallaxAdjacentItemScale,parallaxScrollingScale,vertical}=jsThis._closure;{const translate=interpolate(value,[-1,0,1],[-size+parallaxScrollingOffset,0,size-parallaxScrollingOffset]);const zIndex=interpolate(value,[-1,0,1],[0,size,0],Extrapolate.CLAMP);const scale=interpolate(value,[-1,0,1],[parallaxAdjacentItemScale,parallaxScrollingScale,parallaxAdjacentItemScale],Extrapolate.CLAMP);return{transform:[vertical?{translateY:translate}:{translateX:translate},{scale:scale}],zIndex:zIndex};}}";_f.__workletHash=942233491674;_f.__location="/Users/zhaodonghao/code/github/react-native-reanimated-carousel/src/layouts/parallax.ts (47:9)";return _f;}();}
|
|
2
2
|
//# sourceMappingURL=parallax.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["parallax.ts"],"names":["parallaxLayout","baseConfig","modeConfig","size","vertical","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","
|
|
1
|
+
{"version":3,"sources":["parallax.ts"],"names":["parallaxLayout","baseConfig","modeConfig","size","vertical","parallaxScrollingOffset","parallaxScrollingScale","parallaxAdjacentItemScale","value","translate","zIndex","Extrapolate","CLAMP","scale","transform","translateY","translateX","interpolate"],"mappings":"+FAAA,8DAmCO,QAASA,CAAAA,cAAT,CACLC,UADK,CAGL,IADAC,CAAAA,UACA,2DAD4B,EAC5B,CACA,GAAQC,CAAAA,IAAR,CAA2BF,UAA3B,CAAQE,IAAR,CAAcC,QAA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Types } from \"../types\";\n\ninterface TBaseConfig {\n size: number\n vertical: boolean\n}\n\nexport interface ILayoutConfig {\n /**\n * control prev/next item offset.\n * @default 100\n */\n parallaxScrollingOffset?: number\n /**\n * control prev/current/next item offset.\n * @default 0.8\n */\n parallaxScrollingScale?: number\n /**\n * control prev/next item offset.\n * @default Math.pow(parallaxScrollingScale, 2)\n */\n parallaxAdjacentItemScale?: number\n}\n\nexport type TParallaxModeProps = IComputedDirectionTypes<{\n /**\n * Carousel Animated transitions.\n */\n mode?: \"parallax\"\n modeConfig?: ILayoutConfig\n}>;\n\nexport function parallaxLayout(\n baseConfig: TBaseConfig,\n modeConfig: ILayoutConfig = {},\n) {\n const { size, vertical } = baseConfig;\n const {\n parallaxScrollingOffset = 100,\n parallaxScrollingScale = 0.8,\n parallaxAdjacentItemScale = parallaxScrollingScale ** 2,\n } = modeConfig;\n\n return (value: number) => {\n \"worklet\";\n const translate = interpolate(\n value,\n [-1, 0, 1],\n [-size + parallaxScrollingOffset, 0, size - parallaxScrollingOffset],\n );\n\n const zIndex = interpolate(\n value,\n [-1, 0, 1],\n [0, size, 0],\n Extrapolate.CLAMP,\n );\n\n const scale = interpolate(\n value,\n [-1, 0, 1],\n [\n parallaxAdjacentItemScale,\n parallaxScrollingScale,\n parallaxAdjacentItemScale,\n ],\n Extrapolate.CLAMP,\n );\n\n return {\n transform: [\n vertical\n ? {\n translateY: translate,\n }\n : {\n translateX: translate,\n },\n {\n scale,\n },\n ],\n zIndex,\n };\n };\n}\n"]}
|