customized-fabric 2.0.17 → 2.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/TextInputObject/index.js +12 -11
- package/package.json +1 -1
@@ -35,26 +35,27 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
35
35
|
const group = new fabric_1.fabric.Group([this.rectObject, this.textObject]);
|
36
36
|
this.set(group);
|
37
37
|
this.on("scaling", () => {
|
38
|
-
|
39
|
-
let height = this.height * this.scaleY;
|
38
|
+
const { width, height, scaleX, scaleY } = this;
|
40
39
|
const attributes = {
|
41
40
|
scaleX: 1,
|
42
41
|
scaleY: 1,
|
43
|
-
width,
|
44
|
-
height,
|
42
|
+
width: width * scaleX,
|
43
|
+
height: height * scaleY,
|
45
44
|
};
|
45
|
+
const { fontSize, maxFontSize, fontSizeScalable } = this.textObject;
|
46
|
+
if (fontSizeScalable) {
|
47
|
+
const fontSizeRatio = maxFontSize / Math.min(width, height);
|
48
|
+
const newMaxFontSize = fontSizeRatio * Math.min(attributes.width, attributes.height);
|
49
|
+
this.textObject.set({
|
50
|
+
maxFontSize: newMaxFontSize,
|
51
|
+
fontSize: Math.min(fontSize, newMaxFontSize),
|
52
|
+
});
|
53
|
+
}
|
46
54
|
this.set(attributes);
|
47
55
|
this.rectObject.set(attributes);
|
48
56
|
this.autoChangeFontSize(0.1);
|
49
57
|
this.canvas?.renderAll?.();
|
50
58
|
});
|
51
|
-
this.on("modified", () => {
|
52
|
-
this.textObject.set({ maxFontSize: Math.min(this.width, this.height) });
|
53
|
-
this.autoChangeFontSize(0.1);
|
54
|
-
this.canvas?.renderAll?.();
|
55
|
-
this.fire("object:modified");
|
56
|
-
this.fire("object:updated");
|
57
|
-
});
|
58
59
|
this.set({
|
59
60
|
_id: new objectId_1.ObjectId().toString(),
|
60
61
|
name: constants_1.TEXT_INPUT_OBJECT_ATTRIBUTES.name,
|