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