@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.mjs
CHANGED
|
@@ -354,7 +354,7 @@ class Cache {
|
|
|
354
354
|
}
|
|
355
355
|
const cache = new Cache();
|
|
356
356
|
|
|
357
|
-
var version = "7.0.1-
|
|
357
|
+
var version = "7.0.1-beta5";
|
|
358
358
|
|
|
359
359
|
// use this syntax so babel plugin see this import here
|
|
360
360
|
const VERSION = version;
|
|
@@ -17628,14 +17628,10 @@ class Line extends FabricObject {
|
|
|
17628
17628
|
};
|
|
17629
17629
|
}
|
|
17630
17630
|
_p1PositionHandler() {
|
|
17631
|
-
|
|
17632
|
-
const vpt = ((_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17633
|
-
return new Point(this.x1, this.y1).transform(vpt);
|
|
17631
|
+
return new Point(this.x1, this.y1).transform(this.getViewportTransform());
|
|
17634
17632
|
}
|
|
17635
17633
|
_p2PositionHandler() {
|
|
17636
|
-
|
|
17637
|
-
const vpt = ((_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17638
|
-
return new Point(this.x2, this.y2).transform(vpt);
|
|
17634
|
+
return new Point(this.x2, this.y2).transform(this.getViewportTransform());
|
|
17639
17635
|
}
|
|
17640
17636
|
_renderEndpointControl(ctx, left, top) {
|
|
17641
17637
|
const size = 12;
|
|
@@ -17658,9 +17654,9 @@ class Line extends FabricObject {
|
|
|
17658
17654
|
return super.drawBorders(ctx, styleOverride, {});
|
|
17659
17655
|
}
|
|
17660
17656
|
_drawLineBorders(ctx) {
|
|
17661
|
-
var _this$
|
|
17657
|
+
var _this$canvas;
|
|
17662
17658
|
let styleOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17663
|
-
const vpt = ((_this$
|
|
17659
|
+
const vpt = ((_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17664
17660
|
ctx.save();
|
|
17665
17661
|
ctx.setTransform(vpt[0], vpt[1], vpt[2], vpt[3], vpt[4], vpt[5]);
|
|
17666
17662
|
ctx.strokeStyle = styleOverride.borderColor || this.borderColor || 'rgba(100, 200, 200, 0.5)';
|
|
@@ -17701,14 +17697,14 @@ class Line extends FabricObject {
|
|
|
17701
17697
|
}
|
|
17702
17698
|
setCoords() {
|
|
17703
17699
|
if (this._useEndpointCoords) {
|
|
17704
|
-
|
|
17705
|
-
const
|
|
17706
|
-
|
|
17707
|
-
|
|
17700
|
+
// Set the object's center to the geometric center of the line
|
|
17701
|
+
const center = this._findCenterFromElement();
|
|
17702
|
+
this.left = center.x;
|
|
17703
|
+
this.top = center.y;
|
|
17704
|
+
|
|
17705
|
+
// Set width and height for hit detection and bounding box
|
|
17708
17706
|
const effectiveStrokeWidth = this.hitStrokeWidth === 'auto' ? this.strokeWidth : this.hitStrokeWidth;
|
|
17709
17707
|
const hitPadding = Math.max(effectiveStrokeWidth / 2 + 5, 10);
|
|
17710
|
-
this.left = minX - hitPadding + (maxX - minX + hitPadding * 2) / 2;
|
|
17711
|
-
this.top = minY - hitPadding + (maxY - minY + hitPadding * 2) / 2;
|
|
17712
17708
|
this.width = Math.abs(this.x2 - this.x1) + hitPadding * 2;
|
|
17713
17709
|
this.height = Math.abs(this.y2 - this.y1) + hitPadding * 2;
|
|
17714
17710
|
}
|
|
@@ -17736,8 +17732,8 @@ class Line extends FabricObject {
|
|
|
17736
17732
|
}
|
|
17737
17733
|
containsPoint(point) {
|
|
17738
17734
|
if (this._useEndpointCoords) {
|
|
17739
|
-
var _this$
|
|
17740
|
-
if (((_this$
|
|
17735
|
+
var _this$canvas2;
|
|
17736
|
+
if (((_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.getActiveObject()) === this) {
|
|
17741
17737
|
return super.containsPoint(point);
|
|
17742
17738
|
}
|
|
17743
17739
|
const distance = this._distanceToLineSegment(point.x, point.y);
|
|
@@ -17771,7 +17767,7 @@ class Line extends FabricObject {
|
|
|
17771
17767
|
return Math.sqrt((px - closestX) * (px - closestX) + (py - closestY) * (py - closestY));
|
|
17772
17768
|
}
|
|
17773
17769
|
_endpointActionHandler(eventData, transformData, x, y) {
|
|
17774
|
-
var _this$
|
|
17770
|
+
var _this$canvas4;
|
|
17775
17771
|
const controlKey = transformData.corner;
|
|
17776
17772
|
const pointer = new Point(x, y);
|
|
17777
17773
|
let newX = pointer.x;
|
|
@@ -17785,7 +17781,7 @@ class Line extends FabricObject {
|
|
|
17785
17781
|
newY = snapped.y;
|
|
17786
17782
|
}
|
|
17787
17783
|
if (this._useEndpointCoords) {
|
|
17788
|
-
var _this$
|
|
17784
|
+
var _this$canvas3;
|
|
17789
17785
|
if (controlKey === 'p1') {
|
|
17790
17786
|
this.x1 = newX;
|
|
17791
17787
|
this.y1 = newY;
|
|
@@ -17795,7 +17791,7 @@ class Line extends FabricObject {
|
|
|
17795
17791
|
}
|
|
17796
17792
|
this.dirty = true;
|
|
17797
17793
|
this.setCoords();
|
|
17798
|
-
(_this$
|
|
17794
|
+
(_this$canvas3 = this.canvas) === null || _this$canvas3 === void 0 || _this$canvas3.requestRenderAll();
|
|
17799
17795
|
return true;
|
|
17800
17796
|
}
|
|
17801
17797
|
|
|
@@ -17811,7 +17807,7 @@ class Line extends FabricObject {
|
|
|
17811
17807
|
this._setWidthHeight();
|
|
17812
17808
|
this.dirty = true;
|
|
17813
17809
|
this._updatingEndpoints = false;
|
|
17814
|
-
(_this$
|
|
17810
|
+
(_this$canvas4 = this.canvas) === null || _this$canvas4 === void 0 || _this$canvas4.requestRenderAll();
|
|
17815
17811
|
this.fire('modified', {
|
|
17816
17812
|
transform: transformData,
|
|
17817
17813
|
target: this,
|
|
@@ -17886,11 +17882,9 @@ class Line extends FabricObject {
|
|
|
17886
17882
|
super.render(ctx);
|
|
17887
17883
|
}
|
|
17888
17884
|
_renderDirectly(ctx) {
|
|
17889
|
-
var _this$
|
|
17885
|
+
var _this$stroke;
|
|
17890
17886
|
if (!this.visible) return;
|
|
17891
17887
|
ctx.save();
|
|
17892
|
-
const vpt = ((_this$canvas7 = this.canvas) === null || _this$canvas7 === void 0 ? void 0 : _this$canvas7.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17893
|
-
ctx.transform(vpt[0], vpt[1], vpt[2], vpt[3], vpt[4], vpt[5]);
|
|
17894
17888
|
ctx.globalAlpha = this.opacity;
|
|
17895
17889
|
ctx.strokeStyle = ((_this$stroke = this.stroke) === null || _this$stroke === void 0 ? void 0 : _this$stroke.toString()) || '#000';
|
|
17896
17890
|
ctx.lineWidth = this.strokeWidth;
|
|
@@ -17962,13 +17956,28 @@ class Line extends FabricObject {
|
|
|
17962
17956
|
};
|
|
17963
17957
|
}
|
|
17964
17958
|
_toSVG() {
|
|
17965
|
-
|
|
17966
|
-
|
|
17967
|
-
x2
|
|
17968
|
-
|
|
17969
|
-
|
|
17970
|
-
|
|
17971
|
-
|
|
17959
|
+
if (this._useEndpointCoords) {
|
|
17960
|
+
// Use absolute coordinates to bypass all Fabric.js transforms
|
|
17961
|
+
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`];
|
|
17962
|
+
} else {
|
|
17963
|
+
// Use standard calcLinePoints for legacy mode
|
|
17964
|
+
const {
|
|
17965
|
+
x1,
|
|
17966
|
+
x2,
|
|
17967
|
+
y1,
|
|
17968
|
+
y2
|
|
17969
|
+
} = this.calcLinePoints();
|
|
17970
|
+
return ['<line ', 'COMMON_PARTS', `x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" />\n`];
|
|
17971
|
+
}
|
|
17972
|
+
}
|
|
17973
|
+
toSVG(reviver) {
|
|
17974
|
+
if (this._useEndpointCoords) {
|
|
17975
|
+
// Override toSVG to prevent Fabric.js from adding transform wrapper
|
|
17976
|
+
const markup = this._toSVG().join('');
|
|
17977
|
+
return reviver ? reviver(markup) : markup;
|
|
17978
|
+
}
|
|
17979
|
+
// Use default behavior for legacy mode
|
|
17980
|
+
return super.toSVG(reviver);
|
|
17972
17981
|
}
|
|
17973
17982
|
static async fromElement(element, options, cssRules) {
|
|
17974
17983
|
const {
|