xctc-utils 1.6.67 → 1.6.69

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.
@@ -1,39 +1,28 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
- var config_1 = require("../config");
15
- var utils_1 = require("../utils");
16
- var is_1 = require("../is");
17
- var has_1 = require("../is/has");
18
- var register_1 = require("../handle/register");
19
- var drop_1 = require("../event/drop");
20
- var mouse_down_1 = require("../event/mouse-down");
21
- var mouse_move_1 = require("../event/mouse-move");
22
- var mouse_up_1 = require("../event/mouse-up");
23
- var mouse_wheel_1 = require("../event/mouse-wheel");
24
- var index_1 = require("../handle/index");
25
- var drop_2 = require("../event/drop");
26
- var create_1 = require("../handle/create");
27
- var query_1 = require("../handle/query");
28
- var update_1 = require("../handle/update");
29
- var changed_1 = require("../event/changed");
30
- var index_2 = require("../event/index");
3
+ const config_1 = require("../config");
4
+ const utils_1 = require("../utils");
5
+ const is_1 = require("../is");
6
+ const has_1 = require("../is/has");
7
+ const register_1 = require("../handle/register");
8
+ const drop_1 = require("../event/drop");
9
+ const mouse_down_1 = require("../event/mouse-down");
10
+ const mouse_move_1 = require("../event/mouse-move");
11
+ const mouse_up_1 = require("../event/mouse-up");
12
+ const mouse_wheel_1 = require("../event/mouse-wheel");
13
+ const index_1 = require("../handle/index");
14
+ const drop_2 = require("../event/drop");
15
+ const create_1 = require("../handle/create");
16
+ const query_1 = require("../handle/query");
17
+ const update_1 = require("../handle/update");
18
+ const changed_1 = require("../event/changed");
19
+ const index_2 = require("../event/index");
31
20
  // 初始化画布创建时需要的参数-默认值
