@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
124 lines • 4.08 kB
JavaScript
import { EqualsOfFloatNumbers } from "@aurigma/design-atoms-model/Math";
import { BaseTextItemHandler } from "./BaseTextItemHandler";
import { CurvedTextHandlerData } from "./CurvedTextHandlerData";
export class CurvedTextItemHandler extends BaseTextItemHandler {
constructor(item, textWhizz = null, apiClient, colorPreviewService) {
super(item, textWhizz, apiClient, colorPreviewService);
}
get item() {
return this._getItem();
}
set item(item) {
super._setItem(item);
}
get firstUpdateIsComplete() {
return this._firstUpdateIsComplete;
}
set firstUpdateIsComplete(value) {
this._firstUpdateIsComplete = value;
}
get textPath() {
var center = this.getControlCenter();
var path = this.item.textPath.clone();
var transform = this.item.transform.clone();
path.transform(transform, center);
return path;
}
get originalTextPath() {
return this.item.textPath;
}
set originalTextPath(path) {
this.item.textPath = path;
}
get fitToPath() {
return this.item.fitToPath;
}
set fitToPath(value) {
this.item.fitToPath = value;
}
get stretch() {
return this.item.stretch;
}
set stretch(value) {
this.item.stretch = value;
}
get originalFontSize() {
return this.item.originalFontSize;
}
set originalFontSize(value) {
this.item.originalFontSize = value;
}
get fitToPathStep() {
return this.item.fitToPathStep;
}
set fitToPathStep(value) {
this.item.fitToPathStep = value;
}
get start() {
return this.item.start;
}
set start(value) {
this.item.start = value;
}
get end() {
return this.item.end;
}
set end(value) {
this.item.end = value;
}
onResized() {
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.onResized();
}
_setDataItem(item, itemHandlerData) {
super._setDataItem(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;
}
_onItemPropertyChanged(sender, propertyName) {
switch (propertyName) {
case "textPath":
case "fitToPath":
case "fitToPathStep":
case "stretch":
case "originalFontSize":
case "start":
case "end":
this.update();
break;
default:
}
super._onItemPropertyChanged(sender, propertyName);
}
_setDefaultTextControlPoints() {
this._updateEmptyTextControlPoints();
}
_createDataInstance(itemHandler) {
return new CurvedTextHandlerData(itemHandler);
}
}
CurvedTextItemHandler.typeName = "CurvedTextItemHandler";
//# sourceMappingURL=CurvedTextItemHandler.js.map