modo-mobile
Version:
A mobile UI toolkit, based on React
52 lines (44 loc) • 2.07 kB
JavaScript
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import * as React from 'react';
import CarouselCircle from './carousel-circle';
var Carousel = function (_React$PureComponent) {
_inherits(Carousel, _React$PureComponent);
function Carousel() {
_classCallCheck(this, Carousel);
var _this = _possibleConstructorReturn(this, (Carousel.__proto__ || Object.getPrototypeOf(Carousel)).apply(this, arguments));
_this.state = {
animateValues: [[1, 0.8, 0.6, 0.6, 0.6, 0.8, 1], [0.6, 0.8, 1, 0.8, 0.6, 0.6, 0.6], [0.6, 0.6, 0.6, 0.8, 1, 0.8, 0.6]]
};
return _this;
}
_createClass(Carousel, [{
key: 'render',
value: function render() {
var _props = this.props,
prefixCls = _props.prefixCls,
size = _props.size,
color = _props.color;
var animateValues = this.state.animateValues;
var circleNode = animateValues.map(function (value, index) {
return React.createElement(CarouselCircle, { key: index, size: size, index: index, animateValues: value });
});
var viewWidth = animateValues.length * size + (animateValues.length - 1) * size / 2;
var viewBox = '0 0 ' + viewWidth + ' ' + size;
var svgStyle = { width: viewWidth, height: size };
return React.createElement(
'div',
{ className: prefixCls + '-carousel' },
React.createElement(
'svg',
{ viewBox: viewBox, className: prefixCls + '-carousel-svg', style: svgStyle, fill: color, xmlns: 'http://www.w3.org/2000/svg' },
circleNode
)
);
}
}]);
return Carousel;
}(React.PureComponent);
export default Carousel;