@anu3ev/fabric-image-editor 0.9.11 → 0.9.13

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.
Files changed (2) hide show
  1. package/dist/main.js +19 -2
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -278,7 +278,7 @@ var E = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", D =
278
278
  }
279
279
  handleResetObjectFit(e) {
280
280
  let { target: t, e: n } = e;
281
- n && (n.ctrlKey || n.metaKey) || !t || t instanceof v || t.shapeComposite || this.editor.transformManager.resetObject({ object: t });
281
+ n && (n.ctrlKey || n.metaKey) || this.editor.cropManager.resetFrameToSource({ target: t }) || !t || t instanceof v || t.shapeComposite || this.editor.transformManager.resetObject({ object: t });
282
282
  }
283
283
  _shouldIgnoreKeyboardEvent(e) {
284
284
  let t = document.activeElement, n = e.target, r = [
@@ -3955,6 +3955,14 @@ var $t = class {
3955
3955
  }
3956
3956
  return !1;
3957
3957
  }
3958
+ _constrainViewportToPanBounds() {
3959
+ let { canvas: e, montageArea: t, panConstraintManager: n } = this.editor, r = e.viewportTransform;
3960
+ n.updateBounds();
3961
+ let i = n.constrainPan(r[4], r[5]);
3962
+ if (!(i.x !== r[4] || i.y !== r[5])) return;
3963
+ let a = [...r];
3964
+ a[4] = i.x, a[5] = i.y, e.setViewportTransform(a), t.setCoords();
3965
+ }
3958
3966
  updateDefaultZoom(e = this.options.defaultScale) {
3959
3967
  return this.defaultZoom = this._calculateDefaultZoom(e), this.defaultZoom;
3960
3968
  }
@@ -3998,7 +4006,7 @@ var $t = class {
3998
4006
  let { minZoom: n, maxZoom: r } = this, { canvas: i } = this.editor, a = e < 0, o = i.getZoom(), s = i.getCenterPoint(), c = new m(t.pointX ?? s.x, t.pointY ?? s.y);
3999
4007
  this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
4000
4008
  let l = o + Number(e);
4001
- l > r && (l = r), l < n && (l = n), i.zoomToPoint(c, l), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(l, a, e), i.fire("editor:zoom-changed", {
4009
+ l > r && (l = r), l < n && (l = n), i.zoomToPoint(c, l), this._applyViewportCentering(l, a, e), this._constrainViewportToPanBounds(), i.fire("editor:zoom-changed", {
4002
4010
  currentZoom: i.getZoom(),
4003
4011
  zoom: l,
4004
4012
  point: c
@@ -15129,6 +15137,15 @@ var Fc = {
15129
15137
  size: n
15130
15138
  }), this.getState();
15131
15139
  }
15140
+ resetFrameToSource({ target: e }) {
15141
+ let { _session: t } = this;
15142
+ if (!t || t.frame !== e) return null;
15143
+ let n = Cs({ source: t.source });
15144
+ return this._applyFrameSize({
15145
+ session: t,
15146
+ size: n
15147
+ }), this.getState();
15148
+ }
15132
15149
  apply() {
15133
15150
  let { _session: e } = this;
15134
15151
  if (!e) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anu3ev/fabric-image-editor",
3
- "version": "0.9.11",
3
+ "version": "0.9.13",
4
4
  "description": "TypeScript image editor library built on FabricJS, allowing you to create instances with an integrated montage area and providing an API to modify and manage state.",
5
5
  "module": "dist/main.js",
6
6
  "files": [