@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
187 lines • 7.26 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { EqualsOfFloatNumbers } from "@aurigma/design-atoms-model/Math";
import { BaseTextItemHandler } from "./BaseTextItemHandler";
import { Graphics } from "../Graphics";
import { CurvedTextHandlerData } from "./CurvedTextHandlerData";
var CurvedTextItemHandler = /** @class */ (function (_super) {
__extends(CurvedTextItemHandler, _super);
function CurvedTextItemHandler(item, textWhizz, apiClient, colorPreviewService) {
if (textWhizz === void 0) { textWhizz = null; }
return _super.call(this, item, textWhizz, apiClient, colorPreviewService) || this;
}
Object.defineProperty(CurvedTextItemHandler.prototype, "item", {
get: function () {
return this._getItem();
},
set: function (item) {
_super.prototype._setItem.call(this, item);
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItemHandler.prototype, "firstUpdateIsComplete", {
get: function () {
return this._firstUpdateIsComplete;
},
set: function (value) {
this._firstUpdateIsComplete = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItemHandler.prototype, "textPath", {
get: function () {
var center = this.getControlCenter();
var path = this.item.textPath.clone();
var transform = this.item.transform.clone();
path.transform(transform, center);
return path;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItemHandler.prototype, "originalTextPath", {
get: function () {
return this.item.textPath;
},
set: function (path) {
this.item.textPath = path;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItemHandler.prototype, "fitToPath", {
get: function () {
return this.item.fitToPath;
},
set: function (value) {
this.item.fitToPath = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItemHandler.prototype, "stretch", {
get: function () {
return this.item.stretch;
},
set: function (value) {
this.item.stretch = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItemHandler.prototype, "originalFontSize", {
get: function () {
return this.item.originalFontSize;
},
set: function (value) {
this.item.originalFontSize = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItemHandler.prototype, "fitToPathStep", {
get: function () {
return this.item.fitToPathStep;
},
set: function (value) {
this.item.fitToPathStep = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItemHandler.prototype, "start", {
get: function () {
return this.item.start;
},
set: function (value) {
this.item.start = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CurvedTextItemHandler.prototype, "end", {
get: function () {
return this.item.end;
},
set: function (value) {
this.item.end = value;
},
enumerable: true,
configurable: true
});
CurvedTextItemHandler.prototype.onResized = function () {
var ratio = this.rectangle.height / this._height;
var fontSize = parseFloat((this.item.font.size * ratio).toFixed(1));
var canvas = this.canvas;
if (canvas != null) {
var minFontSize = canvas.minFontSize;
fontSize = typeof minFontSize == "number" ? Math.max(fontSize, minFontSize) : fontSize;
var maxFontSize = canvas.maxFontSize;
fontSize = typeof maxFontSize == "number" ? Math.min(fontSize, maxFontSize) : fontSize;
}
if (EqualsOfFloatNumbers(fontSize, this.item.font.size, 0.01)) {
if (this._startRectangle != null) {
this.setRectangle(this._startRectangle);
canvas.updateSelection();
delete this._startRectangle;
}
else
this.update();
return false;
}
return _super.prototype.onResized.call(this);
};
CurvedTextItemHandler.prototype.drawItemHandler = function (itemHandlerCtx) {
_super.prototype.drawItemHandler.call(this, itemHandlerCtx);
if (window["__$abl$"] === true)
Graphics.drawPath(itemHandlerCtx, this.item.textPath, this.getControlCenter(), this.item.transform, 1, "red", 1);
};
CurvedTextItemHandler.prototype._setDataItem = function (item, itemHandlerData) {
_super.prototype._setDataItem.call(this, item, itemHandlerData);
this.item.textPath = item.textPath;
this.item.fitToPath = item.fitToPath;
this.item.fitToPathStep = item.fitToPathStep;
this.item.stretch = item.stretch;
this.item.originalFontSize = item.originalFontSize;
this.item.start = item.start;
this.item.end = item.end;
};
CurvedTextItemHandler.prototype._onItemPropertyChanged = function (sender, propertyName) {
switch (propertyName) {
case "textPath":
case "fitToPath":
case "fitToPathStep":
case "stretch":
case "originalFontSize":
case "start":
case "end":
this.update();
break;
default:
}
_super.prototype._onItemPropertyChanged.call(this, sender, propertyName);
};
CurvedTextItemHandler.prototype._setDefaultTextControlPoints = function () {
this._updateEmptyTextControlPoints();
};
CurvedTextItemHandler.prototype._createDataInstance = function (itemHandler) {
return new CurvedTextHandlerData(itemHandler);
};
CurvedTextItemHandler.typeName = "CurvedTextItemHandler";
return CurvedTextItemHandler;
}(BaseTextItemHandler));
export { CurvedTextItemHandler };
//# sourceMappingURL=CurvedTextItemHandler.js.map