32
- var defaultConfig = __assign({}, config_1.configDefaultValue.canvasDefaultValue);
33
- var CanvasHooks = /** @class */ (function () {
34
- function CanvasHooks(config) {
21
+ const defaultConfig = { ...config_1.configDefaultValue.canvasDefaultValue };
22
+ class CanvasHooks {
23
+ constructor(config) {
35
24
  this.fabricSource = null;
36
- this.fabricUrlSource = "https://cdn.jsdelivr.net/npm/fabric";
25
+ this.fabricUrlSource = "https://cdn.bootcss.com/fabric.js/4.0.0-beta.5/fabric.min.js";
37
26
  this.canvasDataSource = null;
38
27
  this.zoomDataSource = "100";
39
28
  this.canvasBackgroundImageTarget = null;
@@ -63,24 +52,26 @@ var CanvasHooks = /** @class */ (function () {
63
52
  this.mouseWheelStatus = false;
64
53
  this.defaultCreateDataListStatus = false;
65
54
  this.mouseCanvasInRangeStatus = false;
55
+ const url = this.fabricUrlSource;
66
56
  if (config === null || config === void 0 ? void 0 : config.init) {
67
- // 是否默认加载画布
68
- this.createCanvasFn();
57
+ (0, utils_1.loadScript)(url, () => {
58
+ // 是否默认加载画布
59
+ this.createCanvasFn();
60
+ });
61
+ }
62
+ else {
63
+ (0, utils_1.loadScript)(url);
69
64
  }
70
65
  }
71
- Object.defineProperty(CanvasHooks.prototype, "canvasConfigData", {
72
- get: function () {
73
- return this.canvasConfig;
74
- },
75
- enumerable: false,
76
- configurable: true
77
- });
66
+ get canvasConfigData() {
67
+ return this.canvasConfig;
68
+ }
78
69
  // 创建画布
79
- CanvasHooks.prototype.createCanvasFn = function (config) {
70
+ createCanvasFn(config) {
80
71
  var _a;
81
- var _ = this;
72
+ const _ = this;
82
73
  _.renderCanvasStatus = 1;
83
- var canvasId = "";
74
+ let canvasId = "";
84
75
  // config 配置数据必须有画布ID参数
85
76
  if ((0, is_1.isObject)(config) && !(0, has_1.hasProperty)(config, "id")) {
86
77
  console.error("createCanvasFn函数接收的参数必须包含画布对应的id");
@@ -94,124 +85,135 @@ var CanvasHooks = /** @class */ (function () {
94
85
  }
95
86
  }
96
87
  // 初始化画布渲染时的配置参数
97
- var data = __assign(__assign({}, defaultConfig), _.canvasConfig);
88
+ const data = {
89
+ ...defaultConfig,
90
+ ..._.canvasConfig
91
+ };
98
92
  if (!(0, has_1.hasProperty)(_.canvasConfig, "width")) {
99
93
  data['width'] = _.elementSizeFn("canvasContainer").width;
100
94
  }
101
95
  if (!(0, has_1.hasProperty)(_.canvasConfig, "height")) {
102
96
  data['height'] = _.elementSizeFn("canvasContainer").height;
103
97
  }
104
- var imgUrl = (data === null || data === void 0 ? void 0 : data.backgroundImgUrl) || "";
105
- console.log("canvas--options", data);
98
+ const imgUrl = (data === null || data === void 0 ? void 0 : data.backgroundImgUrl) || "";
106
99
  canvasId = data.id;
107
- var url = _.fabricUrlSource;
100
+ let url = _.fabricUrlSource;
108
101
  if ((_a = _.canvasConfig) === null || _a === void 0 ? void 0 : _a.fabricUrlSource) {
109
102
  url = _.canvasConfig.fabricUrlSource;
110
103
  }
111
104
  if (config === null || config === void 0 ? void 0 : config.fabricUrlSource) {
112
105
  url = config.fabricUrlSource;
113
106
  }
114
- (0, utils_1.loadScript)(url, function () {
115
- var win = window;
116
- _.fabricSource = (win === null || win === void 0 ? void 0 : win.fabric) || {};
117
- if (imgUrl) {
118
- _.fabricSource.Image.fromURL(imgUrl, function (img) {
119
- _.renderCanvasStatus = 2;
120
- _.canvasBackgroundImageTarget = img;
121
- var _a = _.canvasConfig.actions, actions = _a === void 0 ? "" : _a;
122
- var zoomValue = (actions === null || actions === void 0 ? void 0 : actions.zoom) || 1;
123
- if (!_.canvasDataSource) {
124
- _.canvasDataSource = new _.fabricSource.Canvas(canvasId, __assign({}, data));
125
- if (zoomValue != 1) {
126
- _.canvasDataSource.setZoom(zoomValue);
127
- }
107
+ if (!(0, utils_1.isScriptLoaded)(url)) {
108
+ (0, utils_1.loadScript)(url, () => {
109
+ _.initCanvasDataFn(imgUrl, canvasId, data);
110
+ });
111
+ }
112
+ else {
113
+ _.initCanvasDataFn(imgUrl, canvasId, data);
114
+ }
115
+ }
116
+ initCanvasDataFn(imgUrl, canvasId, data) {
117
+ const _ = this;
118
+ const win = window;
119
+ _.fabricSource = (win === null || win === void 0 ? void 0 : win.fabric) || {};
120
+ if (imgUrl) {
121
+ _.fabricSource.Image.fromURL(imgUrl, function (img) {
122
+ _.renderCanvasStatus = 2;
123
+ _.canvasBackgroundImageTarget = img;
124
+ const { actions = "" } = _.canvasConfig;
125
+ const zoomValue = (actions === null || actions === void 0 ? void 0 : actions.zoom) || 1;
126
+ if (!_.canvasDataSource) {
127
+ _.canvasDataSource = new _.fabricSource.Canvas(canvasId, { ...data });
128
+ if (zoomValue != 1) {
129
+ _.canvasDataSource.setZoom(zoomValue);
128
130
  }
129
- var canvasWidth = _.canvasDataSource.getWidth();
130
- var canvasHeight = _.canvasDataSource.getHeight();
131
- var imgWidth = img.width;
132
- var imgHeight = img.height;
133
- var scaleX = 1;
134
- var scaleY = 1;
135
- if (canvasWidth && canvasHeight && imgWidth && imgHeight) {
136
- var imageAspectRatio = imgWidth / imgHeight;
137
- var canvasAspectRatio = canvasWidth / canvasHeight;
138
- if (imageAspectRatio > canvasAspectRatio) {
139
- // 图片更宽,基于高度缩放
140
- scaleY = canvasHeight / imgHeight;
141
- scaleX = scaleY * imageAspectRatio;
142
- }
143
- else {
144
- // 图片更高或宽高比相同,基于宽度缩放
145
- scaleX = canvasWidth / imgWidth;
146
- scaleY = scaleX / imageAspectRatio;
147
- }
131
+ }
132
+ const canvasWidth = _.canvasDataSource.getWidth();
133
+ const canvasHeight = _.canvasDataSource.getHeight();
134
+ const imgWidth = img.width;
135
+ const imgHeight = img.height;
136
+ let scaleX = 1;
137
+ let scaleY = 1;
138
+ if (canvasWidth && canvasHeight && imgWidth && imgHeight) {
139
+ let imageAspectRatio = imgWidth / imgHeight;
140
+ let canvasAspectRatio = canvasWidth / canvasHeight;
141
+ if (imageAspectRatio > canvasAspectRatio) {
142
+ // 图片更宽,基于高度缩放
143
+ scaleY = canvasHeight / imgHeight;
144
+ scaleX = scaleY * imageAspectRatio;
145
+ }
146
+ else {
147
+ // 图片更高或宽高比相同,基于宽度缩放
148
+ scaleX = canvasWidth / imgWidth;
149
+ scaleY = scaleX / imageAspectRatio;
148
150
  }
149
- console.log("原始比例:", { scaleX: scaleX, scaleY: scaleY, width: imgWidth, height: imgHeight });
150
- _.canvasDataSource.setBackgroundImage(img, _.canvasDataSource.renderAll.bind(_.canvasDataSource), {
151
- originX: 'left',
152
- originY: 'top',
153
- left: 0,
154
- top: 0,
155
- // scaleX: scaleX,
156
- // scaleY: scaleY,
157
- width: imgWidth,
158
- height: imgHeight,
159
- });
160
- _.renderCanvasStatus = 3;
161
- _.registerAllEventHandleFn();
162
- _.canvasDataSource.renderAll();
163
- callBack(_.canvasDataSource);
164
- });
165
- }
166
- else {
167
- if (!_.canvasDataSource) {
168
- _.canvasDataSource = new _.fabricSource.Canvas(canvasId, __assign({}, data));
169
- _.renderCanvasStatus = 3;
170
- _.registerAllEventHandleFn();
171
- _.canvasDataSource.renderAll();
172
- callBack(_.canvasDataSource);
173
151
  }
152
+ console.log("原始比例:", { scaleX: scaleX, scaleY: scaleY, width: imgWidth, height: imgHeight });
153
+ _.canvasDataSource.setBackgroundImage(img, _.canvasDataSource.renderAll.bind(_.canvasDataSource), {
154
+ originX: 'left',
155
+ originY: 'top',
156
+ left: 0,
157
+ top: 0,
158
+ // scaleX: scaleX,
159
+ // scaleY: scaleY,
160
+ width: imgWidth,
161
+ height: imgHeight,
162
+ });
163
+ _.renderCanvasStatus = 3;
164
+ _.registerAllEventHandleFn();
165
+ _.canvasDataSource.renderAll();
166
+ callBack(_.canvasDataSource);
167
+ });
168
+ }
169
+ else {
170
+ if (!_.canvasDataSource) {
171
+ _.canvasDataSource = new _.fabricSource.Canvas(canvasId, { ...data });
172
+ _.renderCanvasStatus = 3;
173
+ _.registerAllEventHandleFn();
174
+ _.canvasDataSource.renderAll();
175
+ callBack(_.canvasDataSource);
174
176
  }
175
- // 如果配置里面有回调函数,则将当前画布数据对象返回
176
- function callBack(data) {
177
- var _a;
178
- var cb = ((_a = _.canvasConfig) === null || _a === void 0 ? void 0 : _a.cb) || "";
179
- // 获取DOM元素
180
- var targetElement = (0, utils_1.getDomFn)("canvasContainer");
181
- // 添加事件监听器
182
- document.addEventListener('mousemove', (0, index_2.checkMouseInElement)(targetElement));
183
- if (cb instanceof Function) {
184
- cb(data);
185
- }
177
+ }
178
+ // 如果配置里面有回调函数,则将当前画布数据对象返回
179
+ function callBack(data) {
180
+ var _a;
181
+ const cb = ((_a = _.canvasConfig) === null || _a === void 0 ? void 0 : _a.cb) || "";
182
+ // 获取DOM元素
183
+ const targetElement = (0, utils_1.getDomFn)("canvasContainer");
184
+ // 添加事件监听器
185
+ document.addEventListener('mousemove', (0, index_2.checkMouseInElement)(targetElement));
186
+ if (cb instanceof Function) {
187
+ cb(data);
186
188
  }
187
- });
188
- };
189
+ }
190
+ }
189
191
  // 销毁画布
190
- CanvasHooks.prototype.disposeCanvasFn = function () {
192
+ disposeCanvasFn() {
191
193
  var _a, _b;
192
194
  if (this.canvasDataSource) {
193
- var el = (_a = this.canvasDataSource) === null || _a === void 0 ? void 0 : _a.getElement();
195
+ const el = (_a = this.canvasDataSource) === null || _a === void 0 ? void 0 : _a.getElement();
194
196
  (_b = this.canvasDataSource) === null || _b === void 0 ? void 0 : _b.dispose();
195
197
  el === null || el === void 0 ? void 0 : el.remove(); // 删除canvasDataSource元素
196
198
  this.canvasDataSource = null;
197
199
  }
198
- };
200
+ }
199
201
  // 关于画布相关配置数据
200
- CanvasHooks.prototype.canvasConfigDataFn = function (config) {
202
+ canvasConfigDataFn(config) {
201
203
  /**
202
204
  * rightButtonsDataSource 画布右键菜单列表数据
203
205
  */
204
206
  this.canvasHandleConfig = config || {};
205
- };
207
+ }
206
208
  // 注册回调事件--页面生成画布实例的时候,调用该函数
207
- CanvasHooks.prototype.registerCallBackEventFn = function (config) {
208
- var _ = this;
209
- var boundFunction = register_1.RegisterCanvasEventFn.bind(_, config);
209
+ registerCallBackEventFn(config) {
210
+ const _ = this;
211
+ const boundFunction = register_1.RegisterCanvasEventFn.bind(_, config);
210
212
  boundFunction();
211
- };
213
+ }
212
214
  // 执行注册事件
213
- CanvasHooks.prototype.registerAllEventHandleFn = function () {
214
- var _ = this;
215
+ registerAllEventHandleFn() {
216
+ const _ = this;
215
217
  _.dragLastPosDataSource = {
216
218
  open: false,
217
219
  lastPosX: null,
@@ -239,14 +241,14 @@ var CanvasHooks = /** @class */ (function () {
239
241
  _.registerMouseUpEventFn(options);
240
242
  });
241
243
  // 注册滚动事件
242
- _.canvasDataSource.on('mouse:wheel', function (options) {
244
+ _.canvasDataSource.on('mouse:wheel', (options) => {
243
245
  _.registerMouseWheelEventFn(options);
244
246
  });
245
- _.canvasDataSource.on('drop', function (options) {
247
+ _.canvasDataSource.on('drop', (options) => {
246
248
  _.registerMouseDropEventFn(options);
247
249
  });
248
250
  //监听画布缩放状态
249
- _.canvasDataSource.on('zoom:changed', function (options) {
251
+ _.canvasDataSource.on('zoom:changed', (options) => {
250
252
  _.registerCanvasZoomChangeEventFn(options);
251
253
  });
252
254
  _.canvasDataSource.on('contextmenu', function (options) {
@@ -258,206 +260,205 @@ var CanvasHooks = /** @class */ (function () {
258
260
  document.body.addEventListener('contextmenu', function (event) {
259
261
  event === null || event === void 0 ? void 0 : event.preventDefault();
260
262
  });
261
- };
263
+ }
262
264
  // 注册画布发生缩放监听事件
263
- CanvasHooks.prototype.registerCanvasZoomChangeEventFn = function () {
264
- var _ = this;
265
- var boundFunction = register_1.RegisterCanvasZoomChangeEventFn.bind(_);
265
+ registerCanvasZoomChangeEventFn() {
266
+ const _ = this;
267
+ const boundFunction = register_1.RegisterCanvasZoomChangeEventFn.bind(_);
266
268
  boundFunction();
267
- };
269
+ }
268
270
  // 拖拽事件注册
269
- CanvasHooks.prototype.registerMouseDropEventFn = function (options) {
270
- var _ = this;
271
- var boundFunction = drop_1.RegisterMouseDropEventFn.bind(_, options);
271
+ registerMouseDropEventFn(options) {
272
+ const _ = this;
273
+ const boundFunction = drop_1.RegisterMouseDropEventFn.bind(_, options);
272
274
  boundFunction();
273
- };
275
+ }
274
276
  // 鼠标进入画布
275
- CanvasHooks.prototype.registerMouseOverEventFn = function (options) {
276
- var _ = this;
277
+ registerMouseOverEventFn(options) {
278
+ const _ = this;
277
279
  _.mouseCanvasInRangeStatus = true;
278
- };
280
+ }
279
281
  // 鼠标移出画布
280
- CanvasHooks.prototype.registerMouseOutEventFn = function (options) {
282
+ registerMouseOutEventFn(options) {
281
283
  // console.log("registerMouseOutEventFn");
282
- var _ = this;
284
+ const _ = this;
283
285
  _.mouseCanvasInRangeStatus = false;
284
- };
286
+ }
285
287
  // 注册鼠标按下事件
286
- CanvasHooks.prototype.registerMouseDownEventFn = function (options) {
287
- var _ = this;
288
- var boundFunction = mouse_down_1.RegisterMouseDownEventFn.bind(_, options);
288
+ registerMouseDownEventFn(options) {
289
+ const _ = this;
290
+ const boundFunction = mouse_down_1.RegisterMouseDownEventFn.bind(_, options);
289
291
  boundFunction();
290
- };
292
+ }
291
293
  // 注册鼠标移动事件
292
- CanvasHooks.prototype.registerMouseMoveEventFn = function (options) {
293
- var _ = this;
294
- var boundFunction = mouse_move_1.RegisterMouseMoveEventFn.bind(_, options);
294
+ registerMouseMoveEventFn(options) {
295
+ const _ = this;
296
+ const boundFunction = mouse_move_1.RegisterMouseMoveEventFn.bind(_, options);
295
297
  boundFunction();
296
- };
298
+ }
297
299
  // 注册鼠标抬起事件
298
- CanvasHooks.prototype.registerMouseUpEventFn = function (options) {
299
- var _ = this;
300
- var boundFunction = mouse_up_1.RegisterMouseUpEventFn.bind(_, options);
300
+ registerMouseUpEventFn(options) {
301
+ const _ = this;
302
+ const boundFunction = mouse_up_1.RegisterMouseUpEventFn.bind(_, options);
301
303
  boundFunction();
302
- };
304
+ }
303
305
  // 注册鼠标滚动事件
304
- CanvasHooks.prototype.registerMouseWheelEventFn = function (options) {
305
- var _ = this;
306
- var boundFunction = mouse_wheel_1.RegisterMouseWheelEventFn.bind(_, options);
306
+ registerMouseWheelEventFn(options) {
307
+ const _ = this;
308
+ const boundFunction = mouse_wheel_1.RegisterMouseWheelEventFn.bind(_, options);
307
309
  boundFunction();
308
- };
310
+ }
309
311
  // 滚动事件操作--画布缩放监听
310
- CanvasHooks.prototype.registerZoomHandleFn = function (options) {
311
- var _ = this;
312
- var boundFunction = index_1.RegisterZoomHandleFn.bind(_, options);
312
+ registerZoomHandleFn(options) {
313
+ const _ = this;
314
+ const boundFunction = index_1.RegisterZoomHandleFn.bind(_, options);
313
315
  boundFunction();
314
- };
316
+ }
315
317
  // 页面上发生拖拽时,拖拽完成后的数据存储函数
316
- CanvasHooks.prototype.dragCreateElementDataFn = function (data) {
317
- var _ = this;
318
- var boundFunction = drop_2.DragCreateElementDataFn.bind(_, data);
318
+ dragCreateElementDataFn(data) {
319
+ const _ = this;
320
+ const boundFunction = drop_2.DragCreateElementDataFn.bind(_, data);
319
321
  boundFunction();
320
- };
322
+ }
321
323
  // 拖拽进入画布元素创建
322
- CanvasHooks.prototype.createDragElementFn = function () {
323
- var _ = this;
324
- var boundFunction = create_1.CreateDragElementFn.bind(_);
324
+ createDragElementFn() {
325
+ const _ = this;
326
+ const boundFunction = create_1.CreateDragElementFn.bind(_);
325
327
  boundFunction();
326
- };
328
+ }
327
329
  // 默认加载一个列表数据到画布
328
- CanvasHooks.prototype.initElement2CanvasFn = function (list) {
329
- var _ = this;
330
- var boundFunction = create_1.InitElement2CanvasFn.bind(_, list);
330
+ initElement2CanvasFn(list) {
331
+ const _ = this;
332
+ const boundFunction = create_1.InitElement2CanvasFn.bind(_, list);
331
333
  boundFunction();
332
- };
333
- CanvasHooks.prototype.getCreateElementStatusFn = function (index) {
334
- var _ = this;
335
- var list = _.defaultCreateDataList;
334
+ }
335
+ getCreateElementStatusFn(index) {
336
+ const _ = this;
337
+ const list = _.defaultCreateDataList;
336
338
  if (index >= 0 && (list === null || list === void 0 ? void 0 : list.length)) {
337
339
  if (index == list.length - 1) {
338
- setTimeout(function () {
340
+ setTimeout(() => {
339
341
  _.resetElementSizeFn();
340
342
  }, 100);
341
343
  }
342
344
  }
343
- };
345
+ }
344
346
  // 创建SVG到画布
345
- CanvasHooks.prototype.createCanvasSvgElementFn = function (item, index) {
346
- var _ = this;
347
- var boundFunction = create_1.CreateCanvasSvgElementFn.bind(_, item, index);
347
+ createCanvasSvgElementFn(item, index) {
348
+ const _ = this;
349
+ const boundFunction = create_1.CreateCanvasSvgElementFn.bind(_, item, index);
348
350
  boundFunction();
349
- };
351
+ }
350
352
  // 创建图片到画布
351
- CanvasHooks.prototype.createCanvasImageElementFn = function (item, index) {
352
- var _ = this;
353
- var boundFunction = create_1.CreateCanvasImageElementFn.bind(_, item, index);
353
+ createCanvasImageElementFn(item, index) {
354
+ const _ = this;
355
+ const boundFunction = create_1.CreateCanvasImageElementFn.bind(_, item, index);
354
356
  boundFunction();
355
- };
357
+ }
356
358
  // 获取到所有被框选的对象
357
- CanvasHooks.prototype.getSelectionAllElementsFn = function () {
358
- var _ = this;
359
- var data = query_1.QuerySelectionAllElementsFn.bind(_);
359
+ getSelectionAllElementsFn() {
360
+ const _ = this;
361
+ const data = query_1.QuerySelectionAllElementsFn.bind(_);
360
362
  return data();
361
- };
363
+ }
362
364
  // 获取到指定选择框内被框选的对象
363
- CanvasHooks.prototype.getSelectionElementsFn = function (item) {
364
- var _ = this;
365
- var data = query_1.QuerySelectionElementsFn.bind(_, item);
365
+ getSelectionElementsFn(item) {
366
+ const _ = this;
367
+ const data = query_1.QuerySelectionElementsFn.bind(_, item);
366
368
  return data();
367
- };
369
+ }
368
370
  // 创建自定义图像
369
- CanvasHooks.prototype.createSelectionRectFn = function () {
370
- var _ = this;
371
- var boundFunction = create_1.CreateSelectionRectFn.bind(_);
371
+ createSelectionRectFn() {
372
+ const _ = this;
373
+ const boundFunction = create_1.CreateSelectionRectFn.bind(_);
372
374
  boundFunction();
373
- };
375
+ }
374
376
  // 创建全选框
375
- CanvasHooks.prototype.createAllSelectionRectFn = function () {
376
- var _ = this;
377
- var boundFunction = create_1.CreateAllSelectionRectFn.bind(_);
377
+ createAllSelectionRectFn() {
378
+ const _ = this;
379
+ const boundFunction = create_1.CreateAllSelectionRectFn.bind(_);
378
380
  boundFunction();
379
- };
381
+ }
380
382
  // 删除全选对象选择框
381
- CanvasHooks.prototype.removeAllSelectionRectFn = function () {
382
- var _ = this;
383
- var boundFunction = update_1.RemoveAllSelectionRectFn.bind(_);
383
+ removeAllSelectionRectFn() {
384
+ const _ = this;
385
+ const boundFunction = update_1.RemoveAllSelectionRectFn.bind(_);
384
386
  boundFunction();
385
- };
387
+ }
386
388
  // 自定义选择框绘制数据更新
387
- CanvasHooks.prototype.updateSelectionRectFn = function (options) {
388
- var _ = this;
389
- var boundFunction = update_1.UpdateSelectionRectFn.bind(_, options);
389
+ updateSelectionRectFn(options) {
390
+ const _ = this;
391
+ const boundFunction = update_1.UpdateSelectionRectFn.bind(_, options);
390
392
  boundFunction();
391
- };
393
+ }
392
394
  // 自定义选择框绘制完成
393
- CanvasHooks.prototype.createSelectionRectFinishFn = function () {
394
- var _ = this;
395
- var boundFunction = update_1.CreateSelectionRectFinishFn.bind(_);
395
+ createSelectionRectFinishFn() {
396
+ const _ = this;
397
+ const boundFunction = update_1.CreateSelectionRectFinishFn.bind(_);
396
398
  boundFunction();
397
- };
398
- CanvasHooks.prototype.init = function () {
399
- var _ = this;
400
- };
399
+ }
400
+ init() {
401
+ const _ = this;
402
+ }
401
403
  // 获取画布容器的宽高
402
- CanvasHooks.prototype.elementSizeFn = function (id) {
403
- var _ = this;
404
- var data = query_1.QueryElementSizeFn.bind(_, id);
405
- var result = data() || {};
404
+ elementSizeFn(id) {
405
+ const _ = this;
406
+ const data = query_1.QueryElementSizeFn.bind(_, id);
407
+ const result = data() || {};
406
408
  console.log("elementSizeFn--result==", result);
407
409
  return result;
408
- };
410
+ }
409
411
  // 右键菜单管理
410
- CanvasHooks.prototype.createRightClickMenuFn = function (options) {
411
- var _ = this;
412
- var boundFunction = create_1.CreateRightClickMenuFn.bind(_, options);
412
+ createRightClickMenuFn(options) {
413
+ const _ = this;
414
+ const boundFunction = create_1.CreateRightClickMenuFn.bind(_, options);
413
415
  boundFunction();
414
- };
415
- CanvasHooks.prototype.hiddenRightClickMenuFn = function () {
416
- var _ = this;
417
- var boundFunction = update_1.HiddenRightClickMenuFn.bind(_);
416
+ }
417
+ hiddenRightClickMenuFn() {
418
+ const _ = this;
419
+ const boundFunction = update_1.HiddenRightClickMenuFn.bind(_);
418
420
  boundFunction();
419
- };
421
+ }
420
422
  // 在画布上动态创建对象
421
- CanvasHooks.prototype.createElementFn = function (domVal, id, index) {
422
- var _ = this;
423
- var data = create_1.CreateElementFn.bind(_, domVal, id, index);
423
+ createElementFn(domVal, id, index) {
424
+ const _ = this;
425
+ const data = create_1.CreateElementFn.bind(_, domVal, id, index);
424
426
  return data();
425
- };
427
+ }
426
428
  // 执行返回上一步操作
427
- CanvasHooks.prototype.previousStepFn = function () {
428
- var _ = this;
429
- var boundFunction = changed_1.PreviousStepFn.bind(_);
429
+ previousStepFn() {
430
+ const _ = this;
431
+ const boundFunction = changed_1.PreviousStepFn.bind(_);
430
432
  boundFunction();
431
- };
433
+ }
432
434
  // 移除画布上指定对象
433
- CanvasHooks.prototype.removeElementFn = function (id) {
434
- var _ = this;
435
- var boundFunction = update_1.RemoveElementFn.bind(_, id);
435
+ removeElementFn(id) {
436
+ const _ = this;
437
+ const boundFunction = update_1.RemoveElementFn.bind(_, id);
436
438
  boundFunction();
437
- };
439
+ }
438
440
  // 清空画布上所有对象
439
- CanvasHooks.prototype.removeAllElementFn = function () {
440
- var _ = this;
441
- var boundFunction = update_1.RemoveAllElementFn.bind(_);
441
+ removeAllElementFn() {
442
+ const _ = this;
443
+ const boundFunction = update_1.RemoveAllElementFn.bind(_);
442
444
  boundFunction();
443
- };
445
+ }
444
446
  // 对于画布出现缩放的情况,加载进入的数据会产生偏移处理
445
447
  // 问题未解决,备注
446
- CanvasHooks.prototype.resetElementSizeFn = function () {
447
- var _ = this;
448
- var boundFunction = changed_1.ResetElementSizeFn.bind(_);
448
+ resetElementSizeFn() {
449
+ const _ = this;
450
+ const boundFunction = changed_1.ResetElementSizeFn.bind(_);
449
451
  boundFunction();
450
- };
451
- CanvasHooks.prototype.setCanvasBaseConfigFn = function (zoom) {
452
- var _ = this;
453
- var boundFunction = index_1.SetCanvasBaseConfigFn.bind(_, zoom);
452
+ }
453
+ setCanvasBaseConfigFn(zoom) {
454
+ const _ = this;
455
+ const boundFunction = index_1.SetCanvasBaseConfigFn.bind(_, zoom);
454
456
  boundFunction();
455
- };
456
- CanvasHooks.prototype.getCanvasActionDataFn = function () {
457
- var _ = this;
458
- var data = query_1.QueryCanvasActionDataFn.bind(_);
457
+ }
458
+ getCanvasActionDataFn() {
459
+ const _ = this;
460
+ const data = query_1.QueryCanvasActionDataFn.bind(_);
459
461
  return data();
460
- };
461
- return CanvasHooks;
462
- }());
462
+ }
463
+ }
463
464
  exports.default = CanvasHooks;