react-native-reanimated-carousel
Version:
Simple carousel component.fully implemented using Reanimated 2.Infinitely scrolling, very smooth.
2 lines • 12.7 kB
JavaScript
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.PaginationItem=void 0;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _jsxRuntime=require("react/jsx-runtime");var _excluded=["width","height","borderRadius","backgroundColor"],_excluded2=["width","height","borderRadius","backgroundColor"];var _this=this,_jsxFileName="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/components/Pagination/Custom/PaginationItem.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}var _worklet_10273207657391_init_data={code:"function anonymous(){const{runOnJS,handleCustomAnimation,animValue}=this.__closure;var _animValue;runOnJS(handleCustomAnimation)((_animValue=animValue)===null||_animValue===void 0?void 0:_animValue.value);}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/components/Pagination/Custom/PaginationItem.tsx",sourceMap:"{\"version\":3,\"mappings\":\"AAyDkB,QAAAA,UAAA,EAAM,kEAAAC,WAAA,4GACpBC\",\"names\":[\"anonymous\",\"_animValue\",\"runOnJS\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/components/Pagination/Custom/PaginationItem.tsx\"]}",version:"3.10.1"};var _worklet_9217897742613_init_data={code:"function anonymous(){const{size,defaultDotSize,dotStyle,activeDotStyle,animValue,index,count,interpolate,Extrapolation,interpolateColor,customReanimatedStyleRef}=this.__closure;var _dotStyle,_activeDotStyle,_animValue,_animValue2,_animValue3,_ref,_ref2,_customReanimatedStyl,_restStyle$transform,_customReanimatedStyl2,_customReanimatedStyl3;const{width=size||defaultDotSize,height=size||defaultDotSize,borderRadius:borderRadius,backgroundColor=\"#FFF\",...restDotStyle}=(_dotStyle=dotStyle)!==null&&_dotStyle!==void 0?_dotStyle:{};const{width:activeWidth=width,height:activeHeight=height,borderRadius:activeBorderRadius,backgroundColor:activeBackgroundColor=\"#000\",...restActiveDotStyle}=(_activeDotStyle=activeDotStyle)!==null&&_activeDotStyle!==void 0?_activeDotStyle:{};let val=Math.abs(((_animValue=animValue)===null||_animValue===void 0?void 0:_animValue.value)-index);if(index===0&&((_animValue2=animValue)===null||_animValue2===void 0?void 0:_animValue2.value)>count-1)val=Math.abs(((_animValue3=animValue)===null||_animValue3===void 0?void 0:_animValue3.value)-count);const inputRange=[0,1,2];const restStyle=(_ref=val===0?restActiveDotStyle:restDotStyle)!==null&&_ref!==void 0?_ref:{};return{width:interpolate(val,inputRange,[activeWidth,width,width],Extrapolation.CLAMP),height:interpolate(val,inputRange,[activeHeight,height,height],Extrapolation.CLAMP),borderRadius:interpolate(val,inputRange,[(_ref2=activeBorderRadius!==null&&activeBorderRadius!==void 0?activeBorderRadius:borderRadius)!==null&&_ref2!==void 0?_ref2:0,borderRadius!==null&&borderRadius!==void 0?borderRadius:0,borderRadius!==null&&borderRadius!==void 0?borderRadius:0],Extrapolation.CLAMP),backgroundColor:interpolateColor(val,inputRange,[activeBackgroundColor,backgroundColor,backgroundColor]),...restStyle,...((_customReanimatedStyl=customReanimatedStyleRef.value)!==null&&_customReanimatedStyl!==void 0?_customReanimatedStyl:{}),transform:[...((_restStyle$transform=restStyle===null||restStyle===void 0?void 0:restStyle.transform)!==null&&_restStyle$transform!==void 0?_restStyle$transform:[]),...((_customReanimatedStyl2=(_customReanimatedStyl3=customReanimatedStyleRef.value)===null||_customReanimatedStyl3===void 0?void 0:_customReanimatedStyl3.transform)!==null&&_customReanimatedStyl2!==void 0?_customReanimatedStyl2:[])]};}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/components/Pagination/Custom/PaginationItem.tsx",sourceMap:"{\"version\":3,\"mappings\":\"AA6DqC,QAAAA,UAAA,EAAoB,gKAAAC,UAAA,CAAAC,eAAA,CAAAC,UAAA,CAAAC,WAAA,CAAAC,WAAA,CAAAC,IAAA,CAAAC,KAAA,CAAAC,qBAAA,CAAAC,oBAAA,CAAAC,sBAAA,CAAAC,sBAAA,OACrDC,KAAM,CAAAC,IAAA,EAAAC,eACJF,MAAK,CAAGC,IAAI,EAAIC,eAChBC,YAASF,CAAIG,aACbA,uBACAC,iBACA,CAAGC,kBAAH,IAAGA,IAAH,EAAGA,kBAAH,CAAGA,SAAH,CAAGA,GALC,MAONN,KAAM,CAAAO,WAAA,CAAAP,KAPA,CAQJA,MAAK,CAAEO,YAAW,CAAGP,MARjB,CASJG,YAAQK,mBATJ,CAUJJ,eAAcK,sBAHV,OAPA,CAWJJ,qBAXI,EAYJ,CAAGK,8BAAH,IAAGA,IAAH,EAAGA,wBAAH,CAAGA,eAAH,CAAGA,EAZC,CAOA,GAAAC,IAAA,CAAAC,IAAA,CAAAC,GAAA,GAAAtB,UAMFuB,UANE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AA,SAcFwB,CAdExB,qBAcFwB,CAdE,EAcL,CAhBIA,CAiBJM,SAAA,OAAA7B,oBAAI4B,aAAyBV,IAAzBU,EAAJL,SAAA,SAAIK,CAAJ,MAAIA,CAAJL,SAAA,CAAAM,SAAA,UAAA7B,oBAfK,SAeL,CAfKA,oBAeL,CAfK,EAeL,EAfK,KAAAC,sBAAA,EAAAC,sBAAA,CAAA0B,wBAAA,CAAAV,KAAA,UAAAhB,sBAAA,iBAAAA,sBAAA,CAAA2B,SAAA,UAAA5B,sBAAA,UAAAA,sBAAA,IAeL,CAjBIsB,CAAN,CAEO\",\"names\":[\"anonymous\",\"_dotStyle\",\"_activeDotStyle\",\"_animValue\",\"_animValue2\",\"_animValue3\",\"_ref\",\"_ref2\",\"_customReanimatedStyl\",\"_restStyle$transform\",\"_customReanimatedStyl2\",\"_customReanimatedStyl3\",\"width\",\"size\",\"defaultDotSize\",\"height\",\"borderRadius\",\"backgroundColor\",\"restDotStyle\",\"activeWidth\",\"activeHeight\",\"activeBorderRadius\",\"restActiveDotStyle\",\"val\",\"Math\",\"abs\",\"activeDotStyle\",\"value\",\"index\",\"animValue\",\"count\",\"inputRange\",\"restStyle\",\"interpolate\",\"Extrapolation\",\"CLAMP\",\"activeBackgroundColor\",\"customReanimatedStyleRef\",\"transform\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/components/Pagination/Custom/PaginationItem.tsx\"]}",version:"3.10.1"};var PaginationItem=function PaginationItem(props){var defaultDotSize=10;var animValue=props.animValue,dotStyle=props.dotStyle,activeDotStyle=props.activeDotStyle,index=props.index,count=props.count,size=props.size,horizontal=props.horizontal,children=props.children,customReanimatedStyle=props.customReanimatedStyle,onPress=props.onPress,accessibilityLabel=props.accessibilityLabel;var customReanimatedStyleRef=(0,_reactNativeReanimated.useSharedValue)({});var handleCustomAnimation=function handleCustomAnimation(progress){var _customReanimatedStyl;customReanimatedStyleRef.value=(_customReanimatedStyl=customReanimatedStyle==null?void 0:customReanimatedStyle(progress,index,count))!=null?_customReanimatedStyl:{};};(0,_reactNativeReanimated.useDerivedValue)(function(){var _e=[new global.Error(),-4,-27];var anonymous=function anonymous(){(0,_reactNativeReanimated.runOnJS)(handleCustomAnimation)(animValue==null?void 0:animValue.value);};anonymous.__closure={runOnJS:_reactNativeReanimated.runOnJS,handleCustomAnimation:handleCustomAnimation,animValue:animValue};anonymous.__workletHash=10273207657391;anonymous.__initData=_worklet_10273207657391_init_data;anonymous.__stackDetails=_e;return anonymous;}());var animStyle=(0,_reactNativeReanimated.useAnimatedStyle)(function(){var _e=[new global.Error(),-12,-27];var anonymous=function anonymous(){var _ref3,_ref4,_customReanimatedStyl2,_restStyle$transform,_customReanimatedStyl3,_customReanimatedStyl4;var _ref=dotStyle!=null?dotStyle:{},_ref$width=_ref.width,width=_ref$width===void 0?size||defaultDotSize:_ref$width,_ref$height=_ref.height,height=_ref$height===void 0?size||defaultDotSize:_ref$height,borderRadius=_ref.borderRadius,_ref$backgroundColor=_ref.backgroundColor,backgroundColor=_ref$backgroundColor===void 0?"#FFF":_ref$backgroundColor,restDotStyle=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _ref2=activeDotStyle!=null?activeDotStyle:{},_ref2$width=_ref2.width,activeWidth=_ref2$width===void 0?width:_ref2$width,_ref2$height=_ref2.height,activeHeight=_ref2$height===void 0?height:_ref2$height,activeBorderRadius=_ref2.borderRadius,_ref2$backgroundColor=_ref2.backgroundColor,activeBackgroundColor=_ref2$backgroundColor===void 0?"#000":_ref2$backgroundColor,restActiveDotStyle=(0,_objectWithoutProperties2.default)(_ref2,_excluded2);var val=Math.abs((animValue==null?void 0:animValue.value)-index);if(index===0&&(animValue==null?void 0:animValue.value)>count-1)val=Math.abs((animValue==null?void 0:animValue.value)-count);var inputRange=[0,1,2];var restStyle=(_ref3=val===0?restActiveDotStyle:restDotStyle)!=null?_ref3:{};return Object.assign({width:(0,_reactNativeReanimated.interpolate)(val,inputRange,[activeWidth,width,width],_reactNativeReanimated.Extrapolation.CLAMP),height:(0,_reactNativeReanimated.interpolate)(val,inputRange,[activeHeight,height,height],_reactNativeReanimated.Extrapolation.CLAMP),borderRadius:(0,_reactNativeReanimated.interpolate)(val,inputRange,[(_ref4=activeBorderRadius!=null?activeBorderRadius:borderRadius)!=null?_ref4:0,borderRadius!=null?borderRadius:0,borderRadius!=null?borderRadius:0],_reactNativeReanimated.Extrapolation.CLAMP),backgroundColor:(0,_reactNativeReanimated.interpolateColor)(val,inputRange,[activeBackgroundColor,backgroundColor,backgroundColor])},restStyle,(_customReanimatedStyl2=customReanimatedStyleRef.value)!=null?_customReanimatedStyl2:{},{transform:[].concat((0,_toConsumableArray2.default)((_restStyle$transform=restStyle==null?void 0:restStyle.transform)!=null?_restStyle$transform:[]),(0,_toConsumableArray2.default)((_customReanimatedStyl3=(_customReanimatedStyl4=customReanimatedStyleRef.value)==null?void 0:_customReanimatedStyl4.transform)!=null?_customReanimatedStyl3:[]))});};anonymous.__closure={size:size,defaultDotSize:defaultDotSize,dotStyle:dotStyle,activeDotStyle:activeDotStyle,animValue:animValue,index:index,count:count,interpolate:_reactNativeReanimated.interpolate,Extrapolation:_reactNativeReanimated.Extrapolation,interpolateColor:_reactNativeReanimated.interpolateColor,customReanimatedStyleRef:customReanimatedStyleRef};anonymous.__workletHash=9217897742613;anonymous.__initData=_worklet_9217897742613_init_data;anonymous.__stackDetails=_e;return anonymous;}(),[animValue,index,count,horizontal,dotStyle,activeDotStyle,customReanimatedStyle]);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:onPress,accessibilityLabel:accessibilityLabel,accessibilityRole:"button",accessibilityHint:animValue.value===index?"":`Go to ${accessibilityLabel}`,accessibilityState:{selected:animValue.value===index},children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{overflow:"hidden",transform:[{rotateZ:horizontal?"90deg":"0deg"}]},dotStyle,animStyle],children:children})});};exports.PaginationItem=PaginationItem;
//# sourceMappingURL=PaginationItem.js.map