react-design-editor 0.0.51 → 0.0.54

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/lib/Canvas.js CHANGED
@@ -72,7 +72,7 @@ class InternalCanvas extends react_1.Component {
72
72
  const mergedCanvasOption = Object.assign({}, constants_1.defaults.canvasOption, canvasOption, {
73
73
  width,
74
74
  height,
75
- selection: (typeof canvasOption.selection !== 'undefined' && canvasOption.selection) || editable,
75
+ selection: (typeof canvasOption?.selection !== 'undefined' && canvasOption?.selection) || editable,
76
76
  });
77
77
  this.canvas = new fabric_1.fabric.Canvas(`canvas_${id}`, mergedCanvasOption);
78
78
  this.canvas.setBackgroundColor(mergedCanvasOption.backgroundColor, this.canvas.renderAll.bind(this.canvas));
@@ -283,10 +283,10 @@ class EventHandler {
283
283
  const delta = event.e.deltaY;
284
284
  let zoomRatio = this.handler.canvas.getZoom();
285
285
  if (delta > 0) {
286
- zoomRatio -= 0.05;
286
+ zoomRatio -= this.handler.zoomStep;
287
287
  }
288
288
  else {
289
- zoomRatio += 0.05;
289
+ zoomRatio += this.handler.zoomStep;
290
290
  }
291
291
  this.handler.zoomHandler.zoomToPoint(new fabric_1.fabric.Point(this.handler.canvas.getWidth() / 2, this.handler.canvas.getHeight() / 2), zoomRatio);
292
292
  event.e.preventDefault();
@@ -619,6 +619,7 @@ class EventHandler {
619
619
  const createdObj = this.handler.add(obj, false, true);
620
620
  this.handler.canvas.setActiveObject(createdObj);
621
621
  this.handler.canvas.requestRenderAll();
622
+ this.handler.onAdd?.(createdObj);
622
623
  }
623
624
  else {
624
625
  const nodes = [];
@@ -649,6 +650,7 @@ class EventHandler {
649
650
  });
650
651
  this.handler.canvas.setActiveObject(activeSelection);
651
652
  this.handler.canvas.requestRenderAll();
653
+ this.handler.onAdd?.(activeSelection);
652
654
  }
653
655
  if (!this.handler.transactionHandler.active) {
654
656
  this.handler.transactionHandler.save('paste');
@@ -104,6 +104,11 @@ export interface HandlerOption {
104
104
  * @type {number}
105
105
  */
106
106
  maxZoom?: number;
107
+ /**
108
+ * Zoom ratio step
109
+ * @type {number}
110
+ */
111
+ zoomStep?: number;
107
112
  /**
108
113
  * Workarea option
109
114
  * @type {WorkareaOption}
@@ -179,6 +184,7 @@ declare class Handler implements HandlerOptions {
179
184
  interactionMode: InteractionMode;
180
185
  minZoom: number;
181
186
  maxZoom: number;
187
+ zoomStep: number;
182
188
  propertiesToInclude?: string[];
183
189
  workareaOption?: WorkareaOption;
184
190
  canvasOption?: CanvasOption;
@@ -17,6 +17,7 @@ const constants_1 = require("../constants");
17
17
  */
18
18
  class Handler {
19
19
  constructor(options) {
20
+ this.zoomStep = 0.05;
20
21
  this.propertiesToInclude = constants_1.defaults.propertiesToInclude;
21
22
  this.workareaOption = constants_1.defaults.workareaOption;
22
23
  this.canvasOption = constants_1.defaults.canvasOption;
@@ -43,6 +44,7 @@ class Handler {
43
44
  this.interactionMode = options.interactionMode;
44
45
  this.minZoom = options.minZoom;
45
46
  this.maxZoom = options.maxZoom;
47
+ this.zoomStep = options.zoomStep || 0.05;
46
48
  this.zoomEnabled = options.zoomEnabled;
47
49
  this.width = options.width;
48
50
  this.height = options.height;
@@ -88,7 +90,7 @@ class Handler {
88
90
  this.animationHandler = new _1.AnimationHandler(this);
89
91
  this.contextmenuHandler = new _1.ContextmenuHandler(this);
90
92
  this.tooltipHandler = new _1.TooltipHandler(this);
91
- this.zoomHandler = new _1.ZoomHandler(this);
93
+ this.zoomHandler = new _1.ZoomHandler(this, this.zoomStep);
92
94
  this.interactionHandler = new _1.InteractionHandler(this);
93
95
  this.transactionHandler = new _1.TransactionHandler(this);
94
96
  this.gridHandler = new _1.GridHandler(this);
@@ -1,9 +1,10 @@
1
1
  import { fabric } from 'fabric';
2
- import Handler from './Handler';
3
2
  import { FabricObject } from '../utils';
3
+ import Handler from './Handler';
4
4
  declare class ZoomHandler {
5
5
  handler?: Handler;
6
- constructor(handler: Handler);
6
+ private _zoomStep?;
7
+ constructor(handler: Handler, zoomStep?: number);
7
8
  /**
8
9
  * Zoom to point
9
10
  *
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const fabric_1 = require("fabric");
4
4
  class ZoomHandler {
5
- constructor(handler) {
5
+ constructor(handler, zoomStep = 0.05) {
6
6
  /**
7
7
  * Zoom to point
8
8
  *
@@ -74,7 +74,7 @@ class ZoomHandler {
74
74
  */
75
75
  this.zoomIn = () => {
76
76
  let zoomRatio = this.handler.canvas.getZoom();
77
- zoomRatio += 0.05;
77
+ zoomRatio += this._zoomStep;
78
78
  const center = this.handler.canvas.getCenter();
79
79
  this.zoomToPoint(new fabric_1.fabric.Point(center.left, center.top), zoomRatio);
80
80
  };
@@ -84,7 +84,7 @@ class ZoomHandler {
84
84
  */
85
85
  this.zoomOut = () => {
86
86
  let zoomRatio = this.handler.canvas.getZoom();
87
- zoomRatio -= 0.05;
87
+ zoomRatio -= this._zoomStep;
88
88
  const center = this.handler.canvas.getCenter();
89
89
  this.zoomToPoint(new fabric_1.fabric.Point(center.left, center.top), zoomRatio);
90
90
  };
@@ -138,6 +138,7 @@ class ZoomHandler {
138
138
  this.zoomToCenterWithObject(activeObject, zoomFit);
139
139
  };
140
140
  this.handler = handler;
141
+ this._zoomStep = zoomStep;
141
142
  }
142
143
  }
143
144
  exports.default = ZoomHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-design-editor",
3
- "version": "0.0.51",
3
+ "version": "0.0.54",
4
4
  "description": "Design Editor Tools with React.js + ant.design + fabric.js",
5
5
  "main": "dist/react-design-editor.min.js",
6
6
  "typings": "lib/index.d.ts",