UNPKG

@molejs/mole-components-web

Version:

React组件库

76 lines (69 loc) 3.36 kB
import _extends from 'babel-runtime/helpers/extends'; 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'; var __rest = this && this.__rest || function (s, e) { var t = {}; for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; }if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]]; }return t; }; /* tslint:disable:jsx-no-multiline-js */ import classnames from 'classnames'; import React from 'react'; var ButtonChlid = function (_React$Component) { _inherits(ButtonChlid, _React$Component); function ButtonChlid(props) { _classCallCheck(this, ButtonChlid); var _this = _possibleConstructorReturn(this, (ButtonChlid.__proto__ || Object.getPrototypeOf(ButtonChlid)).call(this, props)); _this.buttonClick = function (e) { e.nativeEvent.stopImmediatePropagation(); _this.props.onClick && _this.props.onClick(); }; return _this; } _createClass(ButtonChlid, [{ key: 'render', value: function render() { var _a = this.props, prefixCls = _a.prefixCls, className = _a.className, children = _a.children, thumb = _a.thumb, nodeIndex = _a.nodeIndex, direction = _a.direction, size = _a.size, childNodeLength = _a.childNodeLength, buttonMoveCls = _a.buttonMoveCls, btnStatus = _a.btnStatus, btnMoveCls = _a.btnMoveCls, restProps = __rest(_a, ["prefixCls", "className", "children", "thumb", "nodeIndex", "direction", "size", "childNodeLength", "buttonMoveCls", "btnStatus", "btnMoveCls"]); var index = nodeIndex + 1; var moveIndex = Math.abs(index - Number(childNodeLength)) + 1; var wrapCls = classnames(className, 'animated', '' + btnMoveCls, prefixCls + '-child', prefixCls + '-child-' + index, buttonMoveCls + '-' + (direction === "left" ? index : moveIndex), prefixCls + '-child-move', {}); var left = index * Number(size) + index * Number(size) * 0.3 + 'px'; var position = direction === "right" ? left : '-' + left; return React.createElement( 'div', _extends({}, restProps, { className: wrapCls, style: { left: position, display: btnMoveCls ? 'block' : 'none', animationDelay: index * 50 + 'ms' }, onClick: this.buttonClick }), React.createElement( 'div', { className: prefixCls + '-child-wrapper', style: { width: size + 'px', height: size + 'px' } }, children ) ); } }]); return ButtonChlid; }(React.Component); ButtonChlid.defaultProps = { prefixCls: 'bs-float-button' }; export default ButtonChlid;