react-view-pager
Version:
View-Pager/Slider/Carousel powered by React Motion.
57 lines (48 loc) • 1.9 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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var ElementBase = function () {
function ElementBase(_ref) {
var node = _ref.node,
axis = _ref.axis,
width = _ref.width,
height = _ref.height;
_classCallCheck(this, ElementBase);
this.node = node;
this.axis = axis;
this.x = this.y = 0;
this.setSize(width, height);
}
_createClass(ElementBase, [{
key: 'setSize',
value: function setSize(width, height) {
this.width = width || this.node.offsetWidth;
this.height = height || this.node.offsetHeight;
}
}, {
key: 'setPosition',
value: function setPosition(position) {
this[this.axis] = position;
}
}, {
key: 'getSize',
value: function getSize(dimension) {
if (dimension === 'width' || dimension === 'height') {
return this[dimension];
} else {
return this[this.axis === 'x' ? 'width' : 'height'];
}
}
}, {
key: 'getPosition',
value: function getPosition() {
return this[this.axis];
}
}]);
return ElementBase;
}();
exports.default = ElementBase;
module.exports = exports['default'];