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