react-lory
Version:
[Deprecated] Use react-slidy instead.
91 lines (65 loc) • 3.6 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 _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactSlidySlider = require('./react-slidy-slider');
var _reactSlidySlider2 = _interopRequireDefault(_reactSlidySlider);
var _suiSpinner = require('@schibstedspain/sui-spinner');
var _suiSpinner2 = _interopRequireDefault(_suiSpinner);
var _reactLazyLoad = require('react-lazy-load');
var _reactLazyLoad2 = _interopRequireDefault(_reactLazyLoad);
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; }
var spinnerConfig = {
size: 20,
thickness: 2,
type: 'circle'
};
var lazyLoadOffsetVerical = 500;
var ReactSlidy = function (_Component) {
_inherits(ReactSlidy, _Component);
function ReactSlidy() {
_classCallCheck(this, ReactSlidy);
return _possibleConstructorReturn(this, (ReactSlidy.__proto__ || Object.getPrototypeOf(ReactSlidy)).apply(this, arguments));
}
_createClass(ReactSlidy, [{
key: 'shouldComponentUpdate',
// as it's a slider, we don't want to re-render it and don't expect
// to add new childrens to it, so we don't want unexpected behaviour
value: function shouldComponentUpdate() {
return false;
}
}, {
key: 'render',
value: function render() {
return _react2.default.createElement(
'div',
{ className: this.props.classNameBase },
_react2.default.createElement(_suiSpinner2.default, spinnerConfig),
_react2.default.createElement(
_reactLazyLoad2.default,
{ offsetVertical: lazyLoadOffsetVerical },
_react2.default.createElement(
_reactSlidySlider2.default,
this.props,
this.props.children
)
)
);
}
}]);
return ReactSlidy;
}(_react.Component);
exports.default = ReactSlidy;
ReactSlidy.propTypes = {
children: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.object]).isRequired,
classNameBase: _react.PropTypes.string
};
ReactSlidy.defaultProps = {
classNameBase: 'react-Slidy'
};
;