@nasser-sw/fabric 7.0.1-beta6 → 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.
@@ -175,11 +175,6 @@ export class Line<
175
175
 
176
176
  setCoords() {
177
177
  if (this._useEndpointCoords) {
178
- // Set the object's center to the geometric center of the line
179
- const center = this._findCenterFromElement();
180
- this.left = center.x;
181
- this.top = center.y;
182
-
183
178
  // Set width and height for hit detection and bounding box
184
179
  const effectiveStrokeWidth =
185
180
  this.hitStrokeWidth === 'auto'
@@ -188,6 +183,13 @@ export class Line<
188
183
  const hitPadding = Math.max(effectiveStrokeWidth / 2 + 5, 10);
189
184
  this.width = Math.abs(this.x2 - this.x1) + hitPadding * 2;
190
185
  this.height = Math.abs(this.y2 - this.y1) + hitPadding * 2;
186
+
187
+ // Only update left/top if they haven't been explicitly set (e.g., during loading)
188
+ if (this.left === 0 && this.top === 0) {
189
+ const center = this._findCenterFromElement();
190
+ this.left = center.x;
191
+ this.top = center.y;
192
+ }
191
193
  }
192
194
  super.setCoords();
193
195
  }
@@ -418,6 +420,15 @@ export class Line<
418
420
  T extends Omit<Props & TClassProperties<this>, keyof SProps>,
419
421
  K extends keyof T = never
420
422
  >(propertiesToInclude: K[] = []): Pick<T, K> & SProps {
423
+ if (this._useEndpointCoords) {
424
+ return {
425
+ ...super.toObject(propertiesToInclude),
426
+ x1: this.x1,
427
+ y1: this.y1,
428
+ x2: this.x2,
429
+ y2: this.y2,
430
+ };
431
+ }
421
432
  return {
422
433
  ...super.toObject(propertiesToInclude),
423
434
  ...this.calcLinePoints(),