customized-fabric 1.2.4 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -42,6 +42,11 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
42
42
|
if (options?.hideStroke) {
|
43
43
|
this.rectObject.set({ strokeWidth: 0 });
|
44
44
|
}
|
45
|
+
else {
|
46
|
+
if (options?.maskUrl) {
|
47
|
+
this.loadMask(options?.maskUrl);
|
48
|
+
}
|
49
|
+
}
|
45
50
|
if (options?.image) {
|
46
51
|
const { image } = options;
|
47
52
|
const { url, data, clipPath } = image;
|
@@ -68,9 +73,6 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
68
73
|
}
|
69
74
|
}
|
70
75
|
}
|
71
|
-
if (options?.maskUrl) {
|
72
|
-
this.loadMask(options?.maskUrl);
|
73
|
-
}
|
74
76
|
},
|
75
77
|
loadImage: async function (image) {
|
76
78
|
const loadedImage = await (0, utils_1.loadImage)(image);
|
@@ -128,9 +130,18 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
128
130
|
top: this.top,
|
129
131
|
left: this.left,
|
130
132
|
});
|
131
|
-
if (this.
|
133
|
+
if (this.maskUrl) {
|
134
|
+
const maskObject = await (0, utils_1.loadImage)(this.maskUrl);
|
135
|
+
maskObject?.set({
|
136
|
+
top: this.top,
|
137
|
+
left: this.left,
|
138
|
+
absolutePositioned: true,
|
139
|
+
scaleX: this.width / (maskObject?.width ?? this.width),
|
140
|
+
scaleY: this.height / (maskObject?.height ?? this.height),
|
141
|
+
angle: this.angle,
|
142
|
+
});
|
132
143
|
loadedImage.set({
|
133
|
-
clipPath:
|
144
|
+
clipPath: maskObject,
|
134
145
|
});
|
135
146
|
}
|
136
147
|
else {
|
@@ -194,13 +205,20 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
194
205
|
scaleY: this.height / loadedMask.height,
|
195
206
|
absolutePositioned: false,
|
196
207
|
});
|
208
|
+
this.remove(this.imageObject);
|
209
|
+
this.remove(this.maskObject);
|
197
210
|
this.maskObject = loadedMask;
|
211
|
+
this.add(this.maskObject);
|
212
|
+
this.imageObject && this.add(this.imageObject);
|
198
213
|
this.set({ clipPath: this.maskObject });
|
199
214
|
this.canvas?.renderAll();
|
200
215
|
}
|
201
216
|
},
|
202
217
|
removeMask: async function () {
|
203
|
-
this.set({ clipPath: undefined });
|
218
|
+
this.set({ clipPath: undefined, maskUrl: undefined });
|
219
|
+
this.remove(this.maskObject);
|
220
|
+
this.maskObject = undefined;
|
221
|
+
this.canvas?.renderAll();
|
204
222
|
},
|
205
223
|
});
|
206
224
|
const toImagePlaceholderObject = (imagePlaceholderObject) => {
|