UNPKG

@aurigma/design-atoms-model

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

86 lines 3.51 kB
import { EqualsOfFloatNumbers } from "./Common"; import { EventWithSenderArg } from "../EventObject"; import { ModelComponent } from "../Product/ModelComponent"; export class Margin extends ModelComponent { constructor(value) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; super(); this._propertyChanged = new EventWithSenderArg(); const rawValue = value; this._left = (_c = (_b = (_a = rawValue === null || rawValue === void 0 ? void 0 : rawValue.left) !== null && _a !== void 0 ? _a : rawValue === null || rawValue === void 0 ? void 0 : rawValue.horizontal) !== null && _b !== void 0 ? _b : rawValue) !== null && _c !== void 0 ? _c : 0; this._top = (_f = (_e = (_d = rawValue === null || rawValue === void 0 ? void 0 : rawValue.top) !== null && _d !== void 0 ? _d : rawValue === null || rawValue === void 0 ? void 0 : rawValue.vertical) !== null && _e !== void 0 ? _e : rawValue) !== null && _f !== void 0 ? _f : 0; this._right = (_j = (_h = (_g = rawValue === null || rawValue === void 0 ? void 0 : rawValue.right) !== null && _g !== void 0 ? _g : rawValue === null || rawValue === void 0 ? void 0 : rawValue.horizontal) !== null && _h !== void 0 ? _h : rawValue) !== null && _j !== void 0 ? _j : 0; this._bottom = (_m = (_l = (_k = rawValue === null || rawValue === void 0 ? void 0 : rawValue.bottom) !== null && _k !== void 0 ? _k : rawValue === null || rawValue === void 0 ? void 0 : rawValue.vertical) !== null && _l !== void 0 ? _l : rawValue) !== null && _m !== void 0 ? _m : 0; } get left() { return this._left; } set left(value) { if (EqualsOfFloatNumbers(value, this._left)) return; this._left = value; this._propertyChanged.notify(this, "left"); } get top() { return this._top; } set top(value) { if (EqualsOfFloatNumbers(value, this._top)) return; this._top = value; this._propertyChanged.notify(this, "top"); } get right() { return this._right; } set right(value) { if (EqualsOfFloatNumbers(value, this._right)) return; this._right = value; this._propertyChanged.notify(this, "right"); } get bottom() { return this._bottom; } set bottom(value) { if (EqualsOfFloatNumbers(value, this._bottom)) return; this._bottom = value; this._propertyChanged.notify(this, "bottom"); } clone() { return new Margin({ left: this.left, top: this.top, right: this.right, bottom: this.bottom }); } get isEmpty() { return this._left === 0 && this._top === 0 && this._right === 0 && this._bottom === 0; } equals(other) { return this.left === other.left && this.top === other.top && this.right === other.right && this.bottom === other.bottom; } getSimplifiedObject() { return { left: this.left, top: this.top, right: this.right, bottom: this.bottom }; } addPropertyChanged(listener) { this._propertyChanged.add(listener); } removePropertyChanged(listener) { this._propertyChanged.remove(listener); } } //# sourceMappingURL=Margin.js.map