customized-fabric 1.8.6 → 1.8.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,6 +30,8 @@ export declare const toTextInputObject: (object: TextInput) => {
30
30
  infix: any;
31
31
  suffix: any;
32
32
  isAllCapital: any;
33
+ lineHeight: number | undefined;
34
+ charSpacing: number | undefined;
33
35
  };
34
36
  };
35
37
  export default class TextInput extends fabric.Group {
@@ -69,22 +69,24 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
69
69
  this.fire("scaling");
70
70
  },
71
71
  autoChangeFontSize: function (changeSpeed) {
72
- if (this.width <= this.textObject.__lineWidths ||
73
- this.height <= this.textObject.height) {
74
- while (this.width <= this.textObject.__lineWidths ||
72
+ let maxLineWidth = Math.max(...this.textObject.__lineWidths);
73
+ if (this.width <= maxLineWidth || this.height <= this.textObject.height) {
74
+ while (this.width <= maxLineWidth ||
75
75
  this.height <= this.textObject.height) {
76
76
  this.textObject.set({
77
77
  fontSize: this.textObject.fontSize - changeSpeed,
78
78
  });
79
+ maxLineWidth = Math.max(...this.textObject.__lineWidths);
79
80
  }
80
81
  }
81
82
  else {
82
83
  while (this.textObject.maxFontSize > this.textObject.fontSize &&
83
- this.width > this.textObject.__lineWidths &&
84
+ this.width > maxLineWidth &&
84
85
  this.height > this.textObject.height) {
85
86
  this.textObject.set({
86
87
  fontSize: this.textObject.fontSize + changeSpeed,
87
88
  });
89
+ maxLineWidth = Math.max(...this.textObject.__lineWidths);
88
90
  }
89
91
  }
90
92
  },
@@ -126,8 +128,8 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
126
128
  this.textObject.set({
127
129
  fontSize,
128
130
  });
129
- if (this.textObject.__lineWidths < this.width &&
130
- this.textObject.height < this.height) {
131
+ const maxLineWidth = Math.max(...this.textObject.__lineWidths);
132
+ if (maxLineWidth < this.width && this.textObject.height < this.height) {
131
133
  }
132
134
  else {
133
135
  this.autoChangeFontSize(1);
@@ -209,6 +211,8 @@ const toTextInputObject = (object) => {
209
211
  infix: textObject?.infix,
210
212
  suffix: textObject?.suffix,
211
213
  isAllCapital: textObject?.isAllCapital,
214
+ lineHeight: textObject?.lineHeight,
215
+ charSpacing: textObject?.charSpacing,
212
216
  },
213
217
  };
214
218
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customized-fabric",
3
- "version": "1.8.6",
3
+ "version": "1.8.7",
4
4
  "description": "Customized fabric",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",