UNPKG

vue-poster-editor

Version:

A poster editor based on Vue.js

64 lines (44 loc) 2.8 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _utils = require('../utils/utils'); var _elementBaseModel = require('./element-base-model'); var _elementBaseModel2 = _interopRequireDefault(_elementBaseModel); 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 ElementMaskModel = function (_ElementBaseModel) { _inherits(ElementMaskModel, _ElementBaseModel); function ElementMaskModel(data) { _classCallCheck(this, ElementMaskModel); var modelVersion = _utils.version.parse(data.version || '0.0.0'); if (modelVersion.major < 2) { data.imageUrl = data.imageUrl || data.image; data.imageHeight = data.imageHeight || data.height; data.imageWidth = data.imageWidth || data.width; delete data.image; var clip = data.clip; if (clip) { data.imageWidth += clip.left + clip.right; data.imageHeight += clip.top + clip.bottom; var imageTransform = data.imageTransform; if (!imageTransform) { data.imageTransform = { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }; } data.imageTransform.tx = -clip.left; data.imageTransform.ty = -clip.top; delete data.clip; } } var _this = _possibleConstructorReturn(this, (ElementMaskModel.__proto__ || Object.getPrototypeOf(ElementMaskModel)).call(this, data)); _this.imageTransform = _this.parseTransform(_this.imageTransform); _this.imageHeight = Number(_this.imageHeight); _this.imageWidth = Number(_this.imageWidth); return _this; } return ElementMaskModel; }(_elementBaseModel2.default); exports.default = ElementMaskModel; module.exports = exports['default'];