@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.js
CHANGED
|
@@ -360,7 +360,7 @@
|
|
|
360
360
|
}
|
|
361
361
|
const cache = new Cache();
|
|
362
362
|
|
|
363
|
-
var version = "7.0.1-
|
|
363
|
+
var version = "7.0.1-beta5";
|
|
364
364
|
|
|
365
365
|
// use this syntax so babel plugin see this import here
|
|
366
366
|
const VERSION = version;
|
|
@@ -17634,14 +17634,10 @@
|
|
|
17634
17634
|
};
|
|
17635
17635
|
}
|
|
17636
17636
|
_p1PositionHandler() {
|
|
17637
|
-
|
|
17638
|
-
const vpt = ((_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17639
|
-
return new Point(this.x1, this.y1).transform(vpt);
|
|
17637
|
+
return new Point(this.x1, this.y1).transform(this.getViewportTransform());
|
|
17640
17638
|
}
|
|
17641
17639
|
_p2PositionHandler() {
|
|
17642
|
-
|
|
17643
|
-
const vpt = ((_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17644
|
-
return new Point(this.x2, this.y2).transform(vpt);
|
|
17640
|
+
return new Point(this.x2, this.y2).transform(this.getViewportTransform());
|
|
17645
17641
|
}
|
|
17646
17642
|
_renderEndpointControl(ctx, left, top) {
|
|
17647
17643
|
const size = 12;
|
|
@@ -17664,9 +17660,9 @@
|
|
|
17664
17660
|
return super.drawBorders(ctx, styleOverride, {});
|
|
17665
17661
|
}
|
|
17666
17662
|
_drawLineBorders(ctx) {
|
|
17667
|
-
var _this$
|
|
17663
|
+
var _this$canvas;
|
|
17668
17664
|
let styleOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17669
|
-
const vpt = ((_this$
|
|
17665
|
+
const vpt = ((_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17670
17666
|
ctx.save();
|
|
17671
17667
|
ctx.setTransform(vpt[0], vpt[1], vpt[2], vpt[3], vpt[4], vpt[5]);
|
|
17672
17668
|
ctx.strokeStyle = styleOverride.borderColor || this.borderColor || 'rgba(100, 200, 200, 0.5)';
|
|
@@ -17707,14 +17703,14 @@
|
|
|
17707
17703
|
}
|
|
17708
17704
|
setCoords() {
|
|
17709
17705
|
if (this._useEndpointCoords) {
|
|
17710
|
-
|
|
17711
|
-
const
|
|
17712
|
-
|
|
17713
|
-
|
|
17706
|
+
// Set the object's center to the geometric center of the line
|
|
17707
|
+
const center = this._findCenterFromElement();
|
|
17708
|
+
this.left = center.x;
|
|
17709
|
+
this.top = center.y;
|
|
17710
|
+
|
|
17711
|
+
// Set width and height for hit detection and bounding box
|
|
17714
17712
|
const effectiveStrokeWidth = this.hitStrokeWidth === 'auto' ? this.strokeWidth : this.hitStrokeWidth;
|
|
17715
17713
|
const hitPadding = Math.max(effectiveStrokeWidth / 2 + 5, 10);
|
|
17716
|
-
this.left = minX - hitPadding + (maxX - minX + hitPadding * 2) / 2;
|
|
17717
|
-
this.top = minY - hitPadding + (maxY - minY + hitPadding * 2) / 2;
|
|
17718
17714
|
this.width = Math.abs(this.x2 - this.x1) + hitPadding * 2;
|
|
17719
17715
|
this.height = Math.abs(this.y2 - this.y1) + hitPadding * 2;
|
|
17720
17716
|
}
|
|
@@ -17742,8 +17738,8 @@
|
|
|
17742
17738
|
}
|
|
17743
17739
|
containsPoint(point) {
|
|
17744
17740
|
if (this._useEndpointCoords) {
|
|
17745
|
-
var _this$
|
|
17746
|
-
if (((_this$
|
|
17741
|
+
var _this$canvas2;
|
|
17742
|
+
if (((_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.getActiveObject()) === this) {
|
|
17747
17743
|
return super.containsPoint(point);
|
|
17748
17744
|
}
|
|
17749
17745
|
const distance = this._distanceToLineSegment(point.x, point.y);
|
|
@@ -17777,7 +17773,7 @@
|
|
|
17777
17773
|
return Math.sqrt((px - closestX) * (px - closestX) + (py - closestY) * (py - closestY));
|
|
17778
17774
|
}
|
|
17779
17775
|
_endpointActionHandler(eventData, transformData, x, y) {
|
|
17780
|
-
var _this$
|
|
17776
|
+
var _this$canvas4;
|
|
17781
17777
|
const controlKey = transformData.corner;
|
|
17782
17778
|
const pointer = new Point(x, y);
|
|
17783
17779
|
let newX = pointer.x;
|
|
@@ -17791,7 +17787,7 @@
|
|
|
17791
17787
|
newY = snapped.y;
|
|
17792
17788
|
}
|
|
17793
17789
|
if (this._useEndpointCoords) {
|
|
17794
|
-
var _this$
|
|
17790
|
+
var _this$canvas3;
|
|
17795
17791
|
if (controlKey === 'p1') {
|
|
17796
17792
|
this.x1 = newX;
|
|
17797
17793
|
this.y1 = newY;
|
|
@@ -17801,7 +17797,7 @@
|
|
|
17801
17797
|
}
|
|
17802
17798
|
this.dirty = true;
|
|
17803
17799
|
this.setCoords();
|
|
17804
|
-
(_this$
|
|
17800
|
+
(_this$canvas3 = this.canvas) === null || _this$canvas3 === void 0 || _this$canvas3.requestRenderAll();
|
|
17805
17801
|
return true;
|
|
17806
17802
|
}
|
|
17807
17803
|
|
|
@@ -17817,7 +17813,7 @@
|
|
|
17817
17813
|
this._setWidthHeight();
|
|
17818
17814
|
this.dirty = true;
|
|
17819
17815
|
this._updatingEndpoints = false;
|
|
17820
|
-
(_this$
|
|
17816
|
+
(_this$canvas4 = this.canvas) === null || _this$canvas4 === void 0 || _this$canvas4.requestRenderAll();
|
|
17821
17817
|
this.fire('modified', {
|
|
17822
17818
|
transform: transformData,
|
|
17823
17819
|
target: this,
|
|
@@ -17892,11 +17888,9 @@
|
|
|
17892
17888
|
super.render(ctx);
|
|
17893
17889
|
}
|
|
17894
17890
|
_renderDirectly(ctx) {
|
|
17895
|
-
var _this$
|
|
17891
|
+
var _this$stroke;
|
|
17896
17892
|
if (!this.visible) return;
|
|
17897
17893
|
ctx.save();
|
|
17898
|
-
const vpt = ((_this$canvas7 = this.canvas) === null || _this$canvas7 === void 0 ? void 0 : _this$canvas7.viewportTransform) || [1, 0, 0, 1, 0, 0];
|
|
17899
|
-
ctx.transform(vpt[0], vpt[1], vpt[2], vpt[3], vpt[4], vpt[5]);
|
|
17900
17894
|
ctx.globalAlpha = this.opacity;
|
|
17901
17895
|
ctx.strokeStyle = ((_this$stroke = this.stroke) === null || _this$stroke === void 0 ? void 0 : _this$stroke.toString()) || '#000';
|
|
17902
17896
|
ctx.lineWidth = this.strokeWidth;
|
|
@@ -17968,13 +17962,28 @@
|
|
|
17968
17962
|
};
|
|
17969
17963
|
}
|
|
17970
17964
|
_toSVG() {
|
|
17971
|
-
|
|
17972
|
-
|
|
17973
|
-
x2
|
|
17974
|
-
|
|
17975
|
-
|
|
17976
|
-
|
|
17977
|
-
|
|
17965
|
+
if (this._useEndpointCoords) {
|
|
17966
|
+
// Use absolute coordinates to bypass all Fabric.js transforms
|
|
17967
|
+
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`];
|
|
17968
|
+
} else {
|
|
17969
|
+
// Use standard calcLinePoints for legacy mode
|
|
17970
|
+
const {
|
|
17971
|
+
x1,
|
|
17972
|
+
x2,
|
|
17973
|
+
y1,
|
|
17974
|
+
y2
|
|
17975
|
+
} = this.calcLinePoints();
|
|
17976
|
+
return ['<line ', 'COMMON_PARTS', `x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" />\n`];
|
|
17977
|
+
}
|
|
17978
|
+
}
|
|
17979
|
+
toSVG(reviver) {
|
|
17980
|
+
if (this._useEndpointCoords) {
|
|
17981
|
+
// Override toSVG to prevent Fabric.js from adding transform wrapper
|
|
17982
|
+
const markup = this._toSVG().join('');
|
|
17983
|
+
return reviver ? reviver(markup) : markup;
|
|
17984
|
+
}
|
|
17985
|
+
// Use default behavior for legacy mode
|
|
17986
|
+
return super.toSVG(reviver);
|
|
17978
17987
|
}
|
|
17979
17988
|
static async fromElement(element, options, cssRules) {
|
|
17980
17989
|
const {
|