@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.
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-beta3";
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;
@@ -17701,14 +17701,14 @@ class Line extends FabricObject {
17701
17701
  }
17702
17702
  setCoords() {
17703
17703
  if (this._useEndpointCoords) {
17704
- const minX = Math.min(this.x1, this.x2);
17705
- const maxX = Math.max(this.x1, this.x2);
17706
- const minY = Math.min(this.y1, this.y2);
17707
- const maxY = Math.max(this.y1, this.y2);
17704
+ // Set the object's center to the geometric center of the line
17705
+ const center = this._findCenterFromElement();
17706
+ this.left = center.x;
17707
+ this.top = center.y;
17708
+
17709
+ // Set width and height for hit detection and bounding box
17708
17710
  const effectiveStrokeWidth = this.hitStrokeWidth === 'auto' ? this.strokeWidth : this.hitStrokeWidth;
17709
17711
  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
17712
  this.width = Math.abs(this.x2 - this.x1) + hitPadding * 2;
17713
17713
  this.height = Math.abs(this.y2 - this.y1) + hitPadding * 2;
17714
17714
  }
@@ -17962,13 +17962,28 @@ class Line extends FabricObject {
17962
17962
  };
17963
17963
  }
17964
17964
  _toSVG() {
17965
- const {
17966
- x1,
17967
- x2,
17968
- y1,
17969
- y2
17970
- } = this.calcLinePoints();
17971
- return ['<line ', 'COMMON_PARTS', `x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" />\n`];
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);
17972
17987
  }
17973
17988
  static async fromElement(element, options, cssRules) {
17974
17989
  const {