customized-fabric 1.3.6 → 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,9 +33,6 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
33
33
  imageType: "Full color",
34
34
  objectCaching: false,
35
35
  });
36
- if (options?.imageFile) {
37
- this.loadImage(options?.imageFile);
38
- }
39
36
  if (options?.isOriginal) {
40
37
  this.rectObject?.set({ strokeWidth: 0 });
41
38
  }
@@ -43,8 +40,13 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
43
40
  if (options?.hideStroke) {
44
41
  this.rectObject?.set({ strokeWidth: 0 });
45
42
  }
46
- if (options?.maskFile || options?.maskUrl) {
47
- this.loadMask(options?.maskFile ?? options?.maskUrl);
43
+ else {
44
+ if (options?.maskFile || options?.maskUrl) {
45
+ this.loadMask(options?.maskFile ?? options?.maskUrl);
46
+ }
47
+ }
48
+ if (options?.imageFile) {
49
+ this.loadImage(options?.imageFile);
48
50
  }
49
51
  }
50
52
  if (options?.imageType) {
@@ -178,14 +180,14 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
178
180
  this.canvas?.renderAll();
179
181
  },
180
182
  getMask: async function () {
181
- if (this.maskObject) {
182
- return this.maskObject;
183
+ if (this.mask) {
184
+ return this.mask;
183
185
  }
184
186
  if (this?.maskUrl) {
185
- const maskObject = await (0, utils_1.loadImageFromUrl)(this.maskUrl);
186
- maskObject?.set({
187
- scaleX: this.width / (maskObject?.width ?? this.width),
188
- scaleY: this.height / (maskObject?.height ?? this.height),
187
+ const mask = await (0, utils_1.loadImageFromUrl)(this.maskUrl);
188
+ mask?.set({
189
+ scaleX: this.width / (mask?.width ?? this.width),
190
+ scaleY: this.height / (mask?.height ?? this.height),
189
191
  absolutePositioned: true,
190
192
  originX: "center",
191
193
  originY: "center",
@@ -193,11 +195,11 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
193
195
  left: this.left,
194
196
  angle: this.angle,
195
197
  });
196
- this.maskObject = maskObject;
197
- return maskObject;
198
+ this.mask = mask;
199
+ return mask;
198
200
  }
199
201
  else {
200
- const maskObject = new fabric_1.fabric.Rect({
202
+ const mask = new fabric_1.fabric.Rect({
201
203
  width: this.width,
202
204
  height: this.height,
203
205
  scaleX: this.scaleX,
@@ -209,8 +211,8 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
209
211
  left: this.left,
210
212
  angle: this.angle,
211
213
  });
212
- this.maskObject = maskObject;
213
- return maskObject;
214
+ this.mask = mask;
215
+ return mask;
214
216
  }
215
217
  },
216
218
  loadCustomizedImage: async function (image) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customized-fabric",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "Customized fabric",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",