@nasser-sw/fabric 7.0.1-beta21 → 7.0.1-beta23

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-beta20";
357
+ var version = "7.0.1-beta22";
358
358
 
359
359
  // use this syntax so babel plugin see this import here
360
360
  const VERSION = version;
@@ -30983,6 +30983,13 @@ class Frame extends Group {
30983
30983
  this._editModeObjectCaching = this.objectCaching;
30984
30984
  this.objectCaching = false;
30985
30985
 
30986
+ // Force clear any existing cache
30987
+ this.dirty = true;
30988
+ if (this._cacheCanvas) {
30989
+ this._cacheCanvas = null;
30990
+ this._cacheContext = null;
30991
+ }
30992
+
30986
30993
  // Enable sub-target interaction so clicks go through to content
30987
30994
  this.subTargetCheck = true;
30988
30995
  this.interactive = true;
@@ -30993,28 +31000,35 @@ class Frame extends Group {
30993
31000
  const minScale = this._calculateCoverScale(originalWidth, originalHeight);
30994
31001
 
30995
31002
  // Make content image interactive with scale constraint
31003
+ // Also disable its caching to ensure it renders fully
30996
31004
  this._contentImage.set({
30997
31005
  selectable: true,
30998
31006
  evented: true,
30999
31007
  hasControls: true,
31000
31008
  hasBorders: true,
31001
31009
  minScaleLimit: minScale,
31002
- lockScalingFlip: true
31010
+ lockScalingFlip: true,
31011
+ objectCaching: false
31003
31012
  });
31013
+ this._contentImage.dirty = true;
31004
31014
 
31005
- // Store clip path but keep rendering it for the overlay effect
31015
+ // Keep clipPath reference for the overlay effect rendering
31016
+ // NOTE: We do NOT set this.clipPath = undefined because that triggers
31017
+ // coordinate recalculations in Fabric that behave differently with
31018
+ // viewport transforms (autoZoom), causing visual position jumps.
31019
+ // Instead, we override drawObject() to skip clipPath rendering in edit mode.
31006
31020
  if (this.clipPath) {
31007
31021
  this._editModeClipPath = this.clipPath;
31008
- this.clipPath = undefined;
31009
31022
  }
31010
31023
 
31011
31024
  // Add constraint handlers for moving/scaling
31012
31025
  this._setupEditModeConstraints();
31013
31026
  this.set('dirty', true);
31014
31027
 
31015
- // Select the content image on the canvas
31028
+ // Just render - don't call setActiveObject() on the content image
31029
+ // because it causes position miscalculation with viewport transforms.
31030
+ // The content image is still interactive via subTargetCheck = true
31016
31031
  if (this.canvas) {
31017
- this.canvas.setActiveObject(this._contentImage);
31018
31032
  this.canvas.renderAll();
31019
31033
  }
31020
31034
 
@@ -31096,6 +31110,38 @@ class Frame extends Group {
31096
31110
  this._boundConstrainScale = undefined;
31097
31111
  }
31098
31112
  }
31113
+ /**
31114
+ * Override shouldCache to prevent caching during edit mode.
31115
+ * This ensures the full image is rendered without cache-based clipping.
31116
+ * @override
31117
+ */
31118
+ shouldCache() {
31119
+ if (this.isEditMode) {
31120
+ this.ownCaching = false;
31121
+ return false;
31122
+ }
31123
+ return super.shouldCache();
31124
+ }
31125
+
31126
+ /**
31127
+ * Override drawObject to skip clipPath rendering during edit mode.
31128
+ * This prevents coordinate recalculation issues with viewport transforms.
31129
+ * @override
31130
+ */
31131
+ drawObject(ctx, forClipping, context) {
31132
+ this._renderBackground(ctx);
31133
+ for (let i = 0; i < this._objects.length; i++) {
31134
+ const obj = this._objects[i];
31135
+ if (obj.group === this) {
31136
+ obj.render(ctx);
31137
+ }
31138
+ }
31139
+ // Skip clipPath rendering in edit mode to show full image
31140
+ if (!this.isEditMode) {
31141
+ this._drawClipPath(ctx, this.clipPath, context);
31142
+ }
31143
+ }
31144
+
31099
31145
  /**
31100
31146
  * Custom render to show edit mode overlay
31101
31147
  * @override
@@ -31242,21 +31288,17 @@ class Frame extends Group {
31242
31288
  contentScale: currentScale
31243
31289
  };
31244
31290
 
31245
- // Make content non-interactive again
31291
+ // Make content non-interactive again and restore caching
31246
31292
  this._contentImage.set({
31247
31293
  selectable: false,
31248
31294
  evented: false,
31249
31295
  hasControls: false,
31250
- hasBorders: false
31296
+ hasBorders: false,
31297
+ objectCaching: true
31251
31298
  });
31252
31299
 
31253
- // Restore clip path
31254
- if (this._editModeClipPath) {
31255
- this.clipPath = this._editModeClipPath;
31256
- this._editModeClipPath = undefined;
31257
- } else {
31258
- this._updateClipPath();
31259
- }
31300
+ // Clear edit mode clip path reference (clipPath was never removed, just skipped during render)
31301
+ this._editModeClipPath = undefined;
31260
31302
 
31261
31303
  // Restore caching setting
31262
31304
  if (this._editModeObjectCaching !== undefined) {