rc-banner-anim
Version:
banner-anim animation component for react
64 lines (54 loc) • 2.18 kB
JavaScript
import _extends from 'babel-runtime/helpers/extends';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
var Arrow = function (_Component) {
_inherits(Arrow, _Component);
function Arrow() {
var _temp, _this, _ret;
_classCallCheck(this, Arrow);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.onClick = function (e) {
_this.props[_this.props.arrowType](e);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
Arrow.prototype.render = function render() {
var className = this.props.className;
var defaultClass = className + '-default';
className = (className + ' ' + (this.props.prefixCls || '')).trim();
className = !this.props['default'] ? className : (className + ' ' + defaultClass).trim();
className = className + ' ' + this.props.arrowType;
var props = _extends({}, this.props);
['arrowType', 'next', 'prev', 'elemHeight', 'component', 'default', 'prefixCls'].forEach(function (key) {
return delete props[key];
});
props.className = className;
props.onClick = this.onClick;
props.style = props.style || {};
props.style.top = this.props.elemHeight / 2 + 'px';
return React.createElement(this.props.component, props, this.props.children);
};
return Arrow;
}(Component);
Arrow.propTypes = {
children: PropTypes.any,
style: PropTypes.object,
className: PropTypes.string,
prefixCls: PropTypes.string,
component: PropTypes.any,
arrowType: PropTypes.string,
'default': PropTypes.bool,
next: PropTypes.func,
prev: PropTypes.func,
elemHeight: PropTypes.number
};
Arrow.defaultProps = {
component: 'div',
className: 'banner-anim-arrow'
};
Arrow.isBannerAnimArrow = true;
export default Arrow;