customized-fabric 1.5.4 → 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -140,13 +140,15 @@ const CurvedTextClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group,
140
140
  },
141
141
  setSizes: function (options) {
142
142
  const { width, height } = options;
143
- if (width && width > this.textObject.__lineWidths) {
143
+ if (width) {
144
144
  this.set({ width });
145
- this.textObject.set({ width });
145
+ this.rectObject.set({ width });
146
146
  }
147
- if (height && height > this.textObject.height) {
147
+ if (height) {
148
148
  this.set({ height });
149
+ this.rectObject.set({ height });
149
150
  }
151
+ this.calculateTextPath(this.width, this.height);
150
152
  this.canvas?.renderAll?.();
151
153
  },
152
154
  setTextAttributes: function (options) {
@@ -177,10 +179,17 @@ const CurvedTextClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group,
177
179
  });
178
180
  this.pathObject = path;
179
181
  const pathInfo = fabric_1.fabric.util?.getPathSegmentsInfo?.(path.path);
182
+ const pathLength = pathInfo?.[(pathInfo?.length ?? 0) - 1]?.length;
180
183
  this.textObject.set({
181
184
  path,
182
- pathLength: pathInfo?.[(pathInfo?.length ?? 0) - 1]?.length,
185
+ pathLength,
183
186
  });
187
+ const position = this.textObject.position;
188
+ if (position) {
189
+ this.textObject.set({
190
+ pathStartOffset: (position * pathLength) / 360,
191
+ });
192
+ }
184
193
  },
185
194
  });
186
195
  const toCurvedTextObject = (object) => {
@@ -1 +1,3 @@
1
+ import { fabric } from "fabric";
1
2
  export declare const getEllipsePath: (rx: number, ry: number) => string;
3
+ export declare const getPathLenght: (path: fabric.Path) => any;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEllipsePath = void 0;
3
+ exports.getPathLenght = exports.getEllipsePath = void 0;
4
+ const fabric_1 = require("fabric");
4
5
  const getEllipsePath = (rx, ry) => {
5
6
  let output = `M 0,0`;
6
7
  output += `a ${rx},${ry} 0 0,1 0,${ry * -2}`;
@@ -9,3 +10,9 @@ const getEllipsePath = (rx, ry) => {
9
10
  return output;
10
11
  };
11
12
  exports.getEllipsePath = getEllipsePath;
13
+ const getPathLenght = (path) => {
14
+ const pathInfo = fabric_1.fabric.util?.getPathSegmentsInfo?.(path.path);
15
+ const pathLength = pathInfo?.[(pathInfo?.length ?? 0) - 1]?.length;
16
+ return pathLength;
17
+ };
18
+ exports.getPathLenght = getPathLenght;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customized-fabric",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
4
4
  "description": "Customized fabric",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",