twreporter-react-index-page
Version:
twreporter index page version 2
105 lines (84 loc) • 3.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _velocityReact = require('velocity-react');
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* global React */
var FadeInFadeOut = function (_React$Component) {
_inherits(FadeInFadeOut, _React$Component);
function FadeInFadeOut(props) {
_classCallCheck(this, FadeInFadeOut);
var _this = _possibleConstructorReturn(this, (FadeInFadeOut.__proto__ || Object.getPrototypeOf(FadeInFadeOut)).call(this, props));
_this.state = {
onAnimate: false
};
_this.onAnimationFinish = _this._onAnimationFinish.bind(_this);
return _this;
}
_createClass(FadeInFadeOut, [{
key: 'componentDidMount',
value: function componentDidMount() {
if (this.textField) {
this.textField.style.display = 'inline';
}
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps() {
this.setState({
onAnimate: true
});
}
}, {
key: '_onAnimationFinish',
value: function _onAnimationFinish() {
if (this.state.onAnimate) {
this.setState({
onAnimate: false
});
}
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
var isSelected = this.props.isSelected;
return React.createElement(
_velocityReact.VelocityComponent,
{
animation: isSelected ? { opacity: 1 } : { opacity: 0 },
duration: 500,
complete: this.onAnimationFinish
},
React.createElement(
'div',
{
ref: function ref(node) {
_this2.textField = node;
},
style: {
display: 'none'
}
},
this.props.children
)
);
}
}]);
return FadeInFadeOut;
}(React.Component);
FadeInFadeOut.defaultProps = {
isSelected: false,
children: null
};
FadeInFadeOut.propTypes = {
isSelected: _propTypes2.default.bool,
children: _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.array])
};
exports.default = FadeInFadeOut;