@nasser-sw/fabric 7.0.1-beta4 → 7.0.1-beta6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +40 -31
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +40 -31
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +40 -31
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +40 -31
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.json.min.mjs +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/shapes/Line.d.ts +1 -0
- package/dist/src/shapes/Line.d.ts.map +1 -1
- package/dist/src/shapes/Line.min.mjs +1 -1
- package/dist/src/shapes/Line.min.mjs.map +1 -1
- package/dist/src/shapes/Line.mjs +39 -30
- package/dist/src/shapes/Line.mjs.map +1 -1
- package/dist-extensions/src/shapes/Line.d.ts +1 -0
- package/dist-extensions/src/shapes/Line.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/shapes/Line.ts +34 -18
package/dist/index.node.cjs
CHANGED
|
@@ -412,7 +412,7 @@ class Cache {
|
|
|
412
412
|
}
|
|
413
413
|
const cache = new Cache();
|
|
414
414
|
|
|
415
|
-
var version = "7.0.1-
|
|
415
|
+
var version = "7.0.1-beta5";
|
|
416
416
|
|
|
417
417
|
// use this syntax so babel plugin see this import here
|
|
418
418
|
const VERSION = version;
|
|
@@ -17686,14 +17686,10 @@ class Line extends FabricObject {
|
|
|
17686
17686
|
};
|
|
17687
17687
|
}
|
|
17688
17688
|
_p1PositionHandler() {
|
|
17689
|
-
|
|
17690
|
-
const vpt = ((_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17691
|
-
return new Point(this.x1, this.y1).transform(vpt);
|
|
17689
|
+
return new Point(this.x1, this.y1).transform(this.getViewportTransform());
|
|
17692
17690
|
}
|
|
17693
17691
|
_p2PositionHandler() {
|
|
17694
|
-
|
|
17695
|
-
const vpt = ((_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17696
|
-
return new Point(this.x2, this.y2).transform(vpt);
|
|
17692
|
+
return new Point(this.x2, this.y2).transform(this.getViewportTransform());
|
|
17697
17693
|
}
|
|
17698
17694
|
_renderEndpointControl(ctx, left, top) {
|
|
17699
17695
|
const size = 12;
|
|
@@ -17716,9 +17712,9 @@ class Line extends FabricObject {
|
|
|
17716
17712
|
return super.drawBorders(ctx, styleOverride, {});
|
|
17717
17713
|
}
|
|
17718
17714
|
_drawLineBorders(ctx) {
|
|
17719
|
-
var _this$
|
|
17715
|
+
var _this$canvas;
|
|
17720
17716
|
let styleOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17721
|
-
const vpt = ((_this$
|
|
17717
|
+
const vpt = ((_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17722
17718
|
ctx.save();
|
|
17723
17719
|
ctx.setTransform(vpt[0], vpt[1], vpt[2], vpt[3], vpt[4], vpt[5]);
|
|
17724
17720
|
ctx.strokeStyle = styleOverride.borderColor || this.borderColor || 'rgba(100, 200, 200, 0.5)';
|
|
@@ -17759,14 +17755,14 @@ class Line extends FabricObject {
|
|
|
17759
17755
|
}
|
|
17760
17756
|
setCoords() {
|
|
17761
17757
|
if (this._useEndpointCoords) {
|
|
17762
|
-
|
|
17763
|
-
const
|
|
17764
|
-
|
|
17765
|
-
|
|
17758
|
+
// Set the object's center to the geometric center of the line
|
|
17759
|
+
const center = this._findCenterFromElement();
|
|
17760
|
+
this.left = center.x;
|
|
17761
|
+
this.top = center.y;
|
|
17762
|
+
|
|
17763
|
+
// Set width and height for hit detection and bounding box
|
|
17766
17764
|
const effectiveStrokeWidth = this.hitStrokeWidth === 'auto' ? this.strokeWidth : this.hitStrokeWidth;
|
|
17767
17765
|
const hitPadding = Math.max(effectiveStrokeWidth / 2 + 5, 10);
|
|
17768
|
-
this.left = minX - hitPadding + (maxX - minX + hitPadding * 2) / 2;
|
|
17769
|
-
this.top = minY - hitPadding + (maxY - minY + hitPadding * 2) / 2;
|
|
17770
17766
|
this.width = Math.abs(this.x2 - this.x1) + hitPadding * 2;
|
|
17771
17767
|
this.height = Math.abs(this.y2 - this.y1) + hitPadding * 2;
|
|
17772
17768
|
}
|
|
@@ -17794,8 +17790,8 @@ class Line extends FabricObject {
|
|
|
17794
17790
|
}
|
|
17795
17791
|
containsPoint(point) {
|
|
17796
17792
|
if (this._useEndpointCoords) {
|
|
17797
|
-
var _this$
|
|
17798
|
-
if (((_this$
|
|
17793
|
+
var _this$canvas2;
|
|
17794
|
+
if (((_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.getActiveObject()) === this) {
|
|
17799
17795
|
return super.containsPoint(point);
|
|
17800
17796
|
}
|
|
17801
17797
|
const distance = this._distanceToLineSegment(point.x, point.y);
|
|
@@ -17829,7 +17825,7 @@ class Line extends FabricObject {
|
|
|
17829
17825
|
return Math.sqrt((px - closestX) * (px - closestX) + (py - closestY) * (py - closestY));
|
|
17830
17826
|
}
|
|
17831
17827
|
_endpointActionHandler(eventData, transformData, x, y) {
|
|
17832
|
-
var _this$
|
|
17828
|
+
var _this$canvas4;
|
|
17833
17829
|
const controlKey = transformData.corner;
|
|
17834
17830
|
const pointer = new Point(x, y);
|
|
17835
17831
|
let newX = pointer.x;
|
|
@@ -17843,7 +17839,7 @@ class Line extends FabricObject {
|
|
|
17843
17839
|
newY = snapped.y;
|
|
17844
17840
|
}
|
|
17845
17841
|
if (this._useEndpointCoords) {
|
|
17846
|
-
var _this$
|
|
17842
|
+
var _this$canvas3;
|
|
17847
17843
|
if (controlKey === 'p1') {
|
|
17848
17844
|
this.x1 = newX;
|
|
17849
17845
|
this.y1 = newY;
|
|
@@ -17853,7 +17849,7 @@ class Line extends FabricObject {
|
|
|
17853
17849
|
}
|
|
17854
17850
|
this.dirty = true;
|
|
17855
17851
|
this.setCoords();
|
|
17856
|
-
(_this$
|
|
17852
|
+
(_this$canvas3 = this.canvas) === null || _this$canvas3 === void 0 || _this$canvas3.requestRenderAll();
|
|
17857
17853
|
return true;
|
|
17858
17854
|
}
|
|
17859
17855
|
|
|
@@ -17869,7 +17865,7 @@ class Line extends FabricObject {
|
|
|
17869
17865
|
this._setWidthHeight();
|
|
17870
17866
|
this.dirty = true;
|
|
17871
17867
|
this._updatingEndpoints = false;
|
|
17872
|
-
(_this$
|
|
17868
|
+
(_this$canvas4 = this.canvas) === null || _this$canvas4 === void 0 || _this$canvas4.requestRenderAll();
|
|
17873
17869
|
this.fire('modified', {
|
|
17874
17870
|
transform: transformData,
|
|
17875
17871
|
target: this,
|
|
@@ -17944,11 +17940,9 @@ class Line extends FabricObject {
|
|
|
17944
17940
|
super.render(ctx);
|
|
17945
17941
|
}
|
|
17946
17942
|
_renderDirectly(ctx) {
|
|
17947
|
-
var _this$
|
|
17943
|
+
var _this$stroke;
|
|
17948
17944
|
if (!this.visible) return;
|
|
17949
17945
|
ctx.save();
|
|
17950
|
-
const vpt = ((_this$canvas7 = this.canvas) === null || _this$canvas7 === void 0 ? void 0 : _this$canvas7.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17951
|
-
ctx.transform(vpt[0], vpt[1], vpt[2], vpt[3], vpt[4], vpt[5]);
|
|
17952
17946
|
ctx.globalAlpha = this.opacity;
|
|
17953
17947
|
ctx.strokeStyle = ((_this$stroke = this.stroke) === null || _this$stroke === void 0 ? void 0 : _this$stroke.toString()) || '#000';
|
|
17954
17948
|
ctx.lineWidth = this.strokeWidth;
|
|
@@ -18020,13 +18014,28 @@ class Line extends FabricObject {
|
|
|
18020
18014
|
};
|
|
18021
18015
|
}
|
|
18022
18016
|
_toSVG() {
|
|
18023
|
-
|
|
18024
|
-
|
|
18025
|
-
x2
|
|
18026
|
-
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
|
|
18017
|
+
if (this._useEndpointCoords) {
|
|
18018
|
+
// Use absolute coordinates to bypass all Fabric.js transforms
|
|
18019
|
+
return [`<line stroke="${this.stroke}" stroke-width="${this.strokeWidth}" stroke-linecap="${this.strokeLineCap}" `, `x1="${this.x1}" y1="${this.y1}" x2="${this.x2}" y2="${this.y2}" />\n`];
|
|
18020
|
+
} else {
|
|
18021
|
+
// Use standard calcLinePoints for legacy mode
|
|
18022
|
+
const {
|
|
18023
|
+
x1,
|
|
18024
|
+
x2,
|
|
18025
|
+
y1,
|
|
18026
|
+
y2
|
|
18027
|
+
} = this.calcLinePoints();
|
|
18028
|
+
return ['<line ', 'COMMON_PARTS', `x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" />\n`];
|
|
18029
|
+
}
|
|
18030
|
+
}
|
|
18031
|
+
toSVG(reviver) {
|
|
18032
|
+
if (this._useEndpointCoords) {
|
|
18033
|
+
// Override toSVG to prevent Fabric.js from adding transform wrapper
|
|
18034
|
+
const markup = this._toSVG().join('');
|
|
18035
|
+
return reviver ? reviver(markup) : markup;
|
|
18036
|
+
}
|
|
18037
|
+
// Use default behavior for legacy mode
|
|
18038
|
+
return super.toSVG(reviver);
|
|
18030
18039
|
}
|
|
18031
18040
|
static async fromElement(element, options, cssRules) {
|
|
18032
18041
|
const {
|