@nasser-sw/fabric 7.0.1-beta5 → 7.0.1-beta7
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 +28 -23
- 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 +28 -23
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +28 -23
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +28 -23
- 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.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 +27 -22
- package/dist/src/shapes/Line.mjs.map +1 -1
- package/dist-extensions/src/shapes/Line.d.ts.map +1 -1
- package/fabric-test2.html +91 -0
- package/package.json +1 -1
- package/src/shapes/Line.ts +19 -11
package/dist/index.node.mjs
CHANGED
|
@@ -410,7 +410,7 @@ class Cache {
|
|
|
410
410
|
}
|
|
411
411
|
const cache = new Cache();
|
|
412
412
|
|
|
413
|
-
var version = "7.0.1-
|
|
413
|
+
var version = "7.0.1-beta6";
|
|
414
414
|
|
|
415
415
|
// use this syntax so babel plugin see this import here
|
|
416
416
|
const VERSION = version;
|
|
@@ -17684,14 +17684,10 @@ class Line extends FabricObject {
|
|
|
17684
17684
|
};
|
|
17685
17685
|
}
|
|
17686
17686
|
_p1PositionHandler() {
|
|
17687
|
-
|
|
17688
|
-
const vpt = ((_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17689
|
-
return new Point(this.x1, this.y1).transform(vpt);
|
|
17687
|
+
return new Point(this.x1, this.y1).transform(this.getViewportTransform());
|
|
17690
17688
|
}
|
|
17691
17689
|
_p2PositionHandler() {
|
|
17692
|
-
|
|
17693
|
-
const vpt = ((_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17694
|
-
return new Point(this.x2, this.y2).transform(vpt);
|
|
17690
|
+
return new Point(this.x2, this.y2).transform(this.getViewportTransform());
|
|
17695
17691
|
}
|
|
17696
17692
|
_renderEndpointControl(ctx, left, top) {
|
|
17697
17693
|
const size = 12;
|
|
@@ -17714,9 +17710,9 @@ class Line extends FabricObject {
|
|
|
17714
17710
|
return super.drawBorders(ctx, styleOverride, {});
|
|
17715
17711
|
}
|
|
17716
17712
|
_drawLineBorders(ctx) {
|
|
17717
|
-
var _this$
|
|
17713
|
+
var _this$canvas;
|
|
17718
17714
|
let styleOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17719
|
-
const vpt = ((_this$
|
|
17715
|
+
const vpt = ((_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17720
17716
|
ctx.save();
|
|
17721
17717
|
ctx.setTransform(vpt[0], vpt[1], vpt[2], vpt[3], vpt[4], vpt[5]);
|
|
17722
17718
|
ctx.strokeStyle = styleOverride.borderColor || this.borderColor || 'rgba(100, 200, 200, 0.5)';
|
|
@@ -17757,16 +17753,18 @@ class Line extends FabricObject {
|
|
|
17757
17753
|
}
|
|
17758
17754
|
setCoords() {
|
|
17759
17755
|
if (this._useEndpointCoords) {
|
|
17760
|
-
// Set the object's center to the geometric center of the line
|
|
17761
|
-
const center = this._findCenterFromElement();
|
|
17762
|
-
this.left = center.x;
|
|
17763
|
-
this.top = center.y;
|
|
17764
|
-
|
|
17765
17756
|
// Set width and height for hit detection and bounding box
|
|
17766
17757
|
const effectiveStrokeWidth = this.hitStrokeWidth === 'auto' ? this.strokeWidth : this.hitStrokeWidth;
|
|
17767
17758
|
const hitPadding = Math.max(effectiveStrokeWidth / 2 + 5, 10);
|
|
17768
17759
|
this.width = Math.abs(this.x2 - this.x1) + hitPadding * 2;
|
|
17769
17760
|
this.height = Math.abs(this.y2 - this.y1) + hitPadding * 2;
|
|
17761
|
+
|
|
17762
|
+
// Only update left/top if they haven't been explicitly set (e.g., during loading)
|
|
17763
|
+
if (this.left === 0 && this.top === 0) {
|
|
17764
|
+
const center = this._findCenterFromElement();
|
|
17765
|
+
this.left = center.x;
|
|
17766
|
+
this.top = center.y;
|
|
17767
|
+
}
|
|
17770
17768
|
}
|
|
17771
17769
|
super.setCoords();
|
|
17772
17770
|
}
|
|
@@ -17792,8 +17790,8 @@ class Line extends FabricObject {
|
|
|
17792
17790
|
}
|
|
17793
17791
|
containsPoint(point) {
|
|
17794
17792
|
if (this._useEndpointCoords) {
|
|
17795
|
-
var _this$
|
|
17796
|
-
if (((_this$
|
|
17793
|
+
var _this$canvas2;
|
|
17794
|
+
if (((_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.getActiveObject()) === this) {
|
|
17797
17795
|
return super.containsPoint(point);
|
|
17798
17796
|
}
|
|
17799
17797
|
const distance = this._distanceToLineSegment(point.x, point.y);
|
|
@@ -17827,7 +17825,7 @@ class Line extends FabricObject {
|
|
|
17827
17825
|
return Math.sqrt((px - closestX) * (px - closestX) + (py - closestY) * (py - closestY));
|
|
17828
17826
|
}
|
|
17829
17827
|
_endpointActionHandler(eventData, transformData, x, y) {
|
|
17830
|
-
var _this$
|
|
17828
|
+
var _this$canvas4;
|
|
17831
17829
|
const controlKey = transformData.corner;
|
|
17832
17830
|
const pointer = new Point(x, y);
|
|
17833
17831
|
let newX = pointer.x;
|
|
@@ -17841,7 +17839,7 @@ class Line extends FabricObject {
|
|
|
17841
17839
|
newY = snapped.y;
|
|
17842
17840
|
}
|
|
17843
17841
|
if (this._useEndpointCoords) {
|
|
17844
|
-
var _this$
|
|
17842
|
+
var _this$canvas3;
|
|
17845
17843
|
if (controlKey === 'p1') {
|
|
17846
17844
|
this.x1 = newX;
|
|
17847
17845
|
this.y1 = newY;
|
|
@@ -17851,7 +17849,7 @@ class Line extends FabricObject {
|
|
|
17851
17849
|
}
|
|
17852
17850
|
this.dirty = true;
|
|
17853
17851
|
this.setCoords();
|
|
17854
|
-
(_this$
|
|
17852
|
+
(_this$canvas3 = this.canvas) === null || _this$canvas3 === void 0 || _this$canvas3.requestRenderAll();
|
|
17855
17853
|
return true;
|
|
17856
17854
|
}
|
|
17857
17855
|
|
|
@@ -17867,7 +17865,7 @@ class Line extends FabricObject {
|
|
|
17867
17865
|
this._setWidthHeight();
|
|
17868
17866
|
this.dirty = true;
|
|
17869
17867
|
this._updatingEndpoints = false;
|
|
17870
|
-
(_this$
|
|
17868
|
+
(_this$canvas4 = this.canvas) === null || _this$canvas4 === void 0 || _this$canvas4.requestRenderAll();
|
|
17871
17869
|
this.fire('modified', {
|
|
17872
17870
|
transform: transformData,
|
|
17873
17871
|
target: this,
|
|
@@ -17942,11 +17940,9 @@ class Line extends FabricObject {
|
|
|
17942
17940
|
super.render(ctx);
|
|
17943
17941
|
}
|
|
17944
17942
|
_renderDirectly(ctx) {
|
|
17945
|
-
var _this$
|
|
17943
|
+
var _this$stroke;
|
|
17946
17944
|
if (!this.visible) return;
|
|
17947
17945
|
ctx.save();
|
|
17948
|
-
const vpt = ((_this$canvas7 = this.canvas) === null || _this$canvas7 === void 0 ? void 0 : _this$canvas7.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17949
|
-
ctx.transform(vpt[0], vpt[1], vpt[2], vpt[3], vpt[4], vpt[5]);
|
|
17950
17946
|
ctx.globalAlpha = this.opacity;
|
|
17951
17947
|
ctx.strokeStyle = ((_this$stroke = this.stroke) === null || _this$stroke === void 0 ? void 0 : _this$stroke.toString()) || '#000';
|
|
17952
17948
|
ctx.lineWidth = this.strokeWidth;
|
|
@@ -17976,6 +17972,15 @@ class Line extends FabricObject {
|
|
|
17976
17972
|
}
|
|
17977
17973
|
toObject() {
|
|
17978
17974
|
let propertiesToInclude = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
17975
|
+
if (this._useEndpointCoords) {
|
|
17976
|
+
return {
|
|
17977
|
+
...super.toObject(propertiesToInclude),
|
|
17978
|
+
x1: this.x1,
|
|
17979
|
+
y1: this.y1,
|
|
17980
|
+
x2: this.x2,
|
|
17981
|
+
y2: this.y2
|
|
17982
|
+
};
|
|
17983
|
+
}
|
|
17979
17984
|
return {
|
|
17980
17985
|
...super.toObject(propertiesToInclude),
|
|
17981
17986
|
...this.calcLinePoints()
|