UNPKG

react-native-slider-intro

Version:

A simple and full customizable React Native package which implements a unique slider.

107 lines (106 loc) 2.74 kB
"use strict"; import React, { useContext } from 'react'; import { Animated, StyleSheet, View } from 'react-native'; import { SliderContext } from './SliderProvider'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; const styles = StyleSheet.create({ wrapper: { flex: 1, alignItems: 'center', justifyContent: 'center' }, dotWrapper: { flex: 1, flexDirection: 'row' }, dotList: { flex: 1, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }, fixDot: { flex: 1, borderRadius: 10 }, animatedDotWrapper: { position: 'absolute', flex: 1, flexDirection: 'row' }, animatedDotInnerWrapper: { flex: 1, flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center' }, animatedDot: { borderRadius: 10, flex: 1, maxWidth: 2 } }); const Dots = () => { const { navContainerMaxSize, numberOfSlides, fixDotBackgroundColor, fixDotOpacity, dotWidth, animations, animatedDotBackgroundColor } = useContext(SliderContext); const arrayOfSlideIndex = [...Array(numberOfSlides).keys()]; const { _slideDotScaleX, _slideDotTranslateX } = animations; return /*#__PURE__*/_jsxs(View, { style: [styles.wrapper, { maxWidth: navContainerMaxSize }], children: [/*#__PURE__*/_jsx(View, { style: [styles.dotWrapper, { maxWidth: navContainerMaxSize }], children: /*#__PURE__*/_jsx(View, { style: styles.dotList, children: arrayOfSlideIndex.map((_, index) => { return /*#__PURE__*/_jsx(View, { style: [styles.fixDot, { backgroundColor: fixDotBackgroundColor, opacity: fixDotOpacity, width: dotWidth, maxWidth: dotWidth, height: dotWidth, maxHeight: dotWidth }] }, index); }) }) }), /*#__PURE__*/_jsx(View, { style: styles.animatedDotWrapper, children: /*#__PURE__*/_jsx(View, { style: styles.animatedDotInnerWrapper, children: /*#__PURE__*/_jsx(Animated.View, { style: [styles.animatedDot, { transform: [{ translateX: _slideDotTranslateX }, { scaleX: _slideDotScaleX }], borderRadius: Animated.divide(dotWidth, _slideDotScaleX), width: dotWidth, minWidth: dotWidth, height: dotWidth, minHeight: dotWidth, maxHeight: dotWidth, backgroundColor: animatedDotBackgroundColor }] }) }) })] }); }; export default Dots; //# sourceMappingURL=Dots.js.map