UNPKG

react-native-reanimated-carousel

Version:

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

2 lines 5.27 kB
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.PaginationItem=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated"));var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/components/Pagination/Basic/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_14422051368407_init_data={code:"function anonymous(){const{horizontal,height,width,index,animValue,count,interpolate,Extrapolation}=this.__closure;var _animValue,_animValue2;const size=horizontal?height:width;let inputRange=[index-1,index,index+1];let outputRange=[-size,0,size];if(index===0&&((_animValue=animValue)===null||_animValue===void 0?void 0:_animValue.value)>count-1){inputRange=[count-1,count,count+1];outputRange=[-size,0,size];}return{transform:[{translateX:interpolate((_animValue2=animValue)===null||_animValue2===void 0?void 0:_animValue2.value,inputRange,outputRange,Extrapolation.CLAMP)}]};}",location:"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/components/Pagination/Basic/PaginationItem.tsx",sourceMap:"{\"version\":3,\"mappings\":\"AAwDqC,QAAAA,UAAA,EAAM,kGAAAC,WAAA,CAAAC,WAAA,oCACvC,GAAAC,WAAaC,OAAU,CAAGC,CAAbD,CAAaC,KAAbD,CAAsBE,KAAnC,EAAaF,CAAb,CACA,GAAID,YAAU,CAAII,OAAQ,CAARA,CAAWA,IAAXA,CAAlB,CACA,GAAIC,WAAe,CAACC,WAASA,CAA7BC,SAAoBD,IAApB,IAAoBA,EAApBR,UAAA,SAAoBQ,CAApB,MAAoBA,CAApBR,UAAA,CAAAU,KAAmB,EAAnBC,KAAA,uCAEAJ,WAAS,CAALD,OAAeG,CAAfH,CAAeG,IAAfH,CAAJ,CACEJ,CACAK,OACFK,SAAA,qJADEL,EAMIM\",\"names\":[\"anonymous\",\"_animValue\",\"_animValue2\",\"inputRange\",\"horizontal\",\"height\",\"width\",\"index\",\"outputRange\",\"size\",\"animValue\",\"value\",\"count\",\"transform\",\"translateX\"],\"sources\":[\"/home/runner/work/react-native-reanimated-carousel/react-native-reanimated-carousel/src/components/Pagination/Basic/PaginationItem.tsx\"]}",version:"3.10.1"};var PaginationItem=function PaginationItem(props){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,onPress=props.onPress,accessibilityLabel=props.accessibilityLabel;var defaultDotSize=10;var sizes={width:size||(dotStyle==null?void 0:dotStyle.width)||defaultDotSize,height:size||(dotStyle==null?void 0:dotStyle.height)||defaultDotSize};var width=sizes.width;var height=sizes.height;var animStyle=(0,_reactNativeReanimated.useAnimatedStyle)(function(){var _e=[new global.Error(),-9,-27];var anonymous=function anonymous(){var size=horizontal?height:width;var inputRange=[index-1,index,index+1];var outputRange=[-size,0,size];if(index===0&&(animValue==null?void 0:animValue.value)>count-1){inputRange=[count-1,count,count+1];outputRange=[-size,0,size];}return{transform:[{translateX:(0,_reactNativeReanimated.interpolate)(animValue==null?void 0:animValue.value,inputRange,outputRange,_reactNativeReanimated.Extrapolation.CLAMP)}]};};anonymous.__closure={horizontal:horizontal,height:height,width:width,index:index,animValue:animValue,count:count,interpolate:_reactNativeReanimated.interpolate,Extrapolation:_reactNativeReanimated.Extrapolation};anonymous.__workletHash=14422051368407;anonymous.__initData=_worklet_14422051368407_init_data;anonymous.__stackDetails=_e;return anonymous;}(),[animValue,index,count,horizontal]);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)(_reactNative.View,{style:[{width:width,height:height,overflow:"hidden",transform:[{rotateZ:horizontal?"90deg":"0deg"}]},dotStyle],children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{backgroundColor:"black",flex:1},animStyle,activeDotStyle],children:children})})});};exports.PaginationItem=PaginationItem; //# sourceMappingURL=PaginationItem.js.map