@leafer-ui/core 1.0.0-beta.9 → 1.0.0-rc.11
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/core.cjs +1343 -0
- package/lib/core.esm.js +1328 -0
- package/lib/core.esm.min.js +1 -0
- package/lib/core.min.cjs +1 -0
- package/package.json +20 -10
- package/src/index.ts +6 -4
- package/types/index.d.ts +6 -0
package/lib/core.cjs
ADDED
|
@@ -0,0 +1,1343 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var draw$1 = require('@leafer-ui/draw');
|
|
4
|
+
var core = require('@leafer/core');
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation.
|
|
8
|
+
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
+
purpose with or without fee is hereby granted.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function __decorate(decorators, target, key, desc) {
|
|
24
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
26
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
27
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
31
|
+
var e = new Error(message);
|
|
32
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.App = class App extends draw$1.Leafer {
|
|
36
|
+
get __tag() { return 'App'; }
|
|
37
|
+
get isApp() { return true; }
|
|
38
|
+
constructor(userConfig, data) {
|
|
39
|
+
super(userConfig, data);
|
|
40
|
+
}
|
|
41
|
+
init(userConfig, parentApp) {
|
|
42
|
+
super.init(userConfig, parentApp);
|
|
43
|
+
if (userConfig) {
|
|
44
|
+
const { ground, tree, sky, editor } = userConfig;
|
|
45
|
+
if (ground)
|
|
46
|
+
this.ground = this.addLeafer(ground);
|
|
47
|
+
if (tree || editor)
|
|
48
|
+
this.tree = this.addLeafer(tree);
|
|
49
|
+
if (sky || editor)
|
|
50
|
+
this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
|
|
51
|
+
if (editor) {
|
|
52
|
+
this.editor = core.Creator.editor(editor);
|
|
53
|
+
this.sky.add(this.editor);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
__setApp() {
|
|
58
|
+
const { canvas } = this;
|
|
59
|
+
const { realCanvas, view } = this.config;
|
|
60
|
+
if (realCanvas || view === this.canvas.view || !canvas.parentView) {
|
|
61
|
+
this.realCanvas = true;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
canvas.unrealCanvas();
|
|
65
|
+
}
|
|
66
|
+
this.leafer = this;
|
|
67
|
+
this.watcher.disable();
|
|
68
|
+
this.layouter.disable();
|
|
69
|
+
this.__eventIds.push(this.on_(core.PropertyEvent.CHANGE, this.__onPropertyChange, this));
|
|
70
|
+
}
|
|
71
|
+
start() {
|
|
72
|
+
super.start();
|
|
73
|
+
this.children.forEach(leafer => leafer.start());
|
|
74
|
+
}
|
|
75
|
+
stop() {
|
|
76
|
+
this.children.forEach(leafer => leafer.stop());
|
|
77
|
+
super.stop();
|
|
78
|
+
}
|
|
79
|
+
unlockLayout() {
|
|
80
|
+
super.unlockLayout();
|
|
81
|
+
this.children.forEach(leafer => leafer.unlockLayout());
|
|
82
|
+
}
|
|
83
|
+
lockLayout() {
|
|
84
|
+
super.lockLayout();
|
|
85
|
+
this.children.forEach(leafer => leafer.lockLayout());
|
|
86
|
+
}
|
|
87
|
+
forceRender(bounds) {
|
|
88
|
+
this.children.forEach(leafer => leafer.forceRender(bounds));
|
|
89
|
+
}
|
|
90
|
+
addLeafer(merge) {
|
|
91
|
+
const leafer = new draw$1.Leafer(merge);
|
|
92
|
+
this.add(leafer);
|
|
93
|
+
return leafer;
|
|
94
|
+
}
|
|
95
|
+
add(leafer) {
|
|
96
|
+
if (!leafer.view) {
|
|
97
|
+
if (this.realCanvas && !this.canvas.bounds) {
|
|
98
|
+
setTimeout(() => this.add(leafer), 10);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
leafer.init(this.__getChildConfig(leafer.userConfig), this);
|
|
102
|
+
}
|
|
103
|
+
super.add(leafer);
|
|
104
|
+
this.__listenChildEvents(leafer);
|
|
105
|
+
}
|
|
106
|
+
__onPropertyChange() {
|
|
107
|
+
if (core.Debug.showHitView)
|
|
108
|
+
this.children.forEach(leafer => leafer.forceUpdate('surface'));
|
|
109
|
+
}
|
|
110
|
+
__onCreated() {
|
|
111
|
+
this.created = this.children.every(child => child.created);
|
|
112
|
+
}
|
|
113
|
+
__onReady() {
|
|
114
|
+
if (this.children.every(child => child.ready))
|
|
115
|
+
super.__onReady();
|
|
116
|
+
}
|
|
117
|
+
__onViewReady() {
|
|
118
|
+
if (this.children.every(child => child.viewReady))
|
|
119
|
+
super.__onViewReady();
|
|
120
|
+
}
|
|
121
|
+
__onChildRenderEnd(e) {
|
|
122
|
+
this.renderer.addBlock(e.renderBounds);
|
|
123
|
+
if (this.viewReady)
|
|
124
|
+
this.renderer.update();
|
|
125
|
+
}
|
|
126
|
+
__render(canvas, _options) {
|
|
127
|
+
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
128
|
+
}
|
|
129
|
+
__onResize(event) {
|
|
130
|
+
this.children.forEach(leafer => leafer.resize(event));
|
|
131
|
+
super.__onResize(event);
|
|
132
|
+
}
|
|
133
|
+
__checkUpdateLayout() {
|
|
134
|
+
this.children.forEach(leafer => leafer.__layout.update());
|
|
135
|
+
}
|
|
136
|
+
__getChildConfig(userConfig) {
|
|
137
|
+
let config = Object.assign({}, this.config);
|
|
138
|
+
config.hittable = config.realCanvas = undefined;
|
|
139
|
+
if (userConfig)
|
|
140
|
+
core.DataHelper.assign(config, userConfig);
|
|
141
|
+
if (this.autoLayout)
|
|
142
|
+
core.DataHelper.copyAttrs(config, this, core.canvasSizeAttrs);
|
|
143
|
+
config.view = this.realCanvas ? undefined : this.view;
|
|
144
|
+
config.fill = undefined;
|
|
145
|
+
return config;
|
|
146
|
+
}
|
|
147
|
+
__listenChildEvents(leafer) {
|
|
148
|
+
leafer.once(core.LayoutEvent.END, () => this.__onReady());
|
|
149
|
+
leafer.once(core.RenderEvent.START, () => this.__onCreated());
|
|
150
|
+
leafer.once(core.RenderEvent.END, () => this.__onViewReady());
|
|
151
|
+
if (this.realCanvas)
|
|
152
|
+
this.__eventIds.push(leafer.on_(core.RenderEvent.END, this.__onChildRenderEnd, this));
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
exports.App = __decorate([
|
|
156
|
+
core.registerUI()
|
|
157
|
+
], exports.App);
|
|
158
|
+
|
|
159
|
+
function draw(leafer) {
|
|
160
|
+
const { config } = leafer;
|
|
161
|
+
config.move.dragOut = false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const downKeyMap = {};
|
|
165
|
+
const Keyboard = {
|
|
166
|
+
isHoldSpaceKey() {
|
|
167
|
+
return Keyboard.isHold('Space');
|
|
168
|
+
},
|
|
169
|
+
isHold(code) {
|
|
170
|
+
return downKeyMap[code];
|
|
171
|
+
},
|
|
172
|
+
setDownCode(code) {
|
|
173
|
+
if (!downKeyMap[code])
|
|
174
|
+
downKeyMap[code] = true;
|
|
175
|
+
},
|
|
176
|
+
setUpCode(code) {
|
|
177
|
+
downKeyMap[code] = false;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const PointerButton = {
|
|
182
|
+
LEFT: 1,
|
|
183
|
+
RIGHT: 2,
|
|
184
|
+
MIDDLE: 4,
|
|
185
|
+
defaultLeft(event) { if (!event.buttons)
|
|
186
|
+
event.buttons = 1; },
|
|
187
|
+
left(event) { return event.buttons === 1; },
|
|
188
|
+
right(event) { return event.buttons === 2; },
|
|
189
|
+
middle(event) { return event.buttons === 4; }
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
class UIEvent extends core.Event {
|
|
193
|
+
get spaceKey() { return Keyboard.isHoldSpaceKey(); }
|
|
194
|
+
get left() { return PointerButton.left(this); }
|
|
195
|
+
get right() { return PointerButton.right(this); }
|
|
196
|
+
get middle() { return PointerButton.middle(this); }
|
|
197
|
+
constructor(params) {
|
|
198
|
+
super(params.type);
|
|
199
|
+
this.bubbles = true;
|
|
200
|
+
Object.assign(this, params);
|
|
201
|
+
}
|
|
202
|
+
getPage() {
|
|
203
|
+
return this.current.getPagePoint(this);
|
|
204
|
+
}
|
|
205
|
+
getInner(relative) {
|
|
206
|
+
if (!relative)
|
|
207
|
+
relative = this.current;
|
|
208
|
+
return relative.getInnerPoint(this);
|
|
209
|
+
}
|
|
210
|
+
getLocal(relative) {
|
|
211
|
+
if (!relative)
|
|
212
|
+
relative = this.current;
|
|
213
|
+
return relative.getLocalPoint(this);
|
|
214
|
+
}
|
|
215
|
+
static changeName(oldName, newName) {
|
|
216
|
+
core.EventCreator.changeName(oldName, newName);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
exports.PointerEvent = class PointerEvent extends UIEvent {
|
|
221
|
+
};
|
|
222
|
+
exports.PointerEvent.POINTER = 'pointer';
|
|
223
|
+
exports.PointerEvent.BEFORE_DOWN = 'pointer.before_down';
|
|
224
|
+
exports.PointerEvent.BEFORE_MOVE = 'pointer.before_move';
|
|
225
|
+
exports.PointerEvent.BEFORE_UP = 'pointer.before_up';
|
|
226
|
+
exports.PointerEvent.DOWN = 'pointer.down';
|
|
227
|
+
exports.PointerEvent.MOVE = 'pointer.move';
|
|
228
|
+
exports.PointerEvent.UP = 'pointer.up';
|
|
229
|
+
exports.PointerEvent.OVER = 'pointer.over';
|
|
230
|
+
exports.PointerEvent.OUT = 'pointer.out';
|
|
231
|
+
exports.PointerEvent.ENTER = 'pointer.enter';
|
|
232
|
+
exports.PointerEvent.LEAVE = 'pointer.leave';
|
|
233
|
+
exports.PointerEvent.TAP = 'tap';
|
|
234
|
+
exports.PointerEvent.DOUBLE_TAP = 'double_tap';
|
|
235
|
+
exports.PointerEvent.CLICK = 'click';
|
|
236
|
+
exports.PointerEvent.DOUBLE_CLICK = 'double_click';
|
|
237
|
+
exports.PointerEvent.LONG_PRESS = 'long_press';
|
|
238
|
+
exports.PointerEvent.LONG_TAP = 'long_tap';
|
|
239
|
+
exports.PointerEvent.MENU = 'pointer.menu';
|
|
240
|
+
exports.PointerEvent.MENU_TAP = 'pointer.menu_tap';
|
|
241
|
+
exports.PointerEvent = __decorate([
|
|
242
|
+
core.registerUIEvent()
|
|
243
|
+
], exports.PointerEvent);
|
|
244
|
+
|
|
245
|
+
const move = {};
|
|
246
|
+
exports.DragEvent = class DragEvent extends exports.PointerEvent {
|
|
247
|
+
static setList(data) {
|
|
248
|
+
this.list = data instanceof core.LeafList ? data : new core.LeafList(data);
|
|
249
|
+
}
|
|
250
|
+
static setData(data) {
|
|
251
|
+
this.data = data;
|
|
252
|
+
}
|
|
253
|
+
getPageMove(total) {
|
|
254
|
+
this.assignMove(total);
|
|
255
|
+
return this.current.getPagePoint(move, null, true);
|
|
256
|
+
}
|
|
257
|
+
getInnerMove(relative, total) {
|
|
258
|
+
if (!relative)
|
|
259
|
+
relative = this.current;
|
|
260
|
+
this.assignMove(total);
|
|
261
|
+
return relative.getInnerPoint(move, null, true);
|
|
262
|
+
}
|
|
263
|
+
getLocalMove(relative, total) {
|
|
264
|
+
if (!relative)
|
|
265
|
+
relative = this.current;
|
|
266
|
+
this.assignMove(total);
|
|
267
|
+
return relative.getLocalPoint(move, null, true);
|
|
268
|
+
}
|
|
269
|
+
getPageTotal() {
|
|
270
|
+
return this.getPageMove(true);
|
|
271
|
+
}
|
|
272
|
+
getInnerTotal(relative) {
|
|
273
|
+
return this.getInnerMove(relative, true);
|
|
274
|
+
}
|
|
275
|
+
getLocalTotal(relative) {
|
|
276
|
+
return this.getLocalMove(relative, true);
|
|
277
|
+
}
|
|
278
|
+
assignMove(total) {
|
|
279
|
+
move.x = total ? this.totalX : this.moveX;
|
|
280
|
+
move.y = total ? this.totalY : this.moveY;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
exports.DragEvent.BEFORE_DRAG = 'drag.before_drag';
|
|
284
|
+
exports.DragEvent.START = 'drag.start';
|
|
285
|
+
exports.DragEvent.DRAG = 'drag';
|
|
286
|
+
exports.DragEvent.END = 'drag.end';
|
|
287
|
+
exports.DragEvent.OVER = 'drag.over';
|
|
288
|
+
exports.DragEvent.OUT = 'drag.out';
|
|
289
|
+
exports.DragEvent.ENTER = 'drag.enter';
|
|
290
|
+
exports.DragEvent.LEAVE = 'drag.leave';
|
|
291
|
+
exports.DragEvent = __decorate([
|
|
292
|
+
core.registerUIEvent()
|
|
293
|
+
], exports.DragEvent);
|
|
294
|
+
|
|
295
|
+
exports.DropEvent = class DropEvent extends exports.PointerEvent {
|
|
296
|
+
static setList(data) {
|
|
297
|
+
exports.DragEvent.setList(data);
|
|
298
|
+
}
|
|
299
|
+
static setData(data) {
|
|
300
|
+
exports.DragEvent.setData(data);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
exports.DropEvent.DROP = 'drop';
|
|
304
|
+
exports.DropEvent = __decorate([
|
|
305
|
+
core.registerUIEvent()
|
|
306
|
+
], exports.DropEvent);
|
|
307
|
+
|
|
308
|
+
exports.MoveEvent = class MoveEvent extends exports.DragEvent {
|
|
309
|
+
};
|
|
310
|
+
exports.MoveEvent.BEFORE_MOVE = 'move.before_move';
|
|
311
|
+
exports.MoveEvent.START = 'move.start';
|
|
312
|
+
exports.MoveEvent.MOVE = 'move';
|
|
313
|
+
exports.MoveEvent.END = 'move.end';
|
|
314
|
+
exports.MoveEvent = __decorate([
|
|
315
|
+
core.registerUIEvent()
|
|
316
|
+
], exports.MoveEvent);
|
|
317
|
+
|
|
318
|
+
exports.RotateEvent = class RotateEvent extends UIEvent {
|
|
319
|
+
};
|
|
320
|
+
exports.RotateEvent.BEFORE_ROTATE = 'rotate.before_rotate';
|
|
321
|
+
exports.RotateEvent.START = 'rotate.start';
|
|
322
|
+
exports.RotateEvent.ROTATE = 'rotate';
|
|
323
|
+
exports.RotateEvent.END = 'rotate.end';
|
|
324
|
+
exports.RotateEvent = __decorate([
|
|
325
|
+
core.registerUIEvent()
|
|
326
|
+
], exports.RotateEvent);
|
|
327
|
+
|
|
328
|
+
exports.SwipeEvent = class SwipeEvent extends exports.DragEvent {
|
|
329
|
+
};
|
|
330
|
+
exports.SwipeEvent.SWIPE = 'swipe';
|
|
331
|
+
exports.SwipeEvent.LEFT = 'swipe.left';
|
|
332
|
+
exports.SwipeEvent.RIGHT = 'swipe.right';
|
|
333
|
+
exports.SwipeEvent.UP = 'swipe.up';
|
|
334
|
+
exports.SwipeEvent.DOWN = 'swipe.down';
|
|
335
|
+
exports.SwipeEvent = __decorate([
|
|
336
|
+
core.registerUIEvent()
|
|
337
|
+
], exports.SwipeEvent);
|
|
338
|
+
|
|
339
|
+
exports.ZoomEvent = class ZoomEvent extends UIEvent {
|
|
340
|
+
};
|
|
341
|
+
exports.ZoomEvent.BEFORE_ZOOM = 'zoom.before_zoom';
|
|
342
|
+
exports.ZoomEvent.START = 'zoom.start';
|
|
343
|
+
exports.ZoomEvent.ZOOM = 'zoom';
|
|
344
|
+
exports.ZoomEvent.END = 'zoom.end';
|
|
345
|
+
exports.ZoomEvent = __decorate([
|
|
346
|
+
core.registerUIEvent()
|
|
347
|
+
], exports.ZoomEvent);
|
|
348
|
+
|
|
349
|
+
exports.KeyEvent = class KeyEvent extends UIEvent {
|
|
350
|
+
};
|
|
351
|
+
exports.KeyEvent.DOWN = 'key.down';
|
|
352
|
+
exports.KeyEvent.HOLD = 'key.hold';
|
|
353
|
+
exports.KeyEvent.UP = 'key.up';
|
|
354
|
+
exports.KeyEvent = __decorate([
|
|
355
|
+
core.registerUIEvent()
|
|
356
|
+
], exports.KeyEvent);
|
|
357
|
+
|
|
358
|
+
function design(leafer) {
|
|
359
|
+
if (leafer.isApp)
|
|
360
|
+
return;
|
|
361
|
+
leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => leafer.zoomLayer.move(e.moveX, e.moveY)), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
|
|
362
|
+
const { zoomLayer } = leafer;
|
|
363
|
+
const { scaleX } = zoomLayer.__, { min, max } = leafer.app.config.zoom;
|
|
364
|
+
let { scale } = e, absScale = Math.abs(scaleX * scale);
|
|
365
|
+
if (absScale < min)
|
|
366
|
+
scale = min / scaleX;
|
|
367
|
+
else if (absScale > max)
|
|
368
|
+
scale = max / scaleX;
|
|
369
|
+
if (scale !== 1) {
|
|
370
|
+
core.PointHelper.scaleOf(zoomLayer, e, scale);
|
|
371
|
+
zoomLayer.scale = scaleX * scale;
|
|
372
|
+
}
|
|
373
|
+
}));
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const debug$1 = core.Debug.get('LeaferTypeCreator');
|
|
377
|
+
const LeaferTypeCreator = {
|
|
378
|
+
list: {},
|
|
379
|
+
register(name, fn) {
|
|
380
|
+
if (list[name]) {
|
|
381
|
+
debug$1.repeat(name);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
list[name] = fn;
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
run(name, leafer) {
|
|
388
|
+
const fn = list[name];
|
|
389
|
+
if (fn) {
|
|
390
|
+
fn(leafer);
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
debug$1.error('no', name);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
const { list, register } = LeaferTypeCreator;
|
|
398
|
+
register('draw', draw);
|
|
399
|
+
register('design', design);
|
|
400
|
+
|
|
401
|
+
draw$1.Leafer.prototype.initType = function (type) {
|
|
402
|
+
LeaferTypeCreator.run(type, this);
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
class Transformer {
|
|
406
|
+
constructor(interaction) {
|
|
407
|
+
this.interaction = interaction;
|
|
408
|
+
}
|
|
409
|
+
move(data) {
|
|
410
|
+
const { interaction } = this;
|
|
411
|
+
if (!this.moveData) {
|
|
412
|
+
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
413
|
+
data.path = path;
|
|
414
|
+
this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
|
|
415
|
+
interaction.emit(exports.MoveEvent.START, this.moveData);
|
|
416
|
+
}
|
|
417
|
+
data.path = this.moveData.path;
|
|
418
|
+
interaction.emit(exports.MoveEvent.BEFORE_MOVE, data);
|
|
419
|
+
interaction.emit(exports.MoveEvent.MOVE, data);
|
|
420
|
+
this.transformEndWait();
|
|
421
|
+
}
|
|
422
|
+
zoom(data) {
|
|
423
|
+
const { interaction } = this;
|
|
424
|
+
if (!this.zoomData) {
|
|
425
|
+
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
426
|
+
data.path = path;
|
|
427
|
+
this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
|
|
428
|
+
interaction.emit(exports.ZoomEvent.START, this.zoomData);
|
|
429
|
+
}
|
|
430
|
+
data.path = this.zoomData.path;
|
|
431
|
+
interaction.emit(exports.ZoomEvent.BEFORE_ZOOM, data);
|
|
432
|
+
interaction.emit(exports.ZoomEvent.ZOOM, data);
|
|
433
|
+
this.transformEndWait();
|
|
434
|
+
}
|
|
435
|
+
rotate(data) {
|
|
436
|
+
const { interaction } = this;
|
|
437
|
+
if (!this.rotateData) {
|
|
438
|
+
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
439
|
+
data.path = path;
|
|
440
|
+
this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
|
|
441
|
+
interaction.emit(exports.RotateEvent.START, this.rotateData);
|
|
442
|
+
}
|
|
443
|
+
data.path = this.rotateData.path;
|
|
444
|
+
interaction.emit(exports.RotateEvent.BEFORE_ROTATE, data);
|
|
445
|
+
interaction.emit(exports.RotateEvent.ROTATE, data);
|
|
446
|
+
this.transformEndWait();
|
|
447
|
+
}
|
|
448
|
+
transformEndWait() {
|
|
449
|
+
clearTimeout(this.transformTimer);
|
|
450
|
+
this.transformTimer = setTimeout(() => {
|
|
451
|
+
this.transformEnd();
|
|
452
|
+
}, this.interaction.config.pointer.transformTime);
|
|
453
|
+
}
|
|
454
|
+
transformEnd() {
|
|
455
|
+
this.moveEnd();
|
|
456
|
+
this.zoomEnd();
|
|
457
|
+
this.rotateEnd();
|
|
458
|
+
}
|
|
459
|
+
moveEnd() {
|
|
460
|
+
if (this.moveData) {
|
|
461
|
+
this.interaction.emit(exports.MoveEvent.END, this.moveData);
|
|
462
|
+
this.moveData = null;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
zoomEnd() {
|
|
466
|
+
if (this.zoomData) {
|
|
467
|
+
this.interaction.emit(exports.ZoomEvent.END, this.zoomData);
|
|
468
|
+
this.zoomData = null;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
rotateEnd() {
|
|
472
|
+
if (this.rotateData) {
|
|
473
|
+
this.interaction.emit(exports.RotateEvent.END, this.rotateData);
|
|
474
|
+
this.rotateData = null;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
destroy() {
|
|
478
|
+
this.zoomData = this.moveData = this.rotateData = null;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const InteractionHelper = {
|
|
483
|
+
getMoveEventData(center, move, event) {
|
|
484
|
+
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, moveX: move.x, moveY: move.y });
|
|
485
|
+
},
|
|
486
|
+
getRotateEventData(center, angle, event) {
|
|
487
|
+
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, rotation: angle });
|
|
488
|
+
},
|
|
489
|
+
getZoomEventData(center, scale, event) {
|
|
490
|
+
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, scale });
|
|
491
|
+
},
|
|
492
|
+
getDragEventData(startPoint, lastPoint, event) {
|
|
493
|
+
return Object.assign(Object.assign({}, event), { x: event.x, y: event.y, moveX: event.x - lastPoint.x, moveY: event.y - lastPoint.y, totalX: event.x - startPoint.x, totalY: event.y - startPoint.y });
|
|
494
|
+
},
|
|
495
|
+
getDropEventData(event, list, data) {
|
|
496
|
+
return Object.assign(Object.assign({}, event), { list,
|
|
497
|
+
data });
|
|
498
|
+
},
|
|
499
|
+
getSwipeDirection(angle) {
|
|
500
|
+
if (angle < -45 && angle > -135) {
|
|
501
|
+
return exports.SwipeEvent.UP;
|
|
502
|
+
}
|
|
503
|
+
else if (angle > 45 && angle < 135) {
|
|
504
|
+
return exports.SwipeEvent.DOWN;
|
|
505
|
+
}
|
|
506
|
+
else if (angle <= 45 && angle >= -45) {
|
|
507
|
+
return exports.SwipeEvent.RIGHT;
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
return exports.SwipeEvent.LEFT;
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
getSwipeEventData(startPoint, lastDragData, event) {
|
|
514
|
+
return Object.assign(Object.assign({}, event), { moveX: lastDragData.moveX, moveY: lastDragData.moveY, totalX: event.x - startPoint.x, totalY: event.y - startPoint.y, type: I.getSwipeDirection(core.PointHelper.getAngle(startPoint, event)) });
|
|
515
|
+
},
|
|
516
|
+
getBase(e) {
|
|
517
|
+
const pointerUpButtons = e.button === 1 ? 4 : e.button;
|
|
518
|
+
return {
|
|
519
|
+
altKey: e.altKey,
|
|
520
|
+
ctrlKey: e.ctrlKey,
|
|
521
|
+
shiftKey: e.shiftKey,
|
|
522
|
+
metaKey: e.metaKey,
|
|
523
|
+
buttons: e.buttons === undefined ? 1 : (e.buttons === 0 ? pointerUpButtons : e.buttons),
|
|
524
|
+
origin: e
|
|
525
|
+
};
|
|
526
|
+
},
|
|
527
|
+
pathHasEventType(path, type) {
|
|
528
|
+
const { list } = path;
|
|
529
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
530
|
+
if (list[i].hasEvent(type))
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
return false;
|
|
534
|
+
},
|
|
535
|
+
filterPathByEventType(path, type) {
|
|
536
|
+
const find = new core.LeafList();
|
|
537
|
+
const { list } = path;
|
|
538
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
539
|
+
if (list[i].hasEvent(type))
|
|
540
|
+
find.add(list[i]);
|
|
541
|
+
}
|
|
542
|
+
return find;
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
const I = InteractionHelper;
|
|
546
|
+
|
|
547
|
+
const emptyList = new core.LeafList();
|
|
548
|
+
const { getDragEventData, getDropEventData, getSwipeEventData } = InteractionHelper;
|
|
549
|
+
class Dragger {
|
|
550
|
+
constructor(interaction) {
|
|
551
|
+
this.interaction = interaction;
|
|
552
|
+
}
|
|
553
|
+
setDragData(data) {
|
|
554
|
+
if (this.animateWait)
|
|
555
|
+
this.dragEndReal();
|
|
556
|
+
this.downData = this.interaction.downData;
|
|
557
|
+
this.dragData = getDragEventData(data, data, data);
|
|
558
|
+
}
|
|
559
|
+
getList() {
|
|
560
|
+
const { proxy } = this.interaction.selector;
|
|
561
|
+
return this.dragging && (!proxy || !proxy.list.length) ? (exports.DragEvent.list || this.dragableList || emptyList) : emptyList;
|
|
562
|
+
}
|
|
563
|
+
checkDrag(data, canDrag) {
|
|
564
|
+
const { interaction } = this;
|
|
565
|
+
if (this.moving && data.buttons < 1) {
|
|
566
|
+
this.canAnimate = false;
|
|
567
|
+
interaction.pointerCancel();
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
this.canAnimate = true;
|
|
572
|
+
}
|
|
573
|
+
if (!this.moving && canDrag) {
|
|
574
|
+
if (this.moving = interaction.moveMode || interaction.isHoldRightKey)
|
|
575
|
+
interaction.emit(exports.MoveEvent.START, this.dragData);
|
|
576
|
+
}
|
|
577
|
+
if (!this.moving) {
|
|
578
|
+
this.dragStart(data, canDrag);
|
|
579
|
+
}
|
|
580
|
+
this.drag(data);
|
|
581
|
+
}
|
|
582
|
+
dragStart(data, canDrag) {
|
|
583
|
+
if (!this.dragging) {
|
|
584
|
+
this.dragging = canDrag && PointerButton.left(data);
|
|
585
|
+
if (this.dragging) {
|
|
586
|
+
this.interaction.emit(exports.DragEvent.START, this.dragData);
|
|
587
|
+
this.getDragableList(this.dragData.path);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
getDragableList(path) {
|
|
592
|
+
let leaf;
|
|
593
|
+
for (let i = 0, len = path.length; i < len; i++) {
|
|
594
|
+
leaf = path.list[i];
|
|
595
|
+
if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf && !leaf.__.locked) {
|
|
596
|
+
this.dragableList = new core.LeafList(leaf);
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
drag(data) {
|
|
602
|
+
const { interaction, dragData, downData } = this;
|
|
603
|
+
const { path, throughPath } = downData;
|
|
604
|
+
this.dragData = getDragEventData(downData, dragData, data);
|
|
605
|
+
if (throughPath)
|
|
606
|
+
this.dragData.throughPath = throughPath;
|
|
607
|
+
this.dragData.path = path;
|
|
608
|
+
if (this.moving) {
|
|
609
|
+
interaction.emit(exports.MoveEvent.BEFORE_MOVE, this.dragData);
|
|
610
|
+
interaction.emit(exports.MoveEvent.MOVE, this.dragData);
|
|
611
|
+
}
|
|
612
|
+
else if (this.dragging) {
|
|
613
|
+
this.dragReal();
|
|
614
|
+
interaction.emit(exports.DragEvent.BEFORE_DRAG, this.dragData);
|
|
615
|
+
interaction.emit(exports.DragEvent.DRAG, this.dragData);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
dragReal() {
|
|
619
|
+
const { running } = this.interaction;
|
|
620
|
+
const list = this.getList();
|
|
621
|
+
if (list.length && running) {
|
|
622
|
+
const { moveX, moveY } = this.dragData;
|
|
623
|
+
list.forEach(leaf => core.LeafHelper.moveWorld(leaf, moveX, moveY));
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
dragOverOrOut(data) {
|
|
627
|
+
const { interaction } = this;
|
|
628
|
+
const { dragOverPath } = this;
|
|
629
|
+
const { path } = data;
|
|
630
|
+
if (dragOverPath) {
|
|
631
|
+
if (path.indexAt(0) !== dragOverPath.indexAt(0)) {
|
|
632
|
+
interaction.emit(exports.DragEvent.OUT, data, dragOverPath);
|
|
633
|
+
interaction.emit(exports.DragEvent.OVER, data, path);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
interaction.emit(exports.DragEvent.OVER, data, path);
|
|
638
|
+
}
|
|
639
|
+
this.dragOverPath = path;
|
|
640
|
+
}
|
|
641
|
+
dragEnterOrLeave(data) {
|
|
642
|
+
const { interaction } = this;
|
|
643
|
+
const { dragEnterPath } = this;
|
|
644
|
+
const { path } = data;
|
|
645
|
+
interaction.emit(exports.DragEvent.LEAVE, data, dragEnterPath, path);
|
|
646
|
+
interaction.emit(exports.DragEvent.ENTER, data, path, dragEnterPath);
|
|
647
|
+
this.dragEnterPath = path;
|
|
648
|
+
}
|
|
649
|
+
dragEnd(data, speed) {
|
|
650
|
+
if (!this.dragData)
|
|
651
|
+
return;
|
|
652
|
+
const { moveX, moveY } = this.dragData;
|
|
653
|
+
if (this.canAnimate && this.moving && (Math.abs(moveX) > 1 || Math.abs(moveY) > 1)) {
|
|
654
|
+
data = Object.assign({}, data);
|
|
655
|
+
speed = (speed || (data.pointerType === 'touch' ? 2 : 1)) * 0.9;
|
|
656
|
+
core.PointHelper.move(data, moveX * speed, moveY * speed);
|
|
657
|
+
this.drag(data);
|
|
658
|
+
this.animate(() => { this.dragEnd(data, 1); });
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
this.dragEndReal(data);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
dragEndReal(data) {
|
|
665
|
+
const { interaction, downData, dragData } = this;
|
|
666
|
+
if (!data)
|
|
667
|
+
data = dragData;
|
|
668
|
+
const { path, throughPath } = downData;
|
|
669
|
+
const endDragData = getDragEventData(downData, data, data);
|
|
670
|
+
if (throughPath)
|
|
671
|
+
endDragData.throughPath = throughPath;
|
|
672
|
+
endDragData.path = path;
|
|
673
|
+
if (this.moving)
|
|
674
|
+
interaction.emit(exports.MoveEvent.END, endDragData);
|
|
675
|
+
if (this.dragging) {
|
|
676
|
+
interaction.emit(exports.DragEvent.END, endDragData);
|
|
677
|
+
this.swipe(data, endDragData);
|
|
678
|
+
this.drop(data);
|
|
679
|
+
}
|
|
680
|
+
this.autoMoveCancel();
|
|
681
|
+
this.dragReset();
|
|
682
|
+
this.animate(null, 'off');
|
|
683
|
+
}
|
|
684
|
+
animate(func, off) {
|
|
685
|
+
const animateWait = func || this.animateWait;
|
|
686
|
+
if (animateWait)
|
|
687
|
+
this.interaction.target.nextRender(animateWait, off);
|
|
688
|
+
this.animateWait = func;
|
|
689
|
+
}
|
|
690
|
+
swipe(data, endDragData) {
|
|
691
|
+
const { interaction } = this;
|
|
692
|
+
const { downData } = interaction;
|
|
693
|
+
if (core.PointHelper.getDistance(downData, data) > interaction.config.pointer.swipeDistance) {
|
|
694
|
+
const swipeData = getSwipeEventData(downData, this.dragData, endDragData);
|
|
695
|
+
this.interaction.emit(swipeData.type, swipeData);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
drop(data) {
|
|
699
|
+
const dropData = getDropEventData(data, this.getList(), exports.DragEvent.data);
|
|
700
|
+
dropData.path = this.dragEnterPath;
|
|
701
|
+
this.interaction.emit(exports.DropEvent.DROP, dropData);
|
|
702
|
+
this.interaction.emit(exports.DragEvent.LEAVE, data, this.dragEnterPath);
|
|
703
|
+
}
|
|
704
|
+
dragReset() {
|
|
705
|
+
exports.DragEvent.list = exports.DragEvent.data = this.dragableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
|
|
706
|
+
this.dragging = this.moving = false;
|
|
707
|
+
}
|
|
708
|
+
checkDragOut(data) {
|
|
709
|
+
const { interaction } = this;
|
|
710
|
+
this.autoMoveCancel();
|
|
711
|
+
if (this.dragging && !interaction.shrinkCanvasBounds.hitPoint(data))
|
|
712
|
+
this.autoMoveOnDragOut(data);
|
|
713
|
+
}
|
|
714
|
+
autoMoveOnDragOut(data) {
|
|
715
|
+
const { interaction, downData } = this;
|
|
716
|
+
const { autoDistance, dragOut } = interaction.config.move;
|
|
717
|
+
if (!dragOut || !autoDistance)
|
|
718
|
+
return;
|
|
719
|
+
const bounds = interaction.shrinkCanvasBounds;
|
|
720
|
+
const { x, y } = bounds;
|
|
721
|
+
const right = core.BoundsHelper.maxX(bounds);
|
|
722
|
+
const bottom = core.BoundsHelper.maxY(bounds);
|
|
723
|
+
const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
|
|
724
|
+
const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
|
|
725
|
+
let totalX = 0, totalY = 0;
|
|
726
|
+
this.autoMoveTimer = setInterval(() => {
|
|
727
|
+
totalX += moveX;
|
|
728
|
+
totalY += moveY;
|
|
729
|
+
core.PointHelper.move(downData, moveX, moveY);
|
|
730
|
+
core.PointHelper.move(this.dragData, moveX, moveY);
|
|
731
|
+
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY }));
|
|
732
|
+
interaction.pointerMoveReal(data);
|
|
733
|
+
}, 10);
|
|
734
|
+
}
|
|
735
|
+
autoMoveCancel() {
|
|
736
|
+
if (this.autoMoveTimer) {
|
|
737
|
+
clearInterval(this.autoMoveTimer);
|
|
738
|
+
this.autoMoveTimer = 0;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
destroy() {
|
|
742
|
+
this.dragReset();
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
const debug = core.Debug.get('emit');
|
|
747
|
+
function emit(type, data, path, excludePath) {
|
|
748
|
+
if (!path && !data.path)
|
|
749
|
+
return;
|
|
750
|
+
let leaf;
|
|
751
|
+
data.type = type;
|
|
752
|
+
if (path) {
|
|
753
|
+
data = Object.assign(Object.assign({}, data), { path });
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
path = data.path;
|
|
757
|
+
}
|
|
758
|
+
data.target = path.indexAt(0);
|
|
759
|
+
try {
|
|
760
|
+
for (let i = path.length - 1; i > -1; i--) {
|
|
761
|
+
leaf = path.list[i];
|
|
762
|
+
if (emitEvent(leaf, type, data, true, excludePath))
|
|
763
|
+
return;
|
|
764
|
+
if (leaf.isApp)
|
|
765
|
+
emitAppChildren(leaf, type, data, true, excludePath);
|
|
766
|
+
}
|
|
767
|
+
for (let i = 0, len = path.length; i < len; i++) {
|
|
768
|
+
leaf = path.list[i];
|
|
769
|
+
if (leaf.isApp)
|
|
770
|
+
emitAppChildren(leaf, type, data, false, excludePath);
|
|
771
|
+
if (emitEvent(leaf, type, data, false, excludePath))
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
catch (e) {
|
|
776
|
+
debug.error(e);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
const allowTypes = ['move', 'zoom', 'rotate', 'key'];
|
|
780
|
+
function emitAppChildren(leaf, type, data, capture, excludePath) {
|
|
781
|
+
if (allowTypes.some(name => type.startsWith(name)) && leaf.__.hitChildren && !exclude(leaf, excludePath)) {
|
|
782
|
+
let child;
|
|
783
|
+
for (let i = 0, len = leaf.children.length; i < len; i++) {
|
|
784
|
+
child = leaf.children[i];
|
|
785
|
+
if (!data.path.has(child) && child.__.hittable)
|
|
786
|
+
emitEvent(child, type, data, capture, excludePath);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function emitEvent(leaf, type, data, capture, excludePath) {
|
|
791
|
+
if (leaf.destroyed)
|
|
792
|
+
return true;
|
|
793
|
+
if (leaf.__.hitSelf && leaf.hasEvent(type, capture) && !exclude(leaf, excludePath)) {
|
|
794
|
+
data.phase = capture ? 1 : ((leaf === data.target) ? 2 : 3);
|
|
795
|
+
const event = core.EventCreator.get(type, data);
|
|
796
|
+
leaf.emitEvent(event, capture);
|
|
797
|
+
if (event.isStop)
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
800
|
+
return false;
|
|
801
|
+
}
|
|
802
|
+
function exclude(leaf, excludePath) {
|
|
803
|
+
return excludePath && excludePath.has(leaf);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
const MultiTouchHelper = {
|
|
807
|
+
getData(list) {
|
|
808
|
+
const a = list[0];
|
|
809
|
+
const b = list[1];
|
|
810
|
+
const lastCenter = core.PointHelper.getCenter(a.from, b.from);
|
|
811
|
+
const center = core.PointHelper.getCenter(a.to, b.to);
|
|
812
|
+
const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
|
|
813
|
+
const lastDistance = core.PointHelper.getDistance(a.from, b.from);
|
|
814
|
+
const distance = core.PointHelper.getDistance(a.to, b.to);
|
|
815
|
+
const scale = distance / lastDistance;
|
|
816
|
+
const angle = core.PointHelper.getRotation(a.from, b.from, a.to, b.to);
|
|
817
|
+
return { move, scale, angle, center };
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
|
|
821
|
+
const config = {
|
|
822
|
+
wheel: {
|
|
823
|
+
zoomMode: false,
|
|
824
|
+
zoomSpeed: 0.5,
|
|
825
|
+
moveSpeed: 0.5,
|
|
826
|
+
rotateSpeed: 0.5,
|
|
827
|
+
delta: { x: 80 / 4, y: 8.0 },
|
|
828
|
+
preventDefault: true
|
|
829
|
+
},
|
|
830
|
+
pointer: {
|
|
831
|
+
hitRadius: 5,
|
|
832
|
+
through: false,
|
|
833
|
+
tapTime: 120,
|
|
834
|
+
longPressTime: 800,
|
|
835
|
+
transformTime: 500,
|
|
836
|
+
dragHover: true,
|
|
837
|
+
dragDistance: 2,
|
|
838
|
+
swipeDistance: 20,
|
|
839
|
+
ignoreMove: false,
|
|
840
|
+
preventDefaultMenu: true
|
|
841
|
+
},
|
|
842
|
+
cursor: {}
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper;
|
|
846
|
+
class InteractionBase {
|
|
847
|
+
get dragging() { return this.dragger.dragging; }
|
|
848
|
+
get isDragEmpty() { return this.config.move.dragEmpty && (this.hoverData && this.hoverData.path.list[0].isLeafer) && (!this.downData || this.downData.path.list[0].isLeafer); }
|
|
849
|
+
get isHoldRightKey() { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData); }
|
|
850
|
+
get moveMode() { return this.config.move.drag || (this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey()) || (this.downData && ((this.config.move.holdMiddleKey && PointerButton.middle(this.downData)) || (this.isHoldRightKey && this.dragger.moving))) || this.isDragEmpty; }
|
|
851
|
+
get hitRadius() { return this.config.pointer.hitRadius; }
|
|
852
|
+
constructor(target, canvas, selector, userConfig) {
|
|
853
|
+
this.config = config;
|
|
854
|
+
this.tapCount = 0;
|
|
855
|
+
this.downKeyMap = {};
|
|
856
|
+
this.target = target;
|
|
857
|
+
this.canvas = canvas;
|
|
858
|
+
this.selector = selector;
|
|
859
|
+
this.defaultPath = new core.LeafList(target);
|
|
860
|
+
this.transformer = new Transformer(this);
|
|
861
|
+
this.dragger = new Dragger(this);
|
|
862
|
+
if (userConfig)
|
|
863
|
+
this.config = core.DataHelper.default(userConfig, this.config);
|
|
864
|
+
this.__listenEvents();
|
|
865
|
+
}
|
|
866
|
+
start() {
|
|
867
|
+
this.running = true;
|
|
868
|
+
}
|
|
869
|
+
stop() {
|
|
870
|
+
this.running = false;
|
|
871
|
+
}
|
|
872
|
+
receive(_event) { }
|
|
873
|
+
pointerDown(data, useDefaultPath) {
|
|
874
|
+
if (!data)
|
|
875
|
+
data = this.hoverData;
|
|
876
|
+
if (!data)
|
|
877
|
+
return;
|
|
878
|
+
PointerButton.defaultLeft(data);
|
|
879
|
+
this.updateDownData(data);
|
|
880
|
+
if (useDefaultPath)
|
|
881
|
+
data.path = this.defaultPath;
|
|
882
|
+
this.emit(exports.PointerEvent.BEFORE_DOWN, data);
|
|
883
|
+
this.emit(exports.PointerEvent.DOWN, data);
|
|
884
|
+
this.downTime = Date.now();
|
|
885
|
+
this.dragger.setDragData(data);
|
|
886
|
+
if (PointerButton.left(data)) {
|
|
887
|
+
this.tapWait();
|
|
888
|
+
this.longPressWait(data);
|
|
889
|
+
}
|
|
890
|
+
else if (PointerButton.right(data)) {
|
|
891
|
+
this.waitMenuTap = true;
|
|
892
|
+
}
|
|
893
|
+
this.updateCursor(data);
|
|
894
|
+
}
|
|
895
|
+
pointerMove(data) {
|
|
896
|
+
if (!data)
|
|
897
|
+
data = this.hoverData;
|
|
898
|
+
if (!data)
|
|
899
|
+
return;
|
|
900
|
+
if (this.downData)
|
|
901
|
+
PointerButton.defaultLeft(data);
|
|
902
|
+
const hit = this.canvas.bounds.hitPoint(data);
|
|
903
|
+
if (hit || this.downData) {
|
|
904
|
+
if (hit && !this.downData && PointerButton.left(data))
|
|
905
|
+
this.pointerDown(data, true);
|
|
906
|
+
this.pointerMoveReal(data);
|
|
907
|
+
this.dragger.checkDragOut(data);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
pointerMoveReal(data) {
|
|
911
|
+
this.emit(exports.PointerEvent.BEFORE_MOVE, data, this.defaultPath);
|
|
912
|
+
if (this.downData) {
|
|
913
|
+
const canDrag = core.PointHelper.getDistance(this.downData, data) > this.config.pointer.dragDistance;
|
|
914
|
+
if (canDrag) {
|
|
915
|
+
if (this.waitTap)
|
|
916
|
+
this.pointerWaitCancel();
|
|
917
|
+
this.waitMenuTap = false;
|
|
918
|
+
}
|
|
919
|
+
this.dragger.checkDrag(data, canDrag);
|
|
920
|
+
}
|
|
921
|
+
if (!this.dragger.moving) {
|
|
922
|
+
this.updateHoverData(data);
|
|
923
|
+
this.emit(exports.PointerEvent.MOVE, data);
|
|
924
|
+
this.pointerOverOrOut(data);
|
|
925
|
+
this.pointerEnterOrLeave(data);
|
|
926
|
+
if (this.dragger.dragging) {
|
|
927
|
+
this.dragger.dragOverOrOut(data);
|
|
928
|
+
this.dragger.dragEnterOrLeave(data);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
this.updateCursor(this.downData || data);
|
|
932
|
+
}
|
|
933
|
+
pointerUp(data) {
|
|
934
|
+
if (!data)
|
|
935
|
+
data = this.downData;
|
|
936
|
+
if (!this.downData)
|
|
937
|
+
return;
|
|
938
|
+
PointerButton.defaultLeft(data);
|
|
939
|
+
this.findPath(data);
|
|
940
|
+
this.emit(exports.PointerEvent.BEFORE_UP, data);
|
|
941
|
+
this.emit(exports.PointerEvent.UP, data);
|
|
942
|
+
if (this.oldDownData)
|
|
943
|
+
this.emit(exports.PointerEvent.UP, this.oldDownData, undefined, data.path);
|
|
944
|
+
this.emit(exports.PointerEvent.UP, this.downData, undefined, data.path);
|
|
945
|
+
this.touchLeave(data);
|
|
946
|
+
this.tap(data);
|
|
947
|
+
this.menuTap(data);
|
|
948
|
+
this.dragger.dragEnd(data);
|
|
949
|
+
this.downData = this.oldDownData = null;
|
|
950
|
+
this.updateCursor(data);
|
|
951
|
+
}
|
|
952
|
+
pointerCancel() {
|
|
953
|
+
this.pointerUp(this.dragger.dragData);
|
|
954
|
+
}
|
|
955
|
+
multiTouch(data, list) {
|
|
956
|
+
const { move, angle, scale, center } = MultiTouchHelper.getData(list);
|
|
957
|
+
this.rotate(getRotateEventData(center, angle, data));
|
|
958
|
+
this.zoom(getZoomEventData(center, scale, data));
|
|
959
|
+
this.move(getMoveEventData(center, move, data));
|
|
960
|
+
}
|
|
961
|
+
menu(data) {
|
|
962
|
+
this.findPath(data);
|
|
963
|
+
this.emit(exports.PointerEvent.MENU, data);
|
|
964
|
+
}
|
|
965
|
+
menuTap(data) {
|
|
966
|
+
if (this.waitMenuTap)
|
|
967
|
+
this.emit(exports.PointerEvent.MENU_TAP, data);
|
|
968
|
+
}
|
|
969
|
+
move(data) {
|
|
970
|
+
this.transformer.move(data);
|
|
971
|
+
}
|
|
972
|
+
zoom(data) {
|
|
973
|
+
this.transformer.zoom(data);
|
|
974
|
+
}
|
|
975
|
+
rotate(data) {
|
|
976
|
+
this.transformer.rotate(data);
|
|
977
|
+
}
|
|
978
|
+
transformEnd() {
|
|
979
|
+
this.transformer.transformEnd();
|
|
980
|
+
}
|
|
981
|
+
keyDown(data) {
|
|
982
|
+
const { code } = data;
|
|
983
|
+
if (!this.downKeyMap[code]) {
|
|
984
|
+
this.downKeyMap[code] = true;
|
|
985
|
+
Keyboard.setDownCode(code);
|
|
986
|
+
this.emit(exports.KeyEvent.HOLD, data, this.defaultPath);
|
|
987
|
+
if (this.moveMode)
|
|
988
|
+
this.updateCursor();
|
|
989
|
+
}
|
|
990
|
+
this.emit(exports.KeyEvent.DOWN, data, this.defaultPath);
|
|
991
|
+
}
|
|
992
|
+
keyUp(data) {
|
|
993
|
+
const { code } = data;
|
|
994
|
+
this.downKeyMap[code] = false;
|
|
995
|
+
Keyboard.setUpCode(code);
|
|
996
|
+
this.emit(exports.KeyEvent.UP, data, this.defaultPath);
|
|
997
|
+
if (this.cursor === 'grab')
|
|
998
|
+
this.updateCursor();
|
|
999
|
+
}
|
|
1000
|
+
pointerOverOrOut(data) {
|
|
1001
|
+
if (this.dragger.moving)
|
|
1002
|
+
return;
|
|
1003
|
+
if (this.dragging && !this.config.pointer.dragHover)
|
|
1004
|
+
return;
|
|
1005
|
+
const { path } = data;
|
|
1006
|
+
if (this.overPath) {
|
|
1007
|
+
if (path.indexAt(0) !== this.overPath.indexAt(0)) {
|
|
1008
|
+
this.emit(exports.PointerEvent.OUT, data, this.overPath);
|
|
1009
|
+
this.emit(exports.PointerEvent.OVER, data, path);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
else {
|
|
1013
|
+
this.emit(exports.PointerEvent.OVER, data, path);
|
|
1014
|
+
}
|
|
1015
|
+
this.overPath = path;
|
|
1016
|
+
}
|
|
1017
|
+
pointerEnterOrLeave(data) {
|
|
1018
|
+
if (this.dragger.moving)
|
|
1019
|
+
return;
|
|
1020
|
+
if (this.dragging && !this.config.pointer.dragHover)
|
|
1021
|
+
return;
|
|
1022
|
+
const { path } = data;
|
|
1023
|
+
this.emit(exports.PointerEvent.LEAVE, data, this.enterPath, path);
|
|
1024
|
+
this.emit(exports.PointerEvent.ENTER, data, path, this.enterPath);
|
|
1025
|
+
this.enterPath = path;
|
|
1026
|
+
}
|
|
1027
|
+
touchLeave(data) {
|
|
1028
|
+
if (data.pointerType === 'touch') {
|
|
1029
|
+
if (this.enterPath) {
|
|
1030
|
+
this.emit(exports.PointerEvent.LEAVE, data);
|
|
1031
|
+
if (this.dragger.dragging)
|
|
1032
|
+
this.emit(exports.DropEvent.LEAVE, data);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
tap(data) {
|
|
1037
|
+
const { pointer } = this.config;
|
|
1038
|
+
const longTap = this.longTap(data);
|
|
1039
|
+
if (!pointer.tapMore && longTap)
|
|
1040
|
+
return;
|
|
1041
|
+
if (!this.waitTap)
|
|
1042
|
+
return;
|
|
1043
|
+
if (pointer.tapMore)
|
|
1044
|
+
this.emitTap(data);
|
|
1045
|
+
const useTime = Date.now() - this.downTime;
|
|
1046
|
+
const hasDouble = [exports.PointerEvent.DOUBLE_TAP, exports.PointerEvent.DOUBLE_CLICK].some(type => pathHasEventType(data.path, type));
|
|
1047
|
+
if (useTime < pointer.tapTime + 50 && hasDouble) {
|
|
1048
|
+
this.tapCount++;
|
|
1049
|
+
if (this.tapCount === 2) {
|
|
1050
|
+
this.tapWaitCancel();
|
|
1051
|
+
this.emitDoubleTap(data);
|
|
1052
|
+
}
|
|
1053
|
+
else {
|
|
1054
|
+
clearTimeout(this.tapTimer);
|
|
1055
|
+
this.tapTimer = setTimeout(() => {
|
|
1056
|
+
if (!pointer.tapMore) {
|
|
1057
|
+
this.tapWaitCancel();
|
|
1058
|
+
this.emitTap(data);
|
|
1059
|
+
}
|
|
1060
|
+
}, pointer.tapTime);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
else {
|
|
1064
|
+
if (!pointer.tapMore) {
|
|
1065
|
+
this.tapWaitCancel();
|
|
1066
|
+
this.emitTap(data);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
findPath(data, options) {
|
|
1071
|
+
const { hitRadius, through } = this.config.pointer;
|
|
1072
|
+
const find = this.selector.getByPoint(data, hitRadius, options || { through });
|
|
1073
|
+
if (find.throughPath)
|
|
1074
|
+
data.throughPath = find.throughPath;
|
|
1075
|
+
data.path = find.path;
|
|
1076
|
+
return find.path;
|
|
1077
|
+
}
|
|
1078
|
+
isDrag(leaf) {
|
|
1079
|
+
return this.dragger.getList().has(leaf);
|
|
1080
|
+
}
|
|
1081
|
+
updateDownData(data, options) {
|
|
1082
|
+
const { downData } = this;
|
|
1083
|
+
if (!data && downData)
|
|
1084
|
+
data = Object.assign({}, downData);
|
|
1085
|
+
if (!data)
|
|
1086
|
+
return;
|
|
1087
|
+
this.oldDownData = downData;
|
|
1088
|
+
this.findPath(data, options);
|
|
1089
|
+
this.downData = data;
|
|
1090
|
+
}
|
|
1091
|
+
updateHoverData(data) {
|
|
1092
|
+
if (!data)
|
|
1093
|
+
data = this.hoverData;
|
|
1094
|
+
if (!data)
|
|
1095
|
+
return;
|
|
1096
|
+
this.findPath(data, { exclude: this.dragger.getList(), name: exports.PointerEvent.MOVE });
|
|
1097
|
+
this.hoverData = data;
|
|
1098
|
+
}
|
|
1099
|
+
updateCursor(data) {
|
|
1100
|
+
if (this.config.cursor.stop)
|
|
1101
|
+
return;
|
|
1102
|
+
if (!data) {
|
|
1103
|
+
this.updateHoverData();
|
|
1104
|
+
data = this.downData || this.hoverData;
|
|
1105
|
+
}
|
|
1106
|
+
if (this.dragger.moving) {
|
|
1107
|
+
return this.setCursor('grabbing');
|
|
1108
|
+
}
|
|
1109
|
+
else if (this.moveMode) {
|
|
1110
|
+
return this.setCursor(this.downData ? 'grabbing' : 'grab');
|
|
1111
|
+
}
|
|
1112
|
+
else if (!data)
|
|
1113
|
+
return;
|
|
1114
|
+
let leaf;
|
|
1115
|
+
let cursor;
|
|
1116
|
+
const { path } = data;
|
|
1117
|
+
for (let i = 0, len = path.length; i < len; i++) {
|
|
1118
|
+
leaf = path.list[i];
|
|
1119
|
+
cursor = leaf.cursor;
|
|
1120
|
+
if (cursor)
|
|
1121
|
+
break;
|
|
1122
|
+
}
|
|
1123
|
+
this.setCursor(cursor);
|
|
1124
|
+
}
|
|
1125
|
+
setCursor(cursor) {
|
|
1126
|
+
this.cursor = cursor;
|
|
1127
|
+
}
|
|
1128
|
+
emitTap(data) {
|
|
1129
|
+
this.emit(exports.PointerEvent.TAP, data);
|
|
1130
|
+
this.emit(exports.PointerEvent.CLICK, data);
|
|
1131
|
+
}
|
|
1132
|
+
emitDoubleTap(data) {
|
|
1133
|
+
this.emit(exports.PointerEvent.DOUBLE_TAP, data);
|
|
1134
|
+
this.emit(exports.PointerEvent.DOUBLE_CLICK, data);
|
|
1135
|
+
}
|
|
1136
|
+
pointerWaitCancel() {
|
|
1137
|
+
this.tapWaitCancel();
|
|
1138
|
+
this.longPressWaitCancel();
|
|
1139
|
+
}
|
|
1140
|
+
tapWait() {
|
|
1141
|
+
clearTimeout(this.tapTimer);
|
|
1142
|
+
this.waitTap = true;
|
|
1143
|
+
}
|
|
1144
|
+
tapWaitCancel() {
|
|
1145
|
+
clearTimeout(this.tapTimer);
|
|
1146
|
+
this.waitTap = false;
|
|
1147
|
+
this.tapCount = 0;
|
|
1148
|
+
}
|
|
1149
|
+
longPressWait(data) {
|
|
1150
|
+
clearTimeout(this.longPressTimer);
|
|
1151
|
+
this.longPressTimer = setTimeout(() => {
|
|
1152
|
+
this.longPressed = true;
|
|
1153
|
+
this.emit(exports.PointerEvent.LONG_PRESS, data);
|
|
1154
|
+
}, this.config.pointer.longPressTime);
|
|
1155
|
+
}
|
|
1156
|
+
longTap(data) {
|
|
1157
|
+
let longTap;
|
|
1158
|
+
if (this.longPressed) {
|
|
1159
|
+
this.emit(exports.PointerEvent.LONG_TAP, data);
|
|
1160
|
+
if (pathHasEventType(data.path, exports.PointerEvent.LONG_TAP))
|
|
1161
|
+
longTap = true;
|
|
1162
|
+
}
|
|
1163
|
+
this.longPressWaitCancel();
|
|
1164
|
+
return longTap;
|
|
1165
|
+
}
|
|
1166
|
+
longPressWaitCancel() {
|
|
1167
|
+
clearTimeout(this.longPressTimer);
|
|
1168
|
+
this.longPressed = false;
|
|
1169
|
+
}
|
|
1170
|
+
__onResize() {
|
|
1171
|
+
this.shrinkCanvasBounds = new core.Bounds(this.canvas.bounds);
|
|
1172
|
+
this.shrinkCanvasBounds.spread(-2);
|
|
1173
|
+
}
|
|
1174
|
+
__listenEvents() {
|
|
1175
|
+
const { target } = this;
|
|
1176
|
+
this.__eventIds = [target.on_(core.ResizeEvent.RESIZE, this.__onResize, this)];
|
|
1177
|
+
target.once(core.LeaferEvent.READY, () => this.__onResize());
|
|
1178
|
+
}
|
|
1179
|
+
__removeListenEvents() {
|
|
1180
|
+
this.target.off_(this.__eventIds);
|
|
1181
|
+
this.__eventIds.length = 0;
|
|
1182
|
+
}
|
|
1183
|
+
emit(type, data, path, excludePath) {
|
|
1184
|
+
if (this.running)
|
|
1185
|
+
emit(type, data, path, excludePath);
|
|
1186
|
+
}
|
|
1187
|
+
destroy() {
|
|
1188
|
+
if (this.__eventIds.length) {
|
|
1189
|
+
this.stop();
|
|
1190
|
+
this.__removeListenEvents();
|
|
1191
|
+
this.dragger.destroy();
|
|
1192
|
+
this.transformer.destroy();
|
|
1193
|
+
this.downData = this.overPath = this.enterPath = null;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
class Cursor {
|
|
1199
|
+
static set(name, value) {
|
|
1200
|
+
this.custom[name] = value;
|
|
1201
|
+
}
|
|
1202
|
+
static get(name) {
|
|
1203
|
+
return this.custom[name];
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
Cursor.custom = {};
|
|
1207
|
+
|
|
1208
|
+
class HitCanvasManager extends core.CanvasManager {
|
|
1209
|
+
constructor() {
|
|
1210
|
+
super(...arguments);
|
|
1211
|
+
this.pathTypeList = new core.LeafList();
|
|
1212
|
+
this.imageTypeList = new core.LeafList();
|
|
1213
|
+
}
|
|
1214
|
+
getImageType(leaf, size) {
|
|
1215
|
+
this.imageTypeList.add(leaf);
|
|
1216
|
+
return core.Creator.hitCanvas(size);
|
|
1217
|
+
}
|
|
1218
|
+
getPathType(leaf) {
|
|
1219
|
+
this.pathTypeList.add(leaf);
|
|
1220
|
+
return core.Creator.hitCanvas();
|
|
1221
|
+
}
|
|
1222
|
+
clearImageType() {
|
|
1223
|
+
this.__clearLeafList(this.imageTypeList);
|
|
1224
|
+
}
|
|
1225
|
+
clearPathType() {
|
|
1226
|
+
this.__clearLeafList(this.pathTypeList);
|
|
1227
|
+
}
|
|
1228
|
+
__clearLeafList(leafList) {
|
|
1229
|
+
if (leafList.length) {
|
|
1230
|
+
leafList.forEach(leaf => {
|
|
1231
|
+
if (leaf.__hitCanvas) {
|
|
1232
|
+
leaf.__hitCanvas.destroy();
|
|
1233
|
+
leaf.__hitCanvas = null;
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
leafList.reset();
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
clear() {
|
|
1240
|
+
this.clearPathType();
|
|
1241
|
+
this.clearImageType();
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
const { toInnerRadiusPointOf, copy, setRadius } = draw$1.PointHelper;
|
|
1246
|
+
const inner = {};
|
|
1247
|
+
draw$1.Leaf.prototype.__hitWorld = function (point) {
|
|
1248
|
+
if (this.__layout.hitCanvasChanged || !this.__hitCanvas) {
|
|
1249
|
+
this.__updateHitCanvas();
|
|
1250
|
+
this.__layout.hitCanvasChanged = false;
|
|
1251
|
+
}
|
|
1252
|
+
if (this.__.hitRadius) {
|
|
1253
|
+
copy(inner, point), point = inner;
|
|
1254
|
+
setRadius(point, this.__.hitRadius);
|
|
1255
|
+
}
|
|
1256
|
+
toInnerRadiusPointOf(point, this.__world, inner);
|
|
1257
|
+
if (this.__.hitBox) {
|
|
1258
|
+
if (draw$1.BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
|
|
1259
|
+
return true;
|
|
1260
|
+
}
|
|
1261
|
+
return this.__hit(inner);
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
draw$1.UI.prototype.__updateHitCanvas = function () {
|
|
1265
|
+
if (!this.__hitCanvas)
|
|
1266
|
+
this.__hitCanvas = this.leafer.hitCanvasManager.getPathType(this);
|
|
1267
|
+
const h = this.__hitCanvas;
|
|
1268
|
+
this.__drawHitPath(h);
|
|
1269
|
+
h.setStrokeOptions(this.__);
|
|
1270
|
+
};
|
|
1271
|
+
draw$1.UI.prototype.__hit = function (inner) {
|
|
1272
|
+
if (draw$1.Platform.name === 'miniapp')
|
|
1273
|
+
this.__drawHitPath(this.__hitCanvas);
|
|
1274
|
+
const { fill, hitFill, windingRule } = this.__;
|
|
1275
|
+
const needHitFill = (fill && hitFill === 'path') || hitFill === 'all';
|
|
1276
|
+
const isHitFill = this.__hitFill(inner, windingRule);
|
|
1277
|
+
if (needHitFill && isHitFill)
|
|
1278
|
+
return true;
|
|
1279
|
+
const { stroke, hitStroke, __strokeWidth, strokeAlign } = this.__;
|
|
1280
|
+
const needHitStroke = (stroke && hitStroke === 'path') || hitStroke === 'all';
|
|
1281
|
+
const radiusWidth = inner.radiusX * 2;
|
|
1282
|
+
let hitWidth = radiusWidth;
|
|
1283
|
+
if (needHitStroke) {
|
|
1284
|
+
switch (strokeAlign) {
|
|
1285
|
+
case 'inside':
|
|
1286
|
+
hitWidth += __strokeWidth * 2;
|
|
1287
|
+
if (!needHitFill && (isHitFill && this.__hitStroke(inner, hitWidth)))
|
|
1288
|
+
return true;
|
|
1289
|
+
hitWidth = radiusWidth;
|
|
1290
|
+
break;
|
|
1291
|
+
case 'center':
|
|
1292
|
+
hitWidth += __strokeWidth;
|
|
1293
|
+
break;
|
|
1294
|
+
case 'outside':
|
|
1295
|
+
hitWidth += __strokeWidth * 2;
|
|
1296
|
+
if (!needHitFill) {
|
|
1297
|
+
if (!isHitFill && this.__hitStroke(inner, hitWidth))
|
|
1298
|
+
return true;
|
|
1299
|
+
hitWidth = radiusWidth;
|
|
1300
|
+
}
|
|
1301
|
+
break;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1307
|
+
const ui = new draw$1.UI();
|
|
1308
|
+
draw$1.Rect.prototype.__updateHitCanvas = function () {
|
|
1309
|
+
if (this.stroke || this.cornerRadius)
|
|
1310
|
+
ui.__updateHitCanvas.call(this);
|
|
1311
|
+
};
|
|
1312
|
+
draw$1.Rect.prototype.__hitFill = function (inner, windingRule) {
|
|
1313
|
+
return this.__hitCanvas ? ui.__hitFill.call(this, inner, windingRule) : draw$1.BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
draw$1.UI.prototype.find = function (condition, options) {
|
|
1317
|
+
return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
|
|
1318
|
+
};
|
|
1319
|
+
draw$1.UI.prototype.findOne = function (condition, options) {
|
|
1320
|
+
return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
|
|
1321
|
+
};
|
|
1322
|
+
draw$1.Group.prototype.pick = function (hitPoint, options) {
|
|
1323
|
+
this.__layout.update();
|
|
1324
|
+
if (!options)
|
|
1325
|
+
options = {};
|
|
1326
|
+
return this.leafer ? this.leafer.selector.getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this })) : null;
|
|
1327
|
+
};
|
|
1328
|
+
|
|
1329
|
+
exports.Cursor = Cursor;
|
|
1330
|
+
exports.HitCanvasManager = HitCanvasManager;
|
|
1331
|
+
exports.InteractionBase = InteractionBase;
|
|
1332
|
+
exports.InteractionHelper = InteractionHelper;
|
|
1333
|
+
exports.Keyboard = Keyboard;
|
|
1334
|
+
exports.LeaferTypeCreator = LeaferTypeCreator;
|
|
1335
|
+
exports.MultiTouchHelper = MultiTouchHelper;
|
|
1336
|
+
exports.PointerButton = PointerButton;
|
|
1337
|
+
exports.UIEvent = UIEvent;
|
|
1338
|
+
Object.keys(draw$1).forEach(function (k) {
|
|
1339
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1340
|
+
enumerable: true,
|
|
1341
|
+
get: function () { return draw$1[k]; }
|
|
1342
|
+
});
|
|
1343
|
+
});
|