customized-fabric 1.6.6 → 1.6.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,8 +5,8 @@ exports.CLIPART_OBJECT_ATTRIBUTES = {
5
5
  name: "Clipart",
6
6
  type: "CLIPART",
7
7
  stroke: {
8
- stroke: "#000000",
8
+ stroke: "#333",
9
9
  strokeDashArray: [5, 5],
10
- strokeWidth: 2,
10
+ strokeWidth: 1,
11
11
  },
12
12
  };
@@ -6,9 +6,9 @@ exports.CURVED_TEXT_OBJECT_ATTRIBUTES = {
6
6
  type: "CURVED_TEXT",
7
7
  maxFontSize: 200,
8
8
  stroke: {
9
- stroke: "#000000",
9
+ stroke: "#333",
10
10
  strokeDashArray: [5, 5],
11
- strokeWidth: 2,
11
+ strokeWidth: 1,
12
12
  },
13
13
  };
14
14
  exports.PARENT_ATTRIBUTES = ["top", "left", "width", "height", "angle"];
@@ -5,9 +5,9 @@ exports.IMAGE_PLACEHOLDER_OBJECT_ATTRIBUTES = {
5
5
  name: "Image placeholder",
6
6
  type: "IMAGE_PLACEHOLDER",
7
7
  stroke: {
8
- stroke: "#000000",
8
+ stroke: "#333",
9
9
  strokeDashArray: [5, 5],
10
- strokeWidth: 2,
10
+ strokeWidth: 1,
11
11
  },
12
12
  };
13
13
  exports.IMAGE_FILTER_TYPES = {
@@ -50,5 +50,6 @@ export default class ImagePlaceholder extends fabric.Group {
50
50
  setImageType?: (type: ImageFilterType) => void;
51
51
  setImageColor?: (color: string) => void;
52
52
  applyImageFilters?: (image: fabric.Image | undefined) => void;
53
+ fitImage?: (image: fabric.Image, cover?: boolean) => void;
53
54
  constructor(options?: IImagePlaceholderOptions);
54
55
  }
@@ -96,13 +96,20 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
96
96
  this.fitImage(this.imageObject);
97
97
  this.canvas?.renderAll?.();
98
98
  },
99
- fitImage: function (image) {
99
+ fitImage: function (image, cover = false) {
100
100
  if (image) {
101
101
  const imageScaleX = this.width / (image?.width ?? 1);
102
102
  const imageScaleY = this.height / (image?.height ?? 1);
103
- imageScaleX > imageScaleY
104
- ? image.set({ scaleX: imageScaleY, scaleY: imageScaleY })
105
- : image.set({ scaleX: imageScaleX, scaleY: imageScaleX });
103
+ if (cover) {
104
+ imageScaleX < imageScaleY
105
+ ? image.set({ scaleX: imageScaleY, scaleY: imageScaleY })
106
+ : image.set({ scaleX: imageScaleX, scaleY: imageScaleX });
107
+ }
108
+ else {
109
+ imageScaleX > imageScaleY
110
+ ? image.set({ scaleX: imageScaleY, scaleY: imageScaleY })
111
+ : image.set({ scaleX: imageScaleX, scaleY: imageScaleX });
112
+ }
106
113
  }
107
114
  },
108
115
  getSettings: function (attribute) {
@@ -128,7 +135,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
128
135
  if (index >= 0) {
129
136
  canvas.insertAt(loadedImage, index, false);
130
137
  }
131
- this.fitImage(this.uploadedImage);
138
+ this.fitImage(this.uploadedImage, true);
132
139
  this.applyImageFilters(this.uploadedImage);
133
140
  canvas?.renderAll();
134
141
  }
@@ -6,9 +6,9 @@ exports.TEXT_INPUT_OBJECT_ATTRIBUTES = {
6
6
  type: "TEXT_INPUT",
7
7
  maxFontSize: 200,
8
8
  stroke: {
9
- stroke: "#000000",
9
+ stroke: "#333",
10
10
  strokeDashArray: [5, 5],
11
- strokeWidth: 2,
11
+ strokeWidth: 1,
12
12
  },
13
13
  };
14
14
  exports.PARENT_ATTRIBUTES = ["top", "left", "width", "height", "angle"];
@@ -211,8 +211,8 @@ exports.asyncGetObject = asyncGetObject;
211
211
  fabric_1.fabric.Object.prototype.transparentCorners = false;
212
212
  fabric_1.fabric.Object.prototype.cornerColor = "transparent";
213
213
  fabric_1.fabric.Object.prototype.cornerStyle = "circle";
214
- fabric_1.fabric.Object.prototype.cornerStrokeColor = "black";
215
- fabric_1.fabric.Object.prototype.borderColor = "black";
214
+ fabric_1.fabric.Object.prototype.cornerStrokeColor = "#3b75cf";
215
+ fabric_1.fabric.Object.prototype.borderColor = "#3b75cf";
216
216
  fabric_1.fabric.Group.prototype.originX = "center";
217
217
  fabric_1.fabric.Group.prototype.originY = "center";
218
218
  fabric_1.fabric.ActiveSelection.prototype.originX = "center";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customized-fabric",
3
- "version": "1.6.6",
3
+ "version": "1.6.8",
4
4
  "description": "Customized fabric",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",