@leafer-ui/worker 1.0.10 → 1.1.1
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/worker.cjs +25 -12
- package/dist/worker.esm.js +25 -12
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +175 -399
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +175 -397
- package/dist/worker.module.min.js +1 -1
- package/package.json +9 -9
package/dist/worker.module.js
CHANGED
|
@@ -108,7 +108,7 @@ const MathHelper = {
|
|
|
108
108
|
return rotation - oldRotation;
|
|
109
109
|
},
|
|
110
110
|
float(num, maxLength) {
|
|
111
|
-
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
111
|
+
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
112
112
|
num = round(num * a) / a;
|
|
113
113
|
return num === -0 ? 0 : num;
|
|
114
114
|
},
|
|
@@ -1411,14 +1411,14 @@ const UICreator = {
|
|
|
1411
1411
|
list: {},
|
|
1412
1412
|
register(UI) {
|
|
1413
1413
|
const { __tag: tag } = UI.prototype;
|
|
1414
|
-
if (list$
|
|
1414
|
+
if (list$1[tag])
|
|
1415
1415
|
debug$e.repeat(tag);
|
|
1416
|
-
list$
|
|
1416
|
+
list$1[tag] = UI;
|
|
1417
1417
|
},
|
|
1418
1418
|
get(tag, data, x, y, width, height) {
|
|
1419
|
-
if (!list$
|
|
1419
|
+
if (!list$1[tag])
|
|
1420
1420
|
debug$e.error('not register ' + tag);
|
|
1421
|
-
const ui = new list$
|
|
1421
|
+
const ui = new list$1[tag](data);
|
|
1422
1422
|
if (x !== undefined) {
|
|
1423
1423
|
ui.x = x;
|
|
1424
1424
|
if (y)
|
|
@@ -1431,7 +1431,7 @@ const UICreator = {
|
|
|
1431
1431
|
return ui;
|
|
1432
1432
|
}
|
|
1433
1433
|
};
|
|
1434
|
-
const { list: list$
|
|
1434
|
+
const { list: list$1 } = UICreator;
|
|
1435
1435
|
|
|
1436
1436
|
const debug$d = Debug.get('EventCreator');
|
|
1437
1437
|
const EventCreator = {
|
|
@@ -1513,17 +1513,19 @@ const DataHelper = {
|
|
|
1513
1513
|
assign(t, defaultData);
|
|
1514
1514
|
return t;
|
|
1515
1515
|
},
|
|
1516
|
-
assign(t, merge) {
|
|
1516
|
+
assign(t, merge, exclude) {
|
|
1517
1517
|
let value;
|
|
1518
1518
|
Object.keys(merge).forEach(key => {
|
|
1519
|
-
var _a;
|
|
1519
|
+
var _a, _b;
|
|
1520
1520
|
value = merge[key];
|
|
1521
|
-
if ((value === null || value === void 0 ? void 0 : value.constructor) === Object)
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1521
|
+
if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object)
|
|
1522
|
+
return assign(t[key], merge[key], exclude && exclude[key]);
|
|
1523
|
+
if (exclude && (key in exclude)) {
|
|
1524
|
+
if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object)
|
|
1525
|
+
assign(t[key] = {}, merge[key], exclude[key]);
|
|
1526
|
+
return;
|
|
1526
1527
|
}
|
|
1528
|
+
t[key] = merge[key];
|
|
1527
1529
|
});
|
|
1528
1530
|
},
|
|
1529
1531
|
copyAttrs(t, from, include) {
|
|
@@ -3891,6 +3893,8 @@ function opacityType(defaultValue) {
|
|
|
3891
3893
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3892
3894
|
set(value) {
|
|
3893
3895
|
this.__setAttr(key, value) && (this.__layout.opacityChanged || this.__layout.opacityChange());
|
|
3896
|
+
if (this.mask)
|
|
3897
|
+
checkMask(this);
|
|
3894
3898
|
}
|
|
3895
3899
|
}));
|
|
3896
3900
|
}
|
|
@@ -3907,9 +3911,20 @@ function visibleType(defaultValue) {
|
|
|
3907
3911
|
this.__runAnimation('in');
|
|
3908
3912
|
}
|
|
3909
3913
|
doVisible(this, key, value, oldValue);
|
|
3914
|
+
if (this.mask)
|
|
3915
|
+
checkMask(this);
|
|
3910
3916
|
}
|
|
3911
3917
|
}));
|
|
3912
3918
|
}
|
|
3919
|
+
function checkMask(leaf) {
|
|
3920
|
+
const { parent } = leaf;
|
|
3921
|
+
if (parent) {
|
|
3922
|
+
const { __hasMask } = parent;
|
|
3923
|
+
parent.__updateMask();
|
|
3924
|
+
if (__hasMask !== parent.__hasMask)
|
|
3925
|
+
parent.forceUpdate();
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3913
3928
|
function doVisible(leaf, key, value, oldValue) {
|
|
3914
3929
|
if (leaf.__setAttr(key, value)) {
|
|
3915
3930
|
leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
|
|
@@ -4048,11 +4063,11 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
4048
4063
|
}
|
|
4049
4064
|
|
|
4050
4065
|
const debug$8 = new Debug('rewrite');
|
|
4051
|
-
const list
|
|
4066
|
+
const list = [];
|
|
4052
4067
|
const excludeNames = ['destroy', 'constructor'];
|
|
4053
4068
|
function rewrite(method) {
|
|
4054
4069
|
return (target, key) => {
|
|
4055
|
-
list
|
|
4070
|
+
list.push({ name: target.constructor.name + '.' + key, run: () => { target[key] = method; } });
|
|
4056
4071
|
};
|
|
4057
4072
|
}
|
|
4058
4073
|
function rewriteAble() {
|
|
@@ -4061,13 +4076,13 @@ function rewriteAble() {
|
|
|
4061
4076
|
};
|
|
4062
4077
|
}
|
|
4063
4078
|
function doRewrite(error) {
|
|
4064
|
-
if (list
|
|
4065
|
-
list
|
|
4079
|
+
if (list.length) {
|
|
4080
|
+
list.forEach(item => {
|
|
4066
4081
|
if (error)
|
|
4067
4082
|
debug$8.error(item.name, '需在Class上装饰@rewriteAble()');
|
|
4068
4083
|
item.run();
|
|
4069
4084
|
});
|
|
4070
|
-
list
|
|
4085
|
+
list.length = 0;
|
|
4071
4086
|
}
|
|
4072
4087
|
}
|
|
4073
4088
|
setTimeout(() => doRewrite(true));
|
|
@@ -4165,20 +4180,17 @@ const LeafHelper = {
|
|
|
4165
4180
|
}
|
|
4166
4181
|
return true;
|
|
4167
4182
|
},
|
|
4168
|
-
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4183
|
+
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4169
4184
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4170
4185
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4171
|
-
L.moveLocal(t, local.x, local.y);
|
|
4186
|
+
L.moveLocal(t, local.x, local.y, transition);
|
|
4172
4187
|
},
|
|
4173
|
-
moveLocal(t, x, y = 0) {
|
|
4174
|
-
if (typeof x === 'object')
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
t.x += x;
|
|
4180
|
-
t.y += y;
|
|
4181
|
-
}
|
|
4188
|
+
moveLocal(t, x, y = 0, transition) {
|
|
4189
|
+
if (typeof x === 'object')
|
|
4190
|
+
y = x.y, x = x.x;
|
|
4191
|
+
x += t.x;
|
|
4192
|
+
y += t.y;
|
|
4193
|
+
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4182
4194
|
},
|
|
4183
4195
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4184
4196
|
L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -5437,8 +5449,8 @@ let Leaf = class Leaf {
|
|
|
5437
5449
|
canvas.clearRect(r.x, r.y, r.width, r.height);
|
|
5438
5450
|
canvas.restore();
|
|
5439
5451
|
}
|
|
5440
|
-
__updateMask(
|
|
5441
|
-
this.__hasMask =
|
|
5452
|
+
__updateMask(_value) {
|
|
5453
|
+
this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
|
|
5442
5454
|
}
|
|
5443
5455
|
__renderMask(_canvas, _options) { }
|
|
5444
5456
|
__getNowWorld(options) {
|
|
@@ -5558,11 +5570,11 @@ let Leaf = class Leaf {
|
|
|
5558
5570
|
transform(matrix, resize) {
|
|
5559
5571
|
transform(this, matrix, resize);
|
|
5560
5572
|
}
|
|
5561
|
-
move(x, y) {
|
|
5562
|
-
moveLocal(this, x, y);
|
|
5573
|
+
move(x, y, transition) {
|
|
5574
|
+
moveLocal(this, x, y, transition);
|
|
5563
5575
|
}
|
|
5564
|
-
moveInner(x, y) {
|
|
5565
|
-
moveWorld(this, x, y, true);
|
|
5576
|
+
moveInner(x, y, transition) {
|
|
5577
|
+
moveWorld(this, x, y, true, transition);
|
|
5566
5578
|
}
|
|
5567
5579
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5568
5580
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
@@ -5576,8 +5588,8 @@ let Leaf = class Leaf {
|
|
|
5576
5588
|
transformWorld(worldTransform, resize) {
|
|
5577
5589
|
transformWorld(this, worldTransform, resize);
|
|
5578
5590
|
}
|
|
5579
|
-
moveWorld(x, y) {
|
|
5580
|
-
moveWorld(this, x, y);
|
|
5591
|
+
moveWorld(x, y, transition) {
|
|
5592
|
+
moveWorld(this, x, y, false, transition);
|
|
5581
5593
|
}
|
|
5582
5594
|
scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
|
|
5583
5595
|
zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
|
|
@@ -5681,6 +5693,7 @@ Leaf = __decorate([
|
|
|
5681
5693
|
const { setListWithFn } = BoundsHelper;
|
|
5682
5694
|
const { sort } = BranchHelper;
|
|
5683
5695
|
const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
|
|
5696
|
+
const debug$6 = new Debug('Branch');
|
|
5684
5697
|
let Branch = class Branch extends Leaf {
|
|
5685
5698
|
__updateStrokeSpread() {
|
|
5686
5699
|
const { children } = this;
|
|
@@ -5721,8 +5734,8 @@ let Branch = class Branch extends Leaf {
|
|
|
5721
5734
|
}
|
|
5722
5735
|
}
|
|
5723
5736
|
add(child, index) {
|
|
5724
|
-
if (child === this)
|
|
5725
|
-
return;
|
|
5737
|
+
if (child === this || child.destroyed)
|
|
5738
|
+
return debug$6.warn('add self or destroyed');
|
|
5726
5739
|
const noIndex = index === undefined;
|
|
5727
5740
|
if (!child.__) {
|
|
5728
5741
|
if (child instanceof Array)
|
|
@@ -5736,8 +5749,9 @@ let Branch = class Branch extends Leaf {
|
|
|
5736
5749
|
noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
|
|
5737
5750
|
if (child.isBranch)
|
|
5738
5751
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5739
|
-
|
|
5740
|
-
|
|
5752
|
+
const childLayout = child.__layout;
|
|
5753
|
+
childLayout.boxChanged || childLayout.boxChange();
|
|
5754
|
+
childLayout.matrixChanged || childLayout.matrixChange();
|
|
5741
5755
|
if (child.__bubbleMap)
|
|
5742
5756
|
child.__emitLifeEvent(ChildEvent.ADD);
|
|
5743
5757
|
if (this.leafer) {
|
|
@@ -5975,7 +5989,7 @@ class LeafLevelList {
|
|
|
5975
5989
|
}
|
|
5976
5990
|
}
|
|
5977
5991
|
|
|
5978
|
-
const version = "1.
|
|
5992
|
+
const version = "1.1.1";
|
|
5979
5993
|
|
|
5980
5994
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5981
5995
|
get allowBackgroundColor() { return true; }
|
|
@@ -6249,7 +6263,7 @@ class LayoutBlockData {
|
|
|
6249
6263
|
}
|
|
6250
6264
|
|
|
6251
6265
|
const { updateAllMatrix, updateAllChange } = LeafHelper;
|
|
6252
|
-
const debug$
|
|
6266
|
+
const debug$5 = Debug.get('Layouter');
|
|
6253
6267
|
class Layouter {
|
|
6254
6268
|
constructor(target, userConfig) {
|
|
6255
6269
|
this.totalTimes = 0;
|
|
@@ -6284,7 +6298,7 @@ class Layouter {
|
|
|
6284
6298
|
target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
|
|
6285
6299
|
}
|
|
6286
6300
|
catch (e) {
|
|
6287
|
-
debug$
|
|
6301
|
+
debug$5.error(e);
|
|
6288
6302
|
}
|
|
6289
6303
|
this.layoutedBlocks = null;
|
|
6290
6304
|
}
|
|
@@ -6298,9 +6312,9 @@ class Layouter {
|
|
|
6298
6312
|
}
|
|
6299
6313
|
layoutOnce() {
|
|
6300
6314
|
if (this.layouting)
|
|
6301
|
-
return debug$
|
|
6315
|
+
return debug$5.warn('layouting');
|
|
6302
6316
|
if (this.times > 3)
|
|
6303
|
-
return debug$
|
|
6317
|
+
return debug$5.warn('layout max times');
|
|
6304
6318
|
this.times++;
|
|
6305
6319
|
this.totalTimes++;
|
|
6306
6320
|
this.layouting = true;
|
|
@@ -6404,7 +6418,7 @@ class Layouter {
|
|
|
6404
6418
|
}
|
|
6405
6419
|
}
|
|
6406
6420
|
|
|
6407
|
-
const debug$
|
|
6421
|
+
const debug$4 = Debug.get('Renderer');
|
|
6408
6422
|
class Renderer {
|
|
6409
6423
|
get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
|
|
6410
6424
|
constructor(target, canvas, userConfig) {
|
|
@@ -6420,29 +6434,29 @@ class Renderer {
|
|
|
6420
6434
|
if (userConfig)
|
|
6421
6435
|
this.config = DataHelper.default(userConfig, this.config);
|
|
6422
6436
|
this.__listenEvents();
|
|
6423
|
-
this.__requestRender();
|
|
6424
6437
|
}
|
|
6425
6438
|
start() {
|
|
6426
6439
|
this.running = true;
|
|
6440
|
+
this.update(false);
|
|
6427
6441
|
}
|
|
6428
6442
|
stop() {
|
|
6429
6443
|
this.running = false;
|
|
6430
6444
|
}
|
|
6431
|
-
update() {
|
|
6432
|
-
this.changed
|
|
6445
|
+
update(change = true) {
|
|
6446
|
+
if (!this.changed)
|
|
6447
|
+
this.changed = change;
|
|
6448
|
+
this.__requestRender();
|
|
6433
6449
|
}
|
|
6434
6450
|
requestLayout() {
|
|
6435
6451
|
this.target.emit(LayoutEvent.REQUEST);
|
|
6436
6452
|
}
|
|
6437
6453
|
render(callback) {
|
|
6438
|
-
if (!(this.running && this.canvas.view))
|
|
6439
|
-
this.
|
|
6440
|
-
return;
|
|
6441
|
-
}
|
|
6454
|
+
if (!(this.running && this.canvas.view))
|
|
6455
|
+
return this.update();
|
|
6442
6456
|
const { target } = this;
|
|
6443
6457
|
this.times = 0;
|
|
6444
6458
|
this.totalBounds = new Bounds();
|
|
6445
|
-
debug$
|
|
6459
|
+
debug$4.log(target.innerName, '--->');
|
|
6446
6460
|
try {
|
|
6447
6461
|
if (!target.isApp)
|
|
6448
6462
|
target.app.emit(RenderEvent.CHILD_START, target);
|
|
@@ -6453,9 +6467,9 @@ class Renderer {
|
|
|
6453
6467
|
}
|
|
6454
6468
|
catch (e) {
|
|
6455
6469
|
this.rendering = false;
|
|
6456
|
-
debug$
|
|
6470
|
+
debug$4.error(e);
|
|
6457
6471
|
}
|
|
6458
|
-
debug$
|
|
6472
|
+
debug$4.log('-------------|');
|
|
6459
6473
|
}
|
|
6460
6474
|
renderAgain() {
|
|
6461
6475
|
if (this.rendering) {
|
|
@@ -6467,9 +6481,9 @@ class Renderer {
|
|
|
6467
6481
|
}
|
|
6468
6482
|
renderOnce(callback) {
|
|
6469
6483
|
if (this.rendering)
|
|
6470
|
-
return debug$
|
|
6484
|
+
return debug$4.warn('rendering');
|
|
6471
6485
|
if (this.times > 3)
|
|
6472
|
-
return debug$
|
|
6486
|
+
return debug$4.warn('render max times');
|
|
6473
6487
|
this.times++;
|
|
6474
6488
|
this.totalTimes++;
|
|
6475
6489
|
this.rendering = true;
|
|
@@ -6506,7 +6520,7 @@ class Renderer {
|
|
|
6506
6520
|
partRender() {
|
|
6507
6521
|
const { canvas, updateBlocks: list } = this;
|
|
6508
6522
|
if (!list)
|
|
6509
|
-
return debug$
|
|
6523
|
+
return debug$4.warn('PartRender: need update attr');
|
|
6510
6524
|
this.mergeBlocks();
|
|
6511
6525
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6512
6526
|
this.clipRender(block); });
|
|
@@ -6572,16 +6586,17 @@ class Renderer {
|
|
|
6572
6586
|
}
|
|
6573
6587
|
}
|
|
6574
6588
|
__requestRender() {
|
|
6575
|
-
|
|
6589
|
+
if (this.requestTime)
|
|
6590
|
+
return;
|
|
6591
|
+
const requestTime = this.requestTime = Date.now();
|
|
6576
6592
|
Platform.requestRender(() => {
|
|
6577
|
-
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() -
|
|
6593
|
+
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
6594
|
+
this.requestTime = 0;
|
|
6578
6595
|
if (this.running) {
|
|
6579
6596
|
if (this.changed && this.canvas.view)
|
|
6580
6597
|
this.render();
|
|
6581
6598
|
this.target.emit(RenderEvent.NEXT);
|
|
6582
6599
|
}
|
|
6583
|
-
if (this.target)
|
|
6584
|
-
this.__requestRender();
|
|
6585
6600
|
});
|
|
6586
6601
|
}
|
|
6587
6602
|
__onResize(e) {
|
|
@@ -6597,7 +6612,7 @@ class Renderer {
|
|
|
6597
6612
|
}
|
|
6598
6613
|
}
|
|
6599
6614
|
this.addBlock(new Bounds(0, 0, 1, 1));
|
|
6600
|
-
this.
|
|
6615
|
+
this.update();
|
|
6601
6616
|
}
|
|
6602
6617
|
__onLayoutEnd(event) {
|
|
6603
6618
|
if (event.data)
|
|
@@ -6608,7 +6623,7 @@ class Renderer {
|
|
|
6608
6623
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
6609
6624
|
if (empty) {
|
|
6610
6625
|
if (!leaf.isLeafer)
|
|
6611
|
-
debug$
|
|
6626
|
+
debug$4.tip(leaf.innerName, ': empty');
|
|
6612
6627
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
6613
6628
|
}
|
|
6614
6629
|
return empty;
|
|
@@ -6983,7 +6998,7 @@ const Transition = {
|
|
|
6983
6998
|
|
|
6984
6999
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6985
7000
|
const emptyPaint = {};
|
|
6986
|
-
const debug$
|
|
7001
|
+
const debug$3 = Debug.get('UIData');
|
|
6987
7002
|
class UIData extends LeafData {
|
|
6988
7003
|
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
6989
7004
|
get __strokeWidth() {
|
|
@@ -7005,7 +7020,7 @@ class UIData extends LeafData {
|
|
|
7005
7020
|
return true;
|
|
7006
7021
|
return t.fill && this.__hasStroke;
|
|
7007
7022
|
}
|
|
7008
|
-
get __clipAfterFill() { return (
|
|
7023
|
+
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
7009
7024
|
get __autoWidth() { return !this._width; }
|
|
7010
7025
|
get __autoHeight() { return !this._height; }
|
|
7011
7026
|
get __autoSide() { return !this._width || !this._height; }
|
|
@@ -7020,7 +7035,7 @@ class UIData extends LeafData {
|
|
|
7020
7035
|
if (value < 0) {
|
|
7021
7036
|
this._width = -value;
|
|
7022
7037
|
this.__leaf.scaleX *= -1;
|
|
7023
|
-
debug$
|
|
7038
|
+
debug$3.warn('width < 0, instead -scaleX ', this);
|
|
7024
7039
|
}
|
|
7025
7040
|
else
|
|
7026
7041
|
this._width = value;
|
|
@@ -7029,7 +7044,7 @@ class UIData extends LeafData {
|
|
|
7029
7044
|
if (value < 0) {
|
|
7030
7045
|
this._height = -value;
|
|
7031
7046
|
this.__leaf.scaleY *= -1;
|
|
7032
|
-
debug$
|
|
7047
|
+
debug$3.warn('height < 0, instead -scaleY', this);
|
|
7033
7048
|
}
|
|
7034
7049
|
else
|
|
7035
7050
|
this._height = value;
|
|
@@ -7119,7 +7134,7 @@ class GroupData extends UIData {
|
|
|
7119
7134
|
|
|
7120
7135
|
class BoxData extends GroupData {
|
|
7121
7136
|
get __boxStroke() { return !this.__pathInputed; }
|
|
7122
|
-
get __drawAfterFill() { return
|
|
7137
|
+
get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
|
|
7123
7138
|
get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
|
|
7124
7139
|
}
|
|
7125
7140
|
|
|
@@ -7405,11 +7420,15 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7405
7420
|
super(data);
|
|
7406
7421
|
}
|
|
7407
7422
|
reset(_data) { }
|
|
7408
|
-
set(data,
|
|
7409
|
-
if (
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7423
|
+
set(data, transition) {
|
|
7424
|
+
if (transition) {
|
|
7425
|
+
if (transition === 'temp') {
|
|
7426
|
+
this.lockNormalStyle = true;
|
|
7427
|
+
Object.assign(this, data);
|
|
7428
|
+
this.lockNormalStyle = false;
|
|
7429
|
+
}
|
|
7430
|
+
else
|
|
7431
|
+
this.animate(data, transition);
|
|
7413
7432
|
}
|
|
7414
7433
|
else
|
|
7415
7434
|
Object.assign(this, data);
|
|
@@ -7719,17 +7738,17 @@ let Group = class Group extends UI {
|
|
|
7719
7738
|
if (!this.children)
|
|
7720
7739
|
this.children = [];
|
|
7721
7740
|
}
|
|
7722
|
-
set(data,
|
|
7741
|
+
set(data, transition) {
|
|
7723
7742
|
if (data.children) {
|
|
7724
7743
|
const { children } = data;
|
|
7725
7744
|
delete data.children;
|
|
7726
7745
|
this.children ? this.clear() : this.__setBranch();
|
|
7727
|
-
super.set(data,
|
|
7746
|
+
super.set(data, transition);
|
|
7728
7747
|
children.forEach(child => this.add(child));
|
|
7729
7748
|
data.children = children;
|
|
7730
7749
|
}
|
|
7731
7750
|
else
|
|
7732
|
-
super.set(data,
|
|
7751
|
+
super.set(data, transition);
|
|
7733
7752
|
}
|
|
7734
7753
|
toJSON(options) {
|
|
7735
7754
|
const data = super.toJSON(options);
|
|
@@ -7761,7 +7780,7 @@ Group = __decorate([
|
|
|
7761
7780
|
], Group);
|
|
7762
7781
|
|
|
7763
7782
|
var Leafer_1;
|
|
7764
|
-
const debug$
|
|
7783
|
+
const debug$2 = Debug.get('Leafer');
|
|
7765
7784
|
let Leafer = Leafer_1 = class Leafer extends Group {
|
|
7766
7785
|
get __tag() { return 'Leafer'; }
|
|
7767
7786
|
get isApp() { return false; }
|
|
@@ -7775,20 +7794,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7775
7794
|
constructor(userConfig, data) {
|
|
7776
7795
|
super(data);
|
|
7777
7796
|
this.config = {
|
|
7778
|
-
type: 'design',
|
|
7779
7797
|
start: true,
|
|
7780
7798
|
hittable: true,
|
|
7781
7799
|
smooth: true,
|
|
7782
|
-
lazySpeard: 100
|
|
7783
|
-
zoom: {
|
|
7784
|
-
min: 0.01,
|
|
7785
|
-
max: 256
|
|
7786
|
-
},
|
|
7787
|
-
move: {
|
|
7788
|
-
holdSpaceKey: true,
|
|
7789
|
-
holdMiddleKey: true,
|
|
7790
|
-
autoDistance: 2
|
|
7791
|
-
}
|
|
7800
|
+
lazySpeard: 100
|
|
7792
7801
|
};
|
|
7793
7802
|
this.leafs = 0;
|
|
7794
7803
|
this.__eventIds = [];
|
|
@@ -7805,23 +7814,27 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7805
7814
|
init(userConfig, parentApp) {
|
|
7806
7815
|
if (this.canvas)
|
|
7807
7816
|
return;
|
|
7808
|
-
this.__setLeafer(this);
|
|
7809
|
-
if (userConfig)
|
|
7810
|
-
DataHelper.assign(this.config, userConfig);
|
|
7811
7817
|
let start;
|
|
7812
7818
|
const { config } = this;
|
|
7813
|
-
this.
|
|
7819
|
+
this.__setLeafer(this);
|
|
7820
|
+
if (parentApp) {
|
|
7821
|
+
this.parentApp = parentApp;
|
|
7822
|
+
this.__bindApp(parentApp);
|
|
7823
|
+
start = parentApp.running;
|
|
7824
|
+
}
|
|
7825
|
+
if (userConfig) {
|
|
7826
|
+
this.parent = parentApp;
|
|
7827
|
+
this.initType(userConfig.type);
|
|
7828
|
+
this.parent = undefined;
|
|
7829
|
+
DataHelper.assign(config, userConfig);
|
|
7830
|
+
}
|
|
7814
7831
|
const canvas = this.canvas = Creator.canvas(config);
|
|
7815
7832
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7816
7833
|
if (this.isApp)
|
|
7817
7834
|
this.__setApp();
|
|
7818
7835
|
this.__checkAutoLayout(config, parentApp);
|
|
7819
7836
|
this.view = canvas.view;
|
|
7820
|
-
if (parentApp) {
|
|
7821
|
-
this.__bindApp(parentApp);
|
|
7822
|
-
start = parentApp.running;
|
|
7823
|
-
}
|
|
7824
|
-
else {
|
|
7837
|
+
if (!parentApp) {
|
|
7825
7838
|
this.selector = Creator.selector(this);
|
|
7826
7839
|
this.interaction = Creator.interaction(this, canvas, this.selector, config);
|
|
7827
7840
|
if (this.interaction) {
|
|
@@ -7842,8 +7855,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7842
7855
|
}
|
|
7843
7856
|
onInit() { }
|
|
7844
7857
|
initType(_type) { }
|
|
7845
|
-
set(data) {
|
|
7846
|
-
this.waitInit(() => { super.set(data); });
|
|
7858
|
+
set(data, transition) {
|
|
7859
|
+
this.waitInit(() => { super.set(data, transition); });
|
|
7847
7860
|
}
|
|
7848
7861
|
start() {
|
|
7849
7862
|
clearTimeout(this.__startTimer);
|
|
@@ -7878,7 +7891,11 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7878
7891
|
forceRender(bounds) {
|
|
7879
7892
|
this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
|
|
7880
7893
|
if (this.viewReady)
|
|
7881
|
-
this.renderer.
|
|
7894
|
+
this.renderer.render();
|
|
7895
|
+
}
|
|
7896
|
+
requestRender(change = false) {
|
|
7897
|
+
if (this.renderer)
|
|
7898
|
+
this.renderer.update(change);
|
|
7882
7899
|
}
|
|
7883
7900
|
updateCursor(cursor) {
|
|
7884
7901
|
const i = this.interaction;
|
|
@@ -7925,7 +7942,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7925
7942
|
if (this.canvas) {
|
|
7926
7943
|
if (canvasSizeAttrs.includes(attrName)) {
|
|
7927
7944
|
if (!newValue)
|
|
7928
|
-
debug$
|
|
7945
|
+
debug$2.warn(attrName + ' is 0');
|
|
7929
7946
|
this.__changeCanvasSize(attrName, newValue);
|
|
7930
7947
|
}
|
|
7931
7948
|
else if (attrName === 'fill') {
|
|
@@ -7986,8 +8003,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7986
8003
|
const { imageReady } = this;
|
|
7987
8004
|
if (imageReady && !this.viewCompleted)
|
|
7988
8005
|
this.__checkViewCompleted();
|
|
7989
|
-
if (!imageReady)
|
|
8006
|
+
if (!imageReady) {
|
|
7990
8007
|
this.viewCompleted = false;
|
|
8008
|
+
this.requestRender();
|
|
8009
|
+
}
|
|
7991
8010
|
}
|
|
7992
8011
|
}
|
|
7993
8012
|
__checkViewCompleted(emit = true) {
|
|
@@ -8045,6 +8064,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8045
8064
|
}
|
|
8046
8065
|
else
|
|
8047
8066
|
list.push(item);
|
|
8067
|
+
this.requestRender();
|
|
8048
8068
|
}
|
|
8049
8069
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
8050
8070
|
return needPlugin('view');
|
|
@@ -8098,14 +8118,14 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8098
8118
|
this.canvasManager.destroy();
|
|
8099
8119
|
}
|
|
8100
8120
|
this.canvas.destroy();
|
|
8101
|
-
this.config.view = this.view = null;
|
|
8121
|
+
this.config.view = this.view = this.parentApp = null;
|
|
8102
8122
|
if (this.userConfig)
|
|
8103
8123
|
this.userConfig.view = null;
|
|
8104
8124
|
super.destroy();
|
|
8105
8125
|
setTimeout(() => { ImageManager.clearRecycled(); }, 100);
|
|
8106
8126
|
}
|
|
8107
8127
|
catch (e) {
|
|
8108
|
-
debug$
|
|
8128
|
+
debug$2.error(e);
|
|
8109
8129
|
}
|
|
8110
8130
|
}
|
|
8111
8131
|
};
|
|
@@ -8825,9 +8845,9 @@ let App = class App extends Leafer {
|
|
|
8825
8845
|
if (ground)
|
|
8826
8846
|
this.ground = this.addLeafer(ground);
|
|
8827
8847
|
if (tree || editor)
|
|
8828
|
-
this.tree = this.addLeafer(tree);
|
|
8848
|
+
this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
|
|
8829
8849
|
if (sky || editor)
|
|
8830
|
-
this.sky = this.addLeafer(sky
|
|
8850
|
+
this.sky = this.addLeafer(sky);
|
|
8831
8851
|
if (editor)
|
|
8832
8852
|
this.sky.add(this.editor = Creator.editor(editor));
|
|
8833
8853
|
}
|
|
@@ -9032,10 +9052,8 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9032
9052
|
this.data = data;
|
|
9033
9053
|
}
|
|
9034
9054
|
static getValidMove(leaf, start, total) {
|
|
9035
|
-
const { draggable, dragBounds
|
|
9036
|
-
|
|
9037
|
-
move.x += start.x - x;
|
|
9038
|
-
move.y += start.y - y;
|
|
9055
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9056
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9039
9057
|
if (dragBounds)
|
|
9040
9058
|
this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9041
9059
|
if (draggable === 'x')
|
|
@@ -9045,8 +9063,7 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9045
9063
|
return move;
|
|
9046
9064
|
}
|
|
9047
9065
|
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9048
|
-
const x = childBox.x + move.x, y = childBox.y + move.y;
|
|
9049
|
-
const right = x + childBox.width, bottom = y + childBox.height;
|
|
9066
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9050
9067
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9051
9068
|
if (!change)
|
|
9052
9069
|
move = Object.assign({}, move);
|
|
@@ -9098,9 +9115,7 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9098
9115
|
return this.getLocalMove(relative, true);
|
|
9099
9116
|
}
|
|
9100
9117
|
getPageBounds() {
|
|
9101
|
-
const total = this.getPageTotal();
|
|
9102
|
-
const start = this.getPagePoint();
|
|
9103
|
-
const bounds = {};
|
|
9118
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9104
9119
|
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9105
9120
|
BoundsHelper.unsign(bounds);
|
|
9106
9121
|
return bounds;
|
|
@@ -9186,184 +9201,7 @@ KeyEvent = __decorate([
|
|
|
9186
9201
|
registerUIEvent()
|
|
9187
9202
|
], KeyEvent);
|
|
9188
9203
|
|
|
9189
|
-
function addInteractionWindow(leafer) {
|
|
9190
|
-
if (leafer.isApp)
|
|
9191
|
-
return;
|
|
9192
|
-
leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => {
|
|
9193
|
-
leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
|
|
9194
|
-
}), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
|
|
9195
|
-
const { zoomLayer } = leafer;
|
|
9196
|
-
const changeScale = leafer.getValidScale(e.scale);
|
|
9197
|
-
if (changeScale !== 1) {
|
|
9198
|
-
PointHelper.scaleOf(zoomLayer, e, changeScale);
|
|
9199
|
-
zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
|
|
9200
|
-
}
|
|
9201
|
-
}));
|
|
9202
|
-
}
|
|
9203
|
-
|
|
9204
|
-
function document(leafer) {
|
|
9205
|
-
addInteractionWindow(leafer);
|
|
9206
|
-
const { move, zoom } = leafer.config;
|
|
9207
|
-
move.scroll = 'limit';
|
|
9208
|
-
zoom.min = 1;
|
|
9209
|
-
}
|
|
9210
|
-
|
|
9211
|
-
function block(leafer) {
|
|
9212
|
-
const { config } = leafer;
|
|
9213
|
-
(config.wheel || (config.wheel = {})).preventDefault = false;
|
|
9214
|
-
(config.touch || (config.touch = {})).preventDefault = 'auto';
|
|
9215
|
-
}
|
|
9216
|
-
|
|
9217
|
-
const debug$2 = Debug.get('LeaferTypeCreator');
|
|
9218
|
-
const LeaferTypeCreator = {
|
|
9219
|
-
list: {},
|
|
9220
|
-
register(name, fn) {
|
|
9221
|
-
list[name] && debug$2.repeat(name);
|
|
9222
|
-
list[name] = fn;
|
|
9223
|
-
},
|
|
9224
|
-
run(name, leafer) {
|
|
9225
|
-
const fn = list[name];
|
|
9226
|
-
fn && fn(leafer);
|
|
9227
|
-
}
|
|
9228
|
-
};
|
|
9229
|
-
const { list, register } = LeaferTypeCreator;
|
|
9230
|
-
register('design', addInteractionWindow);
|
|
9231
|
-
register('document', document);
|
|
9232
|
-
register('block', block);
|
|
9233
|
-
|
|
9234
|
-
const leafer = Leafer.prototype;
|
|
9235
|
-
leafer.initType = function (type) {
|
|
9236
|
-
LeaferTypeCreator.run(type, this);
|
|
9237
|
-
};
|
|
9238
|
-
leafer.getValidMove = function (moveX, moveY) {
|
|
9239
|
-
const { scroll, disabled } = this.app.config.move;
|
|
9240
|
-
if (scroll) {
|
|
9241
|
-
Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
|
|
9242
|
-
if (scroll === 'limit') {
|
|
9243
|
-
const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
|
|
9244
|
-
const right = x + width - this.width, bottom = y + height - this.height;
|
|
9245
|
-
if (x >= 0 && right <= 0)
|
|
9246
|
-
moveX = 0;
|
|
9247
|
-
else if (moveX > 0) {
|
|
9248
|
-
if (x + moveX > 0)
|
|
9249
|
-
moveX = -x;
|
|
9250
|
-
}
|
|
9251
|
-
else if (moveX < 0 && right + moveX < 0)
|
|
9252
|
-
moveX = -right;
|
|
9253
|
-
if (y >= 0 && bottom <= 0)
|
|
9254
|
-
moveY = 0;
|
|
9255
|
-
else if (moveY > 0) {
|
|
9256
|
-
if (y + moveY > 0)
|
|
9257
|
-
moveY = -y;
|
|
9258
|
-
}
|
|
9259
|
-
else if (moveY < 0 && bottom + moveY < 0)
|
|
9260
|
-
moveY = -bottom;
|
|
9261
|
-
}
|
|
9262
|
-
}
|
|
9263
|
-
return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
|
|
9264
|
-
};
|
|
9265
|
-
leafer.getValidScale = function (changeScale) {
|
|
9266
|
-
const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
|
|
9267
|
-
if (absScale < min)
|
|
9268
|
-
changeScale = min / scaleX;
|
|
9269
|
-
else if (absScale > max)
|
|
9270
|
-
changeScale = max / scaleX;
|
|
9271
|
-
return disabled ? 1 : changeScale;
|
|
9272
|
-
};
|
|
9273
|
-
|
|
9274
|
-
class Transformer {
|
|
9275
|
-
get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
|
|
9276
|
-
constructor(interaction) {
|
|
9277
|
-
this.interaction = interaction;
|
|
9278
|
-
}
|
|
9279
|
-
move(data) {
|
|
9280
|
-
const { interaction } = this;
|
|
9281
|
-
if (!data.moveType)
|
|
9282
|
-
data.moveType = 'move';
|
|
9283
|
-
if (!this.moveData) {
|
|
9284
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9285
|
-
data.path = path;
|
|
9286
|
-
this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
|
|
9287
|
-
interaction.cancelHover();
|
|
9288
|
-
interaction.emit(MoveEvent.START, this.moveData);
|
|
9289
|
-
}
|
|
9290
|
-
data.path = this.moveData.path;
|
|
9291
|
-
interaction.emit(MoveEvent.BEFORE_MOVE, data);
|
|
9292
|
-
interaction.emit(MoveEvent.MOVE, data);
|
|
9293
|
-
this.transformEndWait();
|
|
9294
|
-
}
|
|
9295
|
-
zoom(data) {
|
|
9296
|
-
const { interaction } = this;
|
|
9297
|
-
if (!this.zoomData) {
|
|
9298
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9299
|
-
data.path = path;
|
|
9300
|
-
this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
|
|
9301
|
-
interaction.cancelHover();
|
|
9302
|
-
interaction.emit(ZoomEvent.START, this.zoomData);
|
|
9303
|
-
}
|
|
9304
|
-
data.path = this.zoomData.path;
|
|
9305
|
-
interaction.emit(ZoomEvent.BEFORE_ZOOM, data);
|
|
9306
|
-
interaction.emit(ZoomEvent.ZOOM, data);
|
|
9307
|
-
this.transformEndWait();
|
|
9308
|
-
}
|
|
9309
|
-
rotate(data) {
|
|
9310
|
-
const { interaction } = this;
|
|
9311
|
-
if (!this.rotateData) {
|
|
9312
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9313
|
-
data.path = path;
|
|
9314
|
-
this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
|
|
9315
|
-
interaction.cancelHover();
|
|
9316
|
-
interaction.emit(RotateEvent.START, this.rotateData);
|
|
9317
|
-
}
|
|
9318
|
-
data.path = this.rotateData.path;
|
|
9319
|
-
interaction.emit(RotateEvent.BEFORE_ROTATE, data);
|
|
9320
|
-
interaction.emit(RotateEvent.ROTATE, data);
|
|
9321
|
-
this.transformEndWait();
|
|
9322
|
-
}
|
|
9323
|
-
transformEndWait() {
|
|
9324
|
-
clearTimeout(this.transformTimer);
|
|
9325
|
-
this.transformTimer = setTimeout(() => {
|
|
9326
|
-
this.transformEnd();
|
|
9327
|
-
}, this.interaction.config.pointer.transformTime);
|
|
9328
|
-
}
|
|
9329
|
-
transformEnd() {
|
|
9330
|
-
this.moveEnd();
|
|
9331
|
-
this.zoomEnd();
|
|
9332
|
-
this.rotateEnd();
|
|
9333
|
-
}
|
|
9334
|
-
moveEnd() {
|
|
9335
|
-
if (this.moveData) {
|
|
9336
|
-
this.interaction.emit(MoveEvent.END, this.moveData);
|
|
9337
|
-
this.moveData = null;
|
|
9338
|
-
}
|
|
9339
|
-
}
|
|
9340
|
-
zoomEnd() {
|
|
9341
|
-
if (this.zoomData) {
|
|
9342
|
-
this.interaction.emit(ZoomEvent.END, this.zoomData);
|
|
9343
|
-
this.zoomData = null;
|
|
9344
|
-
}
|
|
9345
|
-
}
|
|
9346
|
-
rotateEnd() {
|
|
9347
|
-
if (this.rotateData) {
|
|
9348
|
-
this.interaction.emit(RotateEvent.END, this.rotateData);
|
|
9349
|
-
this.rotateData = null;
|
|
9350
|
-
}
|
|
9351
|
-
}
|
|
9352
|
-
destroy() {
|
|
9353
|
-
this.zoomData = this.moveData = this.rotateData = null;
|
|
9354
|
-
}
|
|
9355
|
-
}
|
|
9356
|
-
|
|
9357
9204
|
const InteractionHelper = {
|
|
9358
|
-
getMoveEventData(center, move, event) {
|
|
9359
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, moveX: move.x, moveY: move.y });
|
|
9360
|
-
},
|
|
9361
|
-
getRotateEventData(center, angle, event) {
|
|
9362
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, rotation: angle });
|
|
9363
|
-
},
|
|
9364
|
-
getZoomEventData(center, scale, event) {
|
|
9365
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, scale });
|
|
9366
|
-
},
|
|
9367
9205
|
getDragEventData(startPoint, lastPoint, event) {
|
|
9368
9206
|
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 });
|
|
9369
9207
|
},
|
|
@@ -9372,18 +9210,14 @@ const InteractionHelper = {
|
|
|
9372
9210
|
data });
|
|
9373
9211
|
},
|
|
9374
9212
|
getSwipeDirection(angle) {
|
|
9375
|
-
if (angle < -45 && angle > -135)
|
|
9213
|
+
if (angle < -45 && angle > -135)
|
|
9376
9214
|
return SwipeEvent.UP;
|
|
9377
|
-
|
|
9378
|
-
else if (angle > 45 && angle < 135) {
|
|
9215
|
+
else if (angle > 45 && angle < 135)
|
|
9379
9216
|
return SwipeEvent.DOWN;
|
|
9380
|
-
|
|
9381
|
-
else if (angle <= 45 && angle >= -45) {
|
|
9217
|
+
else if (angle <= 45 && angle >= -45)
|
|
9382
9218
|
return SwipeEvent.RIGHT;
|
|
9383
|
-
|
|
9384
|
-
else {
|
|
9219
|
+
else
|
|
9385
9220
|
return SwipeEvent.LEFT;
|
|
9386
|
-
}
|
|
9387
9221
|
},
|
|
9388
9222
|
getSwipeEventData(startPoint, lastDragData, event) {
|
|
9389
9223
|
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(PointHelper.getAngle(startPoint, event)) });
|
|
@@ -9456,9 +9290,8 @@ class Dragger {
|
|
|
9456
9290
|
interaction.emit(MoveEvent.START, this.dragData);
|
|
9457
9291
|
}
|
|
9458
9292
|
}
|
|
9459
|
-
if (!this.moving)
|
|
9293
|
+
if (!this.moving)
|
|
9460
9294
|
this.dragStart(data, canDrag);
|
|
9461
|
-
}
|
|
9462
9295
|
this.drag(data);
|
|
9463
9296
|
}
|
|
9464
9297
|
dragStart(data, canDrag) {
|
|
@@ -9536,16 +9369,9 @@ class Dragger {
|
|
|
9536
9369
|
dragEnd(data, speed) {
|
|
9537
9370
|
if (!this.dragging && !this.moving)
|
|
9538
9371
|
return;
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
speed = (speed || (data.pointerType === 'touch' ? 2 : 1)) * 0.9;
|
|
9543
|
-
PointHelper.move(data, moveX * speed, moveY * speed);
|
|
9544
|
-
this.drag(data);
|
|
9545
|
-
this.animate(() => { this.dragEnd(data, 1); });
|
|
9546
|
-
}
|
|
9547
|
-
else
|
|
9548
|
-
this.dragEndReal(data);
|
|
9372
|
+
if (this.checkDragEndAnimate(data, speed))
|
|
9373
|
+
return;
|
|
9374
|
+
this.dragEndReal(data);
|
|
9549
9375
|
}
|
|
9550
9376
|
dragEndReal(data) {
|
|
9551
9377
|
const { interaction, downData, dragData } = this;
|
|
@@ -9572,12 +9398,6 @@ class Dragger {
|
|
|
9572
9398
|
this.dragReset();
|
|
9573
9399
|
this.animate(null, 'off');
|
|
9574
9400
|
}
|
|
9575
|
-
animate(func, off) {
|
|
9576
|
-
const animateWait = func || this.animateWait;
|
|
9577
|
-
if (animateWait)
|
|
9578
|
-
this.interaction.target.nextRender(animateWait, null, off);
|
|
9579
|
-
this.animateWait = func;
|
|
9580
|
-
}
|
|
9581
9401
|
swipe(data, downData, dragData, endDragData) {
|
|
9582
9402
|
const { interaction } = this;
|
|
9583
9403
|
if (PointHelper.getDistance(downData, data) > interaction.config.pointer.swipeDistance) {
|
|
@@ -9594,39 +9414,11 @@ class Dragger {
|
|
|
9594
9414
|
dragReset() {
|
|
9595
9415
|
DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
|
|
9596
9416
|
}
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
}
|
|
9603
|
-
autoMoveOnDragOut(data) {
|
|
9604
|
-
const { interaction, downData, canDragOut } = this;
|
|
9605
|
-
const { autoDistance, dragOut } = interaction.config.move;
|
|
9606
|
-
if (!dragOut || !canDragOut || !autoDistance)
|
|
9607
|
-
return;
|
|
9608
|
-
const bounds = interaction.shrinkCanvasBounds;
|
|
9609
|
-
const { x, y } = bounds;
|
|
9610
|
-
const right = BoundsHelper.maxX(bounds);
|
|
9611
|
-
const bottom = BoundsHelper.maxY(bounds);
|
|
9612
|
-
const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
|
|
9613
|
-
const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
|
|
9614
|
-
let totalX = 0, totalY = 0;
|
|
9615
|
-
this.autoMoveTimer = setInterval(() => {
|
|
9616
|
-
totalX += moveX;
|
|
9617
|
-
totalY += moveY;
|
|
9618
|
-
PointHelper.move(downData, moveX, moveY);
|
|
9619
|
-
PointHelper.move(this.dragData, moveX, moveY);
|
|
9620
|
-
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
|
|
9621
|
-
interaction.pointerMoveReal(data);
|
|
9622
|
-
}, 10);
|
|
9623
|
-
}
|
|
9624
|
-
autoMoveCancel() {
|
|
9625
|
-
if (this.autoMoveTimer) {
|
|
9626
|
-
clearInterval(this.autoMoveTimer);
|
|
9627
|
-
this.autoMoveTimer = 0;
|
|
9628
|
-
}
|
|
9629
|
-
}
|
|
9417
|
+
checkDragEndAnimate(_data, _speed) { return false; }
|
|
9418
|
+
animate(_func, _off) { }
|
|
9419
|
+
checkDragOut(_data) { }
|
|
9420
|
+
autoMoveOnDragOut(_data) { }
|
|
9421
|
+
autoMoveCancel() { }
|
|
9630
9422
|
destroy() {
|
|
9631
9423
|
this.dragReset();
|
|
9632
9424
|
}
|
|
@@ -9696,28 +9488,12 @@ function exclude(leaf, excludePath) {
|
|
|
9696
9488
|
return excludePath && excludePath.has(leaf);
|
|
9697
9489
|
}
|
|
9698
9490
|
|
|
9699
|
-
const MultiTouchHelper = {
|
|
9700
|
-
getData(list) {
|
|
9701
|
-
const a = list[0];
|
|
9702
|
-
const b = list[1];
|
|
9703
|
-
const lastCenter = PointHelper.getCenter(a.from, b.from);
|
|
9704
|
-
const center = PointHelper.getCenter(a.to, b.to);
|
|
9705
|
-
const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
|
|
9706
|
-
const lastDistance = PointHelper.getDistance(a.from, b.from);
|
|
9707
|
-
const distance = PointHelper.getDistance(a.to, b.to);
|
|
9708
|
-
const scale = distance / lastDistance;
|
|
9709
|
-
const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
|
|
9710
|
-
return { move, scale, angle, center };
|
|
9711
|
-
}
|
|
9712
|
-
};
|
|
9713
|
-
|
|
9714
9491
|
const config = {
|
|
9715
9492
|
wheel: {
|
|
9716
9493
|
zoomSpeed: 0.5,
|
|
9717
9494
|
moveSpeed: 0.5,
|
|
9718
9495
|
rotateSpeed: 0.5,
|
|
9719
9496
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9720
|
-
preventDefault: true
|
|
9721
9497
|
},
|
|
9722
9498
|
pointer: {
|
|
9723
9499
|
hitRadius: 5,
|
|
@@ -9728,17 +9504,18 @@ const config = {
|
|
|
9728
9504
|
dragHover: true,
|
|
9729
9505
|
dragDistance: 2,
|
|
9730
9506
|
swipeDistance: 20,
|
|
9731
|
-
preventDefaultMenu: true
|
|
9732
9507
|
},
|
|
9733
9508
|
touch: {
|
|
9734
|
-
preventDefault:
|
|
9509
|
+
preventDefault: 'auto'
|
|
9735
9510
|
},
|
|
9736
9511
|
multiTouch: {},
|
|
9512
|
+
move: { autoDistance: 2 },
|
|
9513
|
+
zoom: {},
|
|
9737
9514
|
cursor: true,
|
|
9738
9515
|
keyEvent: true
|
|
9739
9516
|
};
|
|
9740
9517
|
|
|
9741
|
-
const { pathHasEventType,
|
|
9518
|
+
const { pathHasEventType, pathCanDrag, pathHasOutside } = InteractionHelper;
|
|
9742
9519
|
class InteractionBase {
|
|
9743
9520
|
get dragging() { return this.dragger.dragging; }
|
|
9744
9521
|
get transforming() { return this.transformer.transforming; }
|
|
@@ -9760,7 +9537,7 @@ class InteractionBase {
|
|
|
9760
9537
|
this.canvas = canvas;
|
|
9761
9538
|
this.selector = selector;
|
|
9762
9539
|
this.defaultPath = new LeafList(target);
|
|
9763
|
-
this.
|
|
9540
|
+
this.createTransformer();
|
|
9764
9541
|
this.dragger = new Dragger(this);
|
|
9765
9542
|
if (userConfig)
|
|
9766
9543
|
this.config = DataHelper.default(userConfig, this.config);
|
|
@@ -9861,14 +9638,6 @@ class InteractionBase {
|
|
|
9861
9638
|
data.isCancel = true;
|
|
9862
9639
|
this.pointerUp(data);
|
|
9863
9640
|
}
|
|
9864
|
-
multiTouch(data, list) {
|
|
9865
|
-
if (this.config.multiTouch.disabled)
|
|
9866
|
-
return;
|
|
9867
|
-
const { move, angle, scale, center } = MultiTouchHelper.getData(list);
|
|
9868
|
-
this.rotate(getRotateEventData(center, angle, data));
|
|
9869
|
-
this.zoom(getZoomEventData(center, scale, data));
|
|
9870
|
-
this.move(getMoveEventData(center, move, data));
|
|
9871
|
-
}
|
|
9872
9641
|
menu(data) {
|
|
9873
9642
|
this.findPath(data);
|
|
9874
9643
|
this.emit(PointerEvent.MENU, data);
|
|
@@ -9882,18 +9651,13 @@ class InteractionBase {
|
|
|
9882
9651
|
this.waitRightTap = this.waitMenuTap = false;
|
|
9883
9652
|
}
|
|
9884
9653
|
}
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
}
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
}
|
|
9891
|
-
|
|
9892
|
-
this.transformer.rotate(data);
|
|
9893
|
-
}
|
|
9894
|
-
transformEnd() {
|
|
9895
|
-
this.transformer.transformEnd();
|
|
9896
|
-
}
|
|
9654
|
+
createTransformer() { }
|
|
9655
|
+
move(_data) { }
|
|
9656
|
+
zoom(_data) { }
|
|
9657
|
+
rotate(_data) { }
|
|
9658
|
+
transformEnd() { }
|
|
9659
|
+
wheel(_data) { }
|
|
9660
|
+
multiTouch(_data, _list) { }
|
|
9897
9661
|
keyDown(data) {
|
|
9898
9662
|
if (!this.config.keyEvent)
|
|
9899
9663
|
return;
|
|
@@ -10131,8 +9895,9 @@ class InteractionBase {
|
|
|
10131
9895
|
this.longPressed = false;
|
|
10132
9896
|
}
|
|
10133
9897
|
__onResize() {
|
|
9898
|
+
const { dragOut } = this.m;
|
|
10134
9899
|
this.shrinkCanvasBounds = new Bounds(this.canvas.bounds);
|
|
10135
|
-
this.shrinkCanvasBounds.spread(-2);
|
|
9900
|
+
this.shrinkCanvasBounds.spread(-(typeof dragOut === 'number' ? dragOut : 2));
|
|
10136
9901
|
}
|
|
10137
9902
|
__listenEvents() {
|
|
10138
9903
|
const { target } = this;
|
|
@@ -10152,7 +9917,8 @@ class InteractionBase {
|
|
|
10152
9917
|
this.stop();
|
|
10153
9918
|
this.__removeListenEvents();
|
|
10154
9919
|
this.dragger.destroy();
|
|
10155
|
-
this.transformer
|
|
9920
|
+
if (this.transformer)
|
|
9921
|
+
this.transformer.destroy();
|
|
10156
9922
|
this.downData = this.overPath = this.enterPath = null;
|
|
10157
9923
|
}
|
|
10158
9924
|
}
|
|
@@ -10488,6 +10254,8 @@ function stroke(stroke, ui, canvas) {
|
|
|
10488
10254
|
case 'center':
|
|
10489
10255
|
canvas.setStroke(stroke, __strokeWidth, options);
|
|
10490
10256
|
canvas.stroke();
|
|
10257
|
+
if (options.__useArrow)
|
|
10258
|
+
strokeArrow(ui, canvas);
|
|
10491
10259
|
break;
|
|
10492
10260
|
case 'inside':
|
|
10493
10261
|
canvas.save();
|
|
@@ -10525,6 +10293,8 @@ function strokes(strokes, ui, canvas) {
|
|
|
10525
10293
|
case 'center':
|
|
10526
10294
|
canvas.setStroke(undefined, __strokeWidth, options);
|
|
10527
10295
|
drawStrokesStyle(strokes, false, ui, canvas);
|
|
10296
|
+
if (options.__useArrow)
|
|
10297
|
+
strokeArrow(ui, canvas);
|
|
10528
10298
|
break;
|
|
10529
10299
|
case 'inside':
|
|
10530
10300
|
canvas.save();
|
|
@@ -10550,6 +10320,14 @@ function strokes(strokes, ui, canvas) {
|
|
|
10550
10320
|
}
|
|
10551
10321
|
}
|
|
10552
10322
|
}
|
|
10323
|
+
function strokeArrow(ui, canvas) {
|
|
10324
|
+
if (ui.__.dashPattern) {
|
|
10325
|
+
canvas.beginPath();
|
|
10326
|
+
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
10327
|
+
canvas.dashPattern = null;
|
|
10328
|
+
canvas.stroke();
|
|
10329
|
+
}
|
|
10330
|
+
}
|
|
10553
10331
|
|
|
10554
10332
|
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
|
|
10555
10333
|
function shape(ui, current, options) {
|
|
@@ -12028,4 +11806,4 @@ Object.assign(Creator, {
|
|
|
12028
11806
|
});
|
|
12029
11807
|
useCanvas();
|
|
12030
11808
|
|
|
12031
|
-
export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage,
|
|
11809
|
+
export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, needPlugin, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|