@nasser-sw/fabric 7.0.1-beta4 → 7.0.1-beta5

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.
@@ -410,7 +410,7 @@ class Cache {
410
410
  }
411
411
  const cache = new Cache();
412
412
 
413
- var version = "7.0.1-beta3";
413
+ var version = "7.0.1-beta5";
414
414
 
415
415
  // use this syntax so babel plugin see this import here
416
416
  const VERSION = version;
@@ -17757,14 +17757,14 @@ class Line extends FabricObject {
17757
17757
  }
17758
17758
  setCoords() {
17759
17759
  if (this._useEndpointCoords) {
17760
- const minX = Math.min(this.x1, this.x2);
17761
- const maxX = Math.max(this.x1, this.x2);
17762
- const minY = Math.min(this.y1, this.y2);
17763
- const maxY = Math.max(this.y1, this.y2);
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
+ // Set width and height for hit detection and bounding box
17764
17766
  const effectiveStrokeWidth = this.hitStrokeWidth === 'auto' ? this.strokeWidth : this.hitStrokeWidth;
17765
17767
  const hitPadding = Math.max(effectiveStrokeWidth / 2 + 5, 10);
17766
- this.left = minX - hitPadding + (maxX - minX + hitPadding * 2) / 2;
17767
- this.top = minY - hitPadding + (maxY - minY + hitPadding * 2) / 2;
17768
17768
  this.width = Math.abs(this.x2 - this.x1) + hitPadding * 2;
17769
17769
  this.height = Math.abs(this.y2 - this.y1) + hitPadding * 2;
17770
17770
  }
@@ -18018,13 +18018,28 @@ class Line extends FabricObject {
18018
18018
  };
18019
18019
  }
18020
18020
  _toSVG() {
18021
- const {
18022
- x1,
18023
- x2,
18024
- y1,
18025
- y2
18026
- } = this.calcLinePoints();
18027
- return ['<line ', 'COMMON_PARTS', `x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" />\n`];
18021
+ if (this._useEndpointCoords) {
18022
+ // Use absolute coordinates to bypass all Fabric.js transforms
18023
+ 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`];
18024
+ } else {
18025
+ // Use standard calcLinePoints for legacy mode
18026
+ const {
18027
+ x1,
18028
+ x2,
18029
+ y1,
18030
+ y2
18031
+ } = this.calcLinePoints();
18032
+ return ['<line ', 'COMMON_PARTS', `x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" />\n`];
18033
+ }
18034
+ }
18035
+ toSVG(reviver) {
18036
+ if (this._useEndpointCoords) {
18037
+ // Override toSVG to prevent Fabric.js from adding transform wrapper
18038
+ const markup = this._toSVG().join('');
18039
+ return reviver ? reviver(markup) : markup;
18040
+ }
18041
+ // Use default behavior for legacy mode
18042
+ return super.toSVG(reviver);
18028
18043
  }
18029
18044
  static async fromElement(element, options, cssRules) {
18030
18045
  const {