react-native-slider-intro
Version:
A simple and full customizable React Native package which implements a unique slider.
113 lines (112 loc) • 3.88 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _SliderProvider = require("./SliderProvider");
var _jsxRuntime = require("react/jsx-runtime");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const styles = _reactNative.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
} = (0, _react.useContext)(_SliderProvider.SliderContext);
const arrayOfSlideIndex = [...Array(numberOfSlides).keys()];
const {
_slideDotScaleX,
_slideDotTranslateX
} = animations;
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: [styles.wrapper, {
maxWidth: navContainerMaxSize
}],
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: [styles.dotWrapper, {
maxWidth: navContainerMaxSize
}],
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: styles.dotList,
children: arrayOfSlideIndex.map((_, index) => {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: [styles.fixDot, {
backgroundColor: fixDotBackgroundColor,
opacity: fixDotOpacity,
width: dotWidth,
maxWidth: dotWidth,
height: dotWidth,
maxHeight: dotWidth
}]
}, index);
})
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: styles.animatedDotWrapper,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: styles.animatedDotInnerWrapper,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
style: [styles.animatedDot, {
transform: [{
translateX: _slideDotTranslateX
}, {
scaleX: _slideDotScaleX
}],
borderRadius: _reactNative.Animated.divide(dotWidth, _slideDotScaleX),
width: dotWidth,
minWidth: dotWidth,
height: dotWidth,
minHeight: dotWidth,
maxHeight: dotWidth,
backgroundColor: animatedDotBackgroundColor
}]
})
})
})]
});
};
var _default = exports.default = Dots;
//# sourceMappingURL=Dots.js.map