leafer-ui 1.1.0 → 1.1.2
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/README.md +179 -1
- package/dist/web.cjs +20 -67
- package/dist/web.esm.js +20 -67
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +140 -420
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +140 -418
- package/dist/web.module.min.js +1 -1
- package/package.json +11 -11
package/dist/web.module.js
CHANGED
|
@@ -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$f.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$f.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$e = 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$9 = 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$9.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));
|
|
@@ -5434,8 +5449,8 @@ let Leaf = class Leaf {
|
|
|
5434
5449
|
canvas.clearRect(r.x, r.y, r.width, r.height);
|
|
5435
5450
|
canvas.restore();
|
|
5436
5451
|
}
|
|
5437
|
-
__updateMask(
|
|
5438
|
-
this.__hasMask =
|
|
5452
|
+
__updateMask(_value) {
|
|
5453
|
+
this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
|
|
5439
5454
|
}
|
|
5440
5455
|
__renderMask(_canvas, _options) { }
|
|
5441
5456
|
__getNowWorld(options) {
|
|
@@ -5678,6 +5693,7 @@ Leaf = __decorate([
|
|
|
5678
5693
|
const { setListWithFn } = BoundsHelper;
|
|
5679
5694
|
const { sort } = BranchHelper;
|
|
5680
5695
|
const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
|
|
5696
|
+
const debug$7 = new Debug('Branch');
|
|
5681
5697
|
let Branch = class Branch extends Leaf {
|
|
5682
5698
|
__updateStrokeSpread() {
|
|
5683
5699
|
const { children } = this;
|
|
@@ -5718,8 +5734,8 @@ let Branch = class Branch extends Leaf {
|
|
|
5718
5734
|
}
|
|
5719
5735
|
}
|
|
5720
5736
|
add(child, index) {
|
|
5721
|
-
if (child === this)
|
|
5722
|
-
return;
|
|
5737
|
+
if (child === this || child.destroyed)
|
|
5738
|
+
return debug$7.warn('add self or destroyed');
|
|
5723
5739
|
const noIndex = index === undefined;
|
|
5724
5740
|
if (!child.__) {
|
|
5725
5741
|
if (child instanceof Array)
|
|
@@ -5733,8 +5749,9 @@ let Branch = class Branch extends Leaf {
|
|
|
5733
5749
|
noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
|
|
5734
5750
|
if (child.isBranch)
|
|
5735
5751
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5736
|
-
|
|
5737
|
-
|
|
5752
|
+
const childLayout = child.__layout;
|
|
5753
|
+
childLayout.boxChanged || childLayout.boxChange();
|
|
5754
|
+
childLayout.matrixChanged || childLayout.matrixChange();
|
|
5738
5755
|
if (child.__bubbleMap)
|
|
5739
5756
|
child.__emitLifeEvent(ChildEvent.ADD);
|
|
5740
5757
|
if (this.leafer) {
|
|
@@ -5972,9 +5989,9 @@ class LeafLevelList {
|
|
|
5972
5989
|
}
|
|
5973
5990
|
}
|
|
5974
5991
|
|
|
5975
|
-
const version = "1.1.
|
|
5992
|
+
const version = "1.1.1";
|
|
5976
5993
|
|
|
5977
|
-
const debug$
|
|
5994
|
+
const debug$6 = Debug.get('LeaferCanvas');
|
|
5978
5995
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5979
5996
|
set zIndex(zIndex) {
|
|
5980
5997
|
const { style } = this.view;
|
|
@@ -6046,7 +6063,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
6046
6063
|
}
|
|
6047
6064
|
}
|
|
6048
6065
|
else {
|
|
6049
|
-
debug$
|
|
6066
|
+
debug$6.error(`no id: ${inputView}`);
|
|
6050
6067
|
this.__createView();
|
|
6051
6068
|
}
|
|
6052
6069
|
}
|
|
@@ -6083,7 +6100,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
6083
6100
|
}
|
|
6084
6101
|
else {
|
|
6085
6102
|
this.checkAutoBounds(this.view);
|
|
6086
|
-
debug$
|
|
6103
|
+
debug$6.warn('no parent');
|
|
6087
6104
|
}
|
|
6088
6105
|
}
|
|
6089
6106
|
catch (_a) {
|
|
@@ -6419,7 +6436,7 @@ class LayoutBlockData {
|
|
|
6419
6436
|
}
|
|
6420
6437
|
|
|
6421
6438
|
const { updateAllMatrix, updateAllChange } = LeafHelper;
|
|
6422
|
-
const debug$
|
|
6439
|
+
const debug$5 = Debug.get('Layouter');
|
|
6423
6440
|
class Layouter {
|
|
6424
6441
|
constructor(target, userConfig) {
|
|
6425
6442
|
this.totalTimes = 0;
|
|
@@ -6454,7 +6471,7 @@ class Layouter {
|
|
|
6454
6471
|
target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
|
|
6455
6472
|
}
|
|
6456
6473
|
catch (e) {
|
|
6457
|
-
debug$
|
|
6474
|
+
debug$5.error(e);
|
|
6458
6475
|
}
|
|
6459
6476
|
this.layoutedBlocks = null;
|
|
6460
6477
|
}
|
|
@@ -6468,9 +6485,9 @@ class Layouter {
|
|
|
6468
6485
|
}
|
|
6469
6486
|
layoutOnce() {
|
|
6470
6487
|
if (this.layouting)
|
|
6471
|
-
return debug$
|
|
6488
|
+
return debug$5.warn('layouting');
|
|
6472
6489
|
if (this.times > 3)
|
|
6473
|
-
return debug$
|
|
6490
|
+
return debug$5.warn('layout max times');
|
|
6474
6491
|
this.times++;
|
|
6475
6492
|
this.totalTimes++;
|
|
6476
6493
|
this.layouting = true;
|
|
@@ -6574,7 +6591,7 @@ class Layouter {
|
|
|
6574
6591
|
}
|
|
6575
6592
|
}
|
|
6576
6593
|
|
|
6577
|
-
const debug$
|
|
6594
|
+
const debug$4 = Debug.get('Renderer');
|
|
6578
6595
|
class Renderer {
|
|
6579
6596
|
get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
|
|
6580
6597
|
constructor(target, canvas, userConfig) {
|
|
@@ -6590,29 +6607,29 @@ class Renderer {
|
|
|
6590
6607
|
if (userConfig)
|
|
6591
6608
|
this.config = DataHelper.default(userConfig, this.config);
|
|
6592
6609
|
this.__listenEvents();
|
|
6593
|
-
this.__requestRender();
|
|
6594
6610
|
}
|
|
6595
6611
|
start() {
|
|
6596
6612
|
this.running = true;
|
|
6613
|
+
this.update(false);
|
|
6597
6614
|
}
|
|
6598
6615
|
stop() {
|
|
6599
6616
|
this.running = false;
|
|
6600
6617
|
}
|
|
6601
|
-
update() {
|
|
6602
|
-
this.changed
|
|
6618
|
+
update(change = true) {
|
|
6619
|
+
if (!this.changed)
|
|
6620
|
+
this.changed = change;
|
|
6621
|
+
this.__requestRender();
|
|
6603
6622
|
}
|
|
6604
6623
|
requestLayout() {
|
|
6605
6624
|
this.target.emit(LayoutEvent.REQUEST);
|
|
6606
6625
|
}
|
|
6607
6626
|
render(callback) {
|
|
6608
|
-
if (!(this.running && this.canvas.view))
|
|
6609
|
-
this.
|
|
6610
|
-
return;
|
|
6611
|
-
}
|
|
6627
|
+
if (!(this.running && this.canvas.view))
|
|
6628
|
+
return this.update();
|
|
6612
6629
|
const { target } = this;
|
|
6613
6630
|
this.times = 0;
|
|
6614
6631
|
this.totalBounds = new Bounds();
|
|
6615
|
-
debug$
|
|
6632
|
+
debug$4.log(target.innerName, '--->');
|
|
6616
6633
|
try {
|
|
6617
6634
|
if (!target.isApp)
|
|
6618
6635
|
target.app.emit(RenderEvent.CHILD_START, target);
|
|
@@ -6623,9 +6640,9 @@ class Renderer {
|
|
|
6623
6640
|
}
|
|
6624
6641
|
catch (e) {
|
|
6625
6642
|
this.rendering = false;
|
|
6626
|
-
debug$
|
|
6643
|
+
debug$4.error(e);
|
|
6627
6644
|
}
|
|
6628
|
-
debug$
|
|
6645
|
+
debug$4.log('-------------|');
|
|
6629
6646
|
}
|
|
6630
6647
|
renderAgain() {
|
|
6631
6648
|
if (this.rendering) {
|
|
@@ -6637,9 +6654,9 @@ class Renderer {
|
|
|
6637
6654
|
}
|
|
6638
6655
|
renderOnce(callback) {
|
|
6639
6656
|
if (this.rendering)
|
|
6640
|
-
return debug$
|
|
6657
|
+
return debug$4.warn('rendering');
|
|
6641
6658
|
if (this.times > 3)
|
|
6642
|
-
return debug$
|
|
6659
|
+
return debug$4.warn('render max times');
|
|
6643
6660
|
this.times++;
|
|
6644
6661
|
this.totalTimes++;
|
|
6645
6662
|
this.rendering = true;
|
|
@@ -6676,7 +6693,7 @@ class Renderer {
|
|
|
6676
6693
|
partRender() {
|
|
6677
6694
|
const { canvas, updateBlocks: list } = this;
|
|
6678
6695
|
if (!list)
|
|
6679
|
-
return debug$
|
|
6696
|
+
return debug$4.warn('PartRender: need update attr');
|
|
6680
6697
|
this.mergeBlocks();
|
|
6681
6698
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6682
6699
|
this.clipRender(block); });
|
|
@@ -6742,16 +6759,17 @@ class Renderer {
|
|
|
6742
6759
|
}
|
|
6743
6760
|
}
|
|
6744
6761
|
__requestRender() {
|
|
6745
|
-
|
|
6762
|
+
if (this.requestTime)
|
|
6763
|
+
return;
|
|
6764
|
+
const requestTime = this.requestTime = Date.now();
|
|
6746
6765
|
Platform.requestRender(() => {
|
|
6747
|
-
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() -
|
|
6766
|
+
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
6767
|
+
this.requestTime = 0;
|
|
6748
6768
|
if (this.running) {
|
|
6749
6769
|
if (this.changed && this.canvas.view)
|
|
6750
6770
|
this.render();
|
|
6751
6771
|
this.target.emit(RenderEvent.NEXT);
|
|
6752
6772
|
}
|
|
6753
|
-
if (this.target)
|
|
6754
|
-
this.__requestRender();
|
|
6755
6773
|
});
|
|
6756
6774
|
}
|
|
6757
6775
|
__onResize(e) {
|
|
@@ -6767,7 +6785,7 @@ class Renderer {
|
|
|
6767
6785
|
}
|
|
6768
6786
|
}
|
|
6769
6787
|
this.addBlock(new Bounds(0, 0, 1, 1));
|
|
6770
|
-
this.
|
|
6788
|
+
this.update();
|
|
6771
6789
|
}
|
|
6772
6790
|
__onLayoutEnd(event) {
|
|
6773
6791
|
if (event.data)
|
|
@@ -6778,7 +6796,7 @@ class Renderer {
|
|
|
6778
6796
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
6779
6797
|
if (empty) {
|
|
6780
6798
|
if (!leaf.isLeafer)
|
|
6781
|
-
debug$
|
|
6799
|
+
debug$4.tip(leaf.innerName, ': empty');
|
|
6782
6800
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
6783
6801
|
}
|
|
6784
6802
|
return empty;
|
|
@@ -7153,7 +7171,7 @@ const Transition = {
|
|
|
7153
7171
|
|
|
7154
7172
|
const { parse, objectToCanvasData } = PathConvert;
|
|
7155
7173
|
const emptyPaint = {};
|
|
7156
|
-
const debug$
|
|
7174
|
+
const debug$3 = Debug.get('UIData');
|
|
7157
7175
|
class UIData extends LeafData {
|
|
7158
7176
|
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
7159
7177
|
get __strokeWidth() {
|
|
@@ -7175,7 +7193,7 @@ class UIData extends LeafData {
|
|
|
7175
7193
|
return true;
|
|
7176
7194
|
return t.fill && this.__hasStroke;
|
|
7177
7195
|
}
|
|
7178
|
-
get __clipAfterFill() { return (
|
|
7196
|
+
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
7179
7197
|
get __autoWidth() { return !this._width; }
|
|
7180
7198
|
get __autoHeight() { return !this._height; }
|
|
7181
7199
|
get __autoSide() { return !this._width || !this._height; }
|
|
@@ -7190,7 +7208,7 @@ class UIData extends LeafData {
|
|
|
7190
7208
|
if (value < 0) {
|
|
7191
7209
|
this._width = -value;
|
|
7192
7210
|
this.__leaf.scaleX *= -1;
|
|
7193
|
-
debug$
|
|
7211
|
+
debug$3.warn('width < 0, instead -scaleX ', this);
|
|
7194
7212
|
}
|
|
7195
7213
|
else
|
|
7196
7214
|
this._width = value;
|
|
@@ -7199,7 +7217,7 @@ class UIData extends LeafData {
|
|
|
7199
7217
|
if (value < 0) {
|
|
7200
7218
|
this._height = -value;
|
|
7201
7219
|
this.__leaf.scaleY *= -1;
|
|
7202
|
-
debug$
|
|
7220
|
+
debug$3.warn('height < 0, instead -scaleY', this);
|
|
7203
7221
|
}
|
|
7204
7222
|
else
|
|
7205
7223
|
this._height = value;
|
|
@@ -7289,7 +7307,7 @@ class GroupData extends UIData {
|
|
|
7289
7307
|
|
|
7290
7308
|
class BoxData extends GroupData {
|
|
7291
7309
|
get __boxStroke() { return !this.__pathInputed; }
|
|
7292
|
-
get __drawAfterFill() { return
|
|
7310
|
+
get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
|
|
7293
7311
|
get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
|
|
7294
7312
|
}
|
|
7295
7313
|
|
|
@@ -7935,7 +7953,7 @@ Group = __decorate([
|
|
|
7935
7953
|
], Group);
|
|
7936
7954
|
|
|
7937
7955
|
var Leafer_1;
|
|
7938
|
-
const debug$
|
|
7956
|
+
const debug$2 = Debug.get('Leafer');
|
|
7939
7957
|
let Leafer = Leafer_1 = class Leafer extends Group {
|
|
7940
7958
|
get __tag() { return 'Leafer'; }
|
|
7941
7959
|
get isApp() { return false; }
|
|
@@ -7949,20 +7967,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7949
7967
|
constructor(userConfig, data) {
|
|
7950
7968
|
super(data);
|
|
7951
7969
|
this.config = {
|
|
7952
|
-
type: 'design',
|
|
7953
7970
|
start: true,
|
|
7954
7971
|
hittable: true,
|
|
7955
7972
|
smooth: true,
|
|
7956
|
-
lazySpeard: 100
|
|
7957
|
-
zoom: {
|
|
7958
|
-
min: 0.01,
|
|
7959
|
-
max: 256
|
|
7960
|
-
},
|
|
7961
|
-
move: {
|
|
7962
|
-
holdSpaceKey: true,
|
|
7963
|
-
holdMiddleKey: true,
|
|
7964
|
-
autoDistance: 2
|
|
7965
|
-
}
|
|
7973
|
+
lazySpeard: 100
|
|
7966
7974
|
};
|
|
7967
7975
|
this.leafs = 0;
|
|
7968
7976
|
this.__eventIds = [];
|
|
@@ -7979,23 +7987,27 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7979
7987
|
init(userConfig, parentApp) {
|
|
7980
7988
|
if (this.canvas)
|
|
7981
7989
|
return;
|
|
7982
|
-
this.__setLeafer(this);
|
|
7983
|
-
if (userConfig)
|
|
7984
|
-
DataHelper.assign(this.config, userConfig);
|
|
7985
7990
|
let start;
|
|
7986
7991
|
const { config } = this;
|
|
7987
|
-
this.
|
|
7992
|
+
this.__setLeafer(this);
|
|
7993
|
+
if (parentApp) {
|
|
7994
|
+
this.parentApp = parentApp;
|
|
7995
|
+
this.__bindApp(parentApp);
|
|
7996
|
+
start = parentApp.running;
|
|
7997
|
+
}
|
|
7998
|
+
if (userConfig) {
|
|
7999
|
+
this.parent = parentApp;
|
|
8000
|
+
this.initType(userConfig.type);
|
|
8001
|
+
this.parent = undefined;
|
|
8002
|
+
DataHelper.assign(config, userConfig);
|
|
8003
|
+
}
|
|
7988
8004
|
const canvas = this.canvas = Creator.canvas(config);
|
|
7989
8005
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7990
8006
|
if (this.isApp)
|
|
7991
8007
|
this.__setApp();
|
|
7992
8008
|
this.__checkAutoLayout(config, parentApp);
|
|
7993
8009
|
this.view = canvas.view;
|
|
7994
|
-
if (parentApp) {
|
|
7995
|
-
this.__bindApp(parentApp);
|
|
7996
|
-
start = parentApp.running;
|
|
7997
|
-
}
|
|
7998
|
-
else {
|
|
8010
|
+
if (!parentApp) {
|
|
7999
8011
|
this.selector = Creator.selector(this);
|
|
8000
8012
|
this.interaction = Creator.interaction(this, canvas, this.selector, config);
|
|
8001
8013
|
if (this.interaction) {
|
|
@@ -8052,7 +8064,11 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8052
8064
|
forceRender(bounds) {
|
|
8053
8065
|
this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
|
|
8054
8066
|
if (this.viewReady)
|
|
8055
|
-
this.renderer.
|
|
8067
|
+
this.renderer.render();
|
|
8068
|
+
}
|
|
8069
|
+
requestRender(change = false) {
|
|
8070
|
+
if (this.renderer)
|
|
8071
|
+
this.renderer.update(change);
|
|
8056
8072
|
}
|
|
8057
8073
|
updateCursor(cursor) {
|
|
8058
8074
|
const i = this.interaction;
|
|
@@ -8099,7 +8115,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8099
8115
|
if (this.canvas) {
|
|
8100
8116
|
if (canvasSizeAttrs.includes(attrName)) {
|
|
8101
8117
|
if (!newValue)
|
|
8102
|
-
debug$
|
|
8118
|
+
debug$2.warn(attrName + ' is 0');
|
|
8103
8119
|
this.__changeCanvasSize(attrName, newValue);
|
|
8104
8120
|
}
|
|
8105
8121
|
else if (attrName === 'fill') {
|
|
@@ -8160,8 +8176,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8160
8176
|
const { imageReady } = this;
|
|
8161
8177
|
if (imageReady && !this.viewCompleted)
|
|
8162
8178
|
this.__checkViewCompleted();
|
|
8163
|
-
if (!imageReady)
|
|
8179
|
+
if (!imageReady) {
|
|
8164
8180
|
this.viewCompleted = false;
|
|
8181
|
+
this.requestRender();
|
|
8182
|
+
}
|
|
8165
8183
|
}
|
|
8166
8184
|
}
|
|
8167
8185
|
__checkViewCompleted(emit = true) {
|
|
@@ -8219,6 +8237,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8219
8237
|
}
|
|
8220
8238
|
else
|
|
8221
8239
|
list.push(item);
|
|
8240
|
+
this.requestRender();
|
|
8222
8241
|
}
|
|
8223
8242
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
8224
8243
|
return needPlugin('view');
|
|
@@ -8272,14 +8291,14 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8272
8291
|
this.canvasManager.destroy();
|
|
8273
8292
|
}
|
|
8274
8293
|
this.canvas.destroy();
|
|
8275
|
-
this.config.view = this.view = null;
|
|
8294
|
+
this.config.view = this.view = this.parentApp = null;
|
|
8276
8295
|
if (this.userConfig)
|
|
8277
8296
|
this.userConfig.view = null;
|
|
8278
8297
|
super.destroy();
|
|
8279
8298
|
setTimeout(() => { ImageManager.clearRecycled(); }, 100);
|
|
8280
8299
|
}
|
|
8281
8300
|
catch (e) {
|
|
8282
|
-
debug$
|
|
8301
|
+
debug$2.error(e);
|
|
8283
8302
|
}
|
|
8284
8303
|
}
|
|
8285
8304
|
};
|
|
@@ -8999,9 +9018,9 @@ let App = class App extends Leafer {
|
|
|
8999
9018
|
if (ground)
|
|
9000
9019
|
this.ground = this.addLeafer(ground);
|
|
9001
9020
|
if (tree || editor)
|
|
9002
|
-
this.tree = this.addLeafer(tree);
|
|
9021
|
+
this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
|
|
9003
9022
|
if (sky || editor)
|
|
9004
|
-
this.sky = this.addLeafer(sky
|
|
9023
|
+
this.sky = this.addLeafer(sky);
|
|
9005
9024
|
if (editor)
|
|
9006
9025
|
this.sky.add(this.editor = Creator.editor(editor));
|
|
9007
9026
|
}
|
|
@@ -9355,184 +9374,7 @@ KeyEvent = __decorate([
|
|
|
9355
9374
|
registerUIEvent()
|
|
9356
9375
|
], KeyEvent);
|
|
9357
9376
|
|
|
9358
|
-
function addInteractionWindow(leafer) {
|
|
9359
|
-
if (leafer.isApp)
|
|
9360
|
-
return;
|
|
9361
|
-
leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => {
|
|
9362
|
-
leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
|
|
9363
|
-
}), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
|
|
9364
|
-
const { zoomLayer } = leafer;
|
|
9365
|
-
const changeScale = leafer.getValidScale(e.scale);
|
|
9366
|
-
if (changeScale !== 1) {
|
|
9367
|
-
PointHelper.scaleOf(zoomLayer, e, changeScale);
|
|
9368
|
-
zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
|
|
9369
|
-
}
|
|
9370
|
-
}));
|
|
9371
|
-
}
|
|
9372
|
-
|
|
9373
|
-
function document$1(leafer) {
|
|
9374
|
-
addInteractionWindow(leafer);
|
|
9375
|
-
const { move, zoom } = leafer.config;
|
|
9376
|
-
move.scroll = 'limit';
|
|
9377
|
-
zoom.min = 1;
|
|
9378
|
-
}
|
|
9379
|
-
|
|
9380
|
-
function block(leafer) {
|
|
9381
|
-
const { config } = leafer;
|
|
9382
|
-
(config.wheel || (config.wheel = {})).preventDefault = false;
|
|
9383
|
-
(config.touch || (config.touch = {})).preventDefault = 'auto';
|
|
9384
|
-
}
|
|
9385
|
-
|
|
9386
|
-
const debug$2 = Debug.get('LeaferTypeCreator');
|
|
9387
|
-
const LeaferTypeCreator = {
|
|
9388
|
-
list: {},
|
|
9389
|
-
register(name, fn) {
|
|
9390
|
-
list[name] && debug$2.repeat(name);
|
|
9391
|
-
list[name] = fn;
|
|
9392
|
-
},
|
|
9393
|
-
run(name, leafer) {
|
|
9394
|
-
const fn = list[name];
|
|
9395
|
-
fn && fn(leafer);
|
|
9396
|
-
}
|
|
9397
|
-
};
|
|
9398
|
-
const { list, register } = LeaferTypeCreator;
|
|
9399
|
-
register('design', addInteractionWindow);
|
|
9400
|
-
register('document', document$1);
|
|
9401
|
-
register('block', block);
|
|
9402
|
-
|
|
9403
|
-
const leafer = Leafer.prototype;
|
|
9404
|
-
leafer.initType = function (type) {
|
|
9405
|
-
LeaferTypeCreator.run(type, this);
|
|
9406
|
-
};
|
|
9407
|
-
leafer.getValidMove = function (moveX, moveY) {
|
|
9408
|
-
const { scroll, disabled } = this.app.config.move;
|
|
9409
|
-
if (scroll) {
|
|
9410
|
-
Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
|
|
9411
|
-
if (scroll === 'limit') {
|
|
9412
|
-
const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
|
|
9413
|
-
const right = x + width - this.width, bottom = y + height - this.height;
|
|
9414
|
-
if (x >= 0 && right <= 0)
|
|
9415
|
-
moveX = 0;
|
|
9416
|
-
else if (moveX > 0) {
|
|
9417
|
-
if (x + moveX > 0)
|
|
9418
|
-
moveX = -x;
|
|
9419
|
-
}
|
|
9420
|
-
else if (moveX < 0 && right + moveX < 0)
|
|
9421
|
-
moveX = -right;
|
|
9422
|
-
if (y >= 0 && bottom <= 0)
|
|
9423
|
-
moveY = 0;
|
|
9424
|
-
else if (moveY > 0) {
|
|
9425
|
-
if (y + moveY > 0)
|
|
9426
|
-
moveY = -y;
|
|
9427
|
-
}
|
|
9428
|
-
else if (moveY < 0 && bottom + moveY < 0)
|
|
9429
|
-
moveY = -bottom;
|
|
9430
|
-
}
|
|
9431
|
-
}
|
|
9432
|
-
return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
|
|
9433
|
-
};
|
|
9434
|
-
leafer.getValidScale = function (changeScale) {
|
|
9435
|
-
const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
|
|
9436
|
-
if (absScale < min)
|
|
9437
|
-
changeScale = min / scaleX;
|
|
9438
|
-
else if (absScale > max)
|
|
9439
|
-
changeScale = max / scaleX;
|
|
9440
|
-
return disabled ? 1 : changeScale;
|
|
9441
|
-
};
|
|
9442
|
-
|
|
9443
|
-
class Transformer {
|
|
9444
|
-
get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
|
|
9445
|
-
constructor(interaction) {
|
|
9446
|
-
this.interaction = interaction;
|
|
9447
|
-
}
|
|
9448
|
-
move(data) {
|
|
9449
|
-
const { interaction } = this;
|
|
9450
|
-
if (!data.moveType)
|
|
9451
|
-
data.moveType = 'move';
|
|
9452
|
-
if (!this.moveData) {
|
|
9453
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9454
|
-
data.path = path;
|
|
9455
|
-
this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
|
|
9456
|
-
interaction.cancelHover();
|
|
9457
|
-
interaction.emit(MoveEvent.START, this.moveData);
|
|
9458
|
-
}
|
|
9459
|
-
data.path = this.moveData.path;
|
|
9460
|
-
interaction.emit(MoveEvent.BEFORE_MOVE, data);
|
|
9461
|
-
interaction.emit(MoveEvent.MOVE, data);
|
|
9462
|
-
this.transformEndWait();
|
|
9463
|
-
}
|
|
9464
|
-
zoom(data) {
|
|
9465
|
-
const { interaction } = this;
|
|
9466
|
-
if (!this.zoomData) {
|
|
9467
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9468
|
-
data.path = path;
|
|
9469
|
-
this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
|
|
9470
|
-
interaction.cancelHover();
|
|
9471
|
-
interaction.emit(ZoomEvent.START, this.zoomData);
|
|
9472
|
-
}
|
|
9473
|
-
data.path = this.zoomData.path;
|
|
9474
|
-
interaction.emit(ZoomEvent.BEFORE_ZOOM, data);
|
|
9475
|
-
interaction.emit(ZoomEvent.ZOOM, data);
|
|
9476
|
-
this.transformEndWait();
|
|
9477
|
-
}
|
|
9478
|
-
rotate(data) {
|
|
9479
|
-
const { interaction } = this;
|
|
9480
|
-
if (!this.rotateData) {
|
|
9481
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9482
|
-
data.path = path;
|
|
9483
|
-
this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
|
|
9484
|
-
interaction.cancelHover();
|
|
9485
|
-
interaction.emit(RotateEvent.START, this.rotateData);
|
|
9486
|
-
}
|
|
9487
|
-
data.path = this.rotateData.path;
|
|
9488
|
-
interaction.emit(RotateEvent.BEFORE_ROTATE, data);
|
|
9489
|
-
interaction.emit(RotateEvent.ROTATE, data);
|
|
9490
|
-
this.transformEndWait();
|
|
9491
|
-
}
|
|
9492
|
-
transformEndWait() {
|
|
9493
|
-
clearTimeout(this.transformTimer);
|
|
9494
|
-
this.transformTimer = setTimeout(() => {
|
|
9495
|
-
this.transformEnd();
|
|
9496
|
-
}, this.interaction.config.pointer.transformTime);
|
|
9497
|
-
}
|
|
9498
|
-
transformEnd() {
|
|
9499
|
-
this.moveEnd();
|
|
9500
|
-
this.zoomEnd();
|
|
9501
|
-
this.rotateEnd();
|
|
9502
|
-
}
|
|
9503
|
-
moveEnd() {
|
|
9504
|
-
if (this.moveData) {
|
|
9505
|
-
this.interaction.emit(MoveEvent.END, this.moveData);
|
|
9506
|
-
this.moveData = null;
|
|
9507
|
-
}
|
|
9508
|
-
}
|
|
9509
|
-
zoomEnd() {
|
|
9510
|
-
if (this.zoomData) {
|
|
9511
|
-
this.interaction.emit(ZoomEvent.END, this.zoomData);
|
|
9512
|
-
this.zoomData = null;
|
|
9513
|
-
}
|
|
9514
|
-
}
|
|
9515
|
-
rotateEnd() {
|
|
9516
|
-
if (this.rotateData) {
|
|
9517
|
-
this.interaction.emit(RotateEvent.END, this.rotateData);
|
|
9518
|
-
this.rotateData = null;
|
|
9519
|
-
}
|
|
9520
|
-
}
|
|
9521
|
-
destroy() {
|
|
9522
|
-
this.zoomData = this.moveData = this.rotateData = null;
|
|
9523
|
-
}
|
|
9524
|
-
}
|
|
9525
|
-
|
|
9526
9377
|
const InteractionHelper = {
|
|
9527
|
-
getMoveEventData(center, move, event) {
|
|
9528
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, moveX: move.x, moveY: move.y });
|
|
9529
|
-
},
|
|
9530
|
-
getRotateEventData(center, angle, event) {
|
|
9531
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, rotation: angle });
|
|
9532
|
-
},
|
|
9533
|
-
getZoomEventData(center, scale, event) {
|
|
9534
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, scale });
|
|
9535
|
-
},
|
|
9536
9378
|
getDragEventData(startPoint, lastPoint, event) {
|
|
9537
9379
|
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 });
|
|
9538
9380
|
},
|
|
@@ -9541,18 +9383,14 @@ const InteractionHelper = {
|
|
|
9541
9383
|
data });
|
|
9542
9384
|
},
|
|
9543
9385
|
getSwipeDirection(angle) {
|
|
9544
|
-
if (angle < -45 && angle > -135)
|
|
9386
|
+
if (angle < -45 && angle > -135)
|
|
9545
9387
|
return SwipeEvent.UP;
|
|
9546
|
-
|
|
9547
|
-
else if (angle > 45 && angle < 135) {
|
|
9388
|
+
else if (angle > 45 && angle < 135)
|
|
9548
9389
|
return SwipeEvent.DOWN;
|
|
9549
|
-
|
|
9550
|
-
else if (angle <= 45 && angle >= -45) {
|
|
9390
|
+
else if (angle <= 45 && angle >= -45)
|
|
9551
9391
|
return SwipeEvent.RIGHT;
|
|
9552
|
-
|
|
9553
|
-
else {
|
|
9392
|
+
else
|
|
9554
9393
|
return SwipeEvent.LEFT;
|
|
9555
|
-
}
|
|
9556
9394
|
},
|
|
9557
9395
|
getSwipeEventData(startPoint, lastDragData, event) {
|
|
9558
9396
|
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)) });
|
|
@@ -9625,9 +9463,8 @@ class Dragger {
|
|
|
9625
9463
|
interaction.emit(MoveEvent.START, this.dragData);
|
|
9626
9464
|
}
|
|
9627
9465
|
}
|
|
9628
|
-
if (!this.moving)
|
|
9466
|
+
if (!this.moving)
|
|
9629
9467
|
this.dragStart(data, canDrag);
|
|
9630
|
-
}
|
|
9631
9468
|
this.drag(data);
|
|
9632
9469
|
}
|
|
9633
9470
|
dragStart(data, canDrag) {
|
|
@@ -9705,16 +9542,9 @@ class Dragger {
|
|
|
9705
9542
|
dragEnd(data, speed) {
|
|
9706
9543
|
if (!this.dragging && !this.moving)
|
|
9707
9544
|
return;
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
speed = (speed || (data.pointerType === 'touch' ? 2 : 1)) * 0.9;
|
|
9712
|
-
PointHelper.move(data, moveX * speed, moveY * speed);
|
|
9713
|
-
this.drag(data);
|
|
9714
|
-
this.animate(() => { this.dragEnd(data, 1); });
|
|
9715
|
-
}
|
|
9716
|
-
else
|
|
9717
|
-
this.dragEndReal(data);
|
|
9545
|
+
if (this.checkDragEndAnimate(data, speed))
|
|
9546
|
+
return;
|
|
9547
|
+
this.dragEndReal(data);
|
|
9718
9548
|
}
|
|
9719
9549
|
dragEndReal(data) {
|
|
9720
9550
|
const { interaction, downData, dragData } = this;
|
|
@@ -9741,12 +9571,6 @@ class Dragger {
|
|
|
9741
9571
|
this.dragReset();
|
|
9742
9572
|
this.animate(null, 'off');
|
|
9743
9573
|
}
|
|
9744
|
-
animate(func, off) {
|
|
9745
|
-
const animateWait = func || this.animateWait;
|
|
9746
|
-
if (animateWait)
|
|
9747
|
-
this.interaction.target.nextRender(animateWait, null, off);
|
|
9748
|
-
this.animateWait = func;
|
|
9749
|
-
}
|
|
9750
9574
|
swipe(data, downData, dragData, endDragData) {
|
|
9751
9575
|
const { interaction } = this;
|
|
9752
9576
|
if (PointHelper.getDistance(downData, data) > interaction.config.pointer.swipeDistance) {
|
|
@@ -9763,39 +9587,11 @@ class Dragger {
|
|
|
9763
9587
|
dragReset() {
|
|
9764
9588
|
DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
|
|
9765
9589
|
}
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
}
|
|
9772
|
-
autoMoveOnDragOut(data) {
|
|
9773
|
-
const { interaction, downData, canDragOut } = this;
|
|
9774
|
-
const { autoDistance, dragOut } = interaction.config.move;
|
|
9775
|
-
if (!dragOut || !canDragOut || !autoDistance)
|
|
9776
|
-
return;
|
|
9777
|
-
const bounds = interaction.shrinkCanvasBounds;
|
|
9778
|
-
const { x, y } = bounds;
|
|
9779
|
-
const right = BoundsHelper.maxX(bounds);
|
|
9780
|
-
const bottom = BoundsHelper.maxY(bounds);
|
|
9781
|
-
const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
|
|
9782
|
-
const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
|
|
9783
|
-
let totalX = 0, totalY = 0;
|
|
9784
|
-
this.autoMoveTimer = setInterval(() => {
|
|
9785
|
-
totalX += moveX;
|
|
9786
|
-
totalY += moveY;
|
|
9787
|
-
PointHelper.move(downData, moveX, moveY);
|
|
9788
|
-
PointHelper.move(this.dragData, moveX, moveY);
|
|
9789
|
-
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
|
|
9790
|
-
interaction.pointerMoveReal(data);
|
|
9791
|
-
}, 10);
|
|
9792
|
-
}
|
|
9793
|
-
autoMoveCancel() {
|
|
9794
|
-
if (this.autoMoveTimer) {
|
|
9795
|
-
clearInterval(this.autoMoveTimer);
|
|
9796
|
-
this.autoMoveTimer = 0;
|
|
9797
|
-
}
|
|
9798
|
-
}
|
|
9590
|
+
checkDragEndAnimate(_data, _speed) { return false; }
|
|
9591
|
+
animate(_func, _off) { }
|
|
9592
|
+
checkDragOut(_data) { }
|
|
9593
|
+
autoMoveOnDragOut(_data) { }
|
|
9594
|
+
autoMoveCancel() { }
|
|
9799
9595
|
destroy() {
|
|
9800
9596
|
this.dragReset();
|
|
9801
9597
|
}
|
|
@@ -9865,28 +9661,12 @@ function exclude(leaf, excludePath) {
|
|
|
9865
9661
|
return excludePath && excludePath.has(leaf);
|
|
9866
9662
|
}
|
|
9867
9663
|
|
|
9868
|
-
const MultiTouchHelper = {
|
|
9869
|
-
getData(list) {
|
|
9870
|
-
const a = list[0];
|
|
9871
|
-
const b = list[1];
|
|
9872
|
-
const lastCenter = PointHelper.getCenter(a.from, b.from);
|
|
9873
|
-
const center = PointHelper.getCenter(a.to, b.to);
|
|
9874
|
-
const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
|
|
9875
|
-
const lastDistance = PointHelper.getDistance(a.from, b.from);
|
|
9876
|
-
const distance = PointHelper.getDistance(a.to, b.to);
|
|
9877
|
-
const scale = distance / lastDistance;
|
|
9878
|
-
const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
|
|
9879
|
-
return { move, scale, angle, center };
|
|
9880
|
-
}
|
|
9881
|
-
};
|
|
9882
|
-
|
|
9883
9664
|
const config = {
|
|
9884
9665
|
wheel: {
|
|
9885
9666
|
zoomSpeed: 0.5,
|
|
9886
9667
|
moveSpeed: 0.5,
|
|
9887
9668
|
rotateSpeed: 0.5,
|
|
9888
9669
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9889
|
-
preventDefault: true
|
|
9890
9670
|
},
|
|
9891
9671
|
pointer: {
|
|
9892
9672
|
hitRadius: 5,
|
|
@@ -9897,17 +9677,18 @@ const config = {
|
|
|
9897
9677
|
dragHover: true,
|
|
9898
9678
|
dragDistance: 2,
|
|
9899
9679
|
swipeDistance: 20,
|
|
9900
|
-
preventDefaultMenu: true
|
|
9901
9680
|
},
|
|
9902
9681
|
touch: {
|
|
9903
|
-
preventDefault:
|
|
9682
|
+
preventDefault: 'auto'
|
|
9904
9683
|
},
|
|
9905
9684
|
multiTouch: {},
|
|
9685
|
+
move: { autoDistance: 2 },
|
|
9686
|
+
zoom: {},
|
|
9906
9687
|
cursor: true,
|
|
9907
9688
|
keyEvent: true
|
|
9908
9689
|
};
|
|
9909
9690
|
|
|
9910
|
-
const { pathHasEventType,
|
|
9691
|
+
const { pathHasEventType, pathCanDrag: pathCanDrag$1, pathHasOutside } = InteractionHelper;
|
|
9911
9692
|
class InteractionBase {
|
|
9912
9693
|
get dragging() { return this.dragger.dragging; }
|
|
9913
9694
|
get transforming() { return this.transformer.transforming; }
|
|
@@ -9929,7 +9710,7 @@ class InteractionBase {
|
|
|
9929
9710
|
this.canvas = canvas;
|
|
9930
9711
|
this.selector = selector;
|
|
9931
9712
|
this.defaultPath = new LeafList(target);
|
|
9932
|
-
this.
|
|
9713
|
+
this.createTransformer();
|
|
9933
9714
|
this.dragger = new Dragger(this);
|
|
9934
9715
|
if (userConfig)
|
|
9935
9716
|
this.config = DataHelper.default(userConfig, this.config);
|
|
@@ -10030,14 +9811,6 @@ class InteractionBase {
|
|
|
10030
9811
|
data.isCancel = true;
|
|
10031
9812
|
this.pointerUp(data);
|
|
10032
9813
|
}
|
|
10033
|
-
multiTouch(data, list) {
|
|
10034
|
-
if (this.config.multiTouch.disabled)
|
|
10035
|
-
return;
|
|
10036
|
-
const { move, angle, scale, center } = MultiTouchHelper.getData(list);
|
|
10037
|
-
this.rotate(getRotateEventData$1(center, angle, data));
|
|
10038
|
-
this.zoom(getZoomEventData$1(center, scale, data));
|
|
10039
|
-
this.move(getMoveEventData$1(center, move, data));
|
|
10040
|
-
}
|
|
10041
9814
|
menu(data) {
|
|
10042
9815
|
this.findPath(data);
|
|
10043
9816
|
this.emit(PointerEvent.MENU, data);
|
|
@@ -10051,18 +9824,13 @@ class InteractionBase {
|
|
|
10051
9824
|
this.waitRightTap = this.waitMenuTap = false;
|
|
10052
9825
|
}
|
|
10053
9826
|
}
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
}
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
}
|
|
10060
|
-
|
|
10061
|
-
this.transformer.rotate(data);
|
|
10062
|
-
}
|
|
10063
|
-
transformEnd() {
|
|
10064
|
-
this.transformer.transformEnd();
|
|
10065
|
-
}
|
|
9827
|
+
createTransformer() { }
|
|
9828
|
+
move(_data) { }
|
|
9829
|
+
zoom(_data) { }
|
|
9830
|
+
rotate(_data) { }
|
|
9831
|
+
transformEnd() { }
|
|
9832
|
+
wheel(_data) { }
|
|
9833
|
+
multiTouch(_data, _list) { }
|
|
10066
9834
|
keyDown(data) {
|
|
10067
9835
|
if (!this.config.keyEvent)
|
|
10068
9836
|
return;
|
|
@@ -10300,8 +10068,9 @@ class InteractionBase {
|
|
|
10300
10068
|
this.longPressed = false;
|
|
10301
10069
|
}
|
|
10302
10070
|
__onResize() {
|
|
10071
|
+
const { dragOut } = this.m;
|
|
10303
10072
|
this.shrinkCanvasBounds = new Bounds(this.canvas.bounds);
|
|
10304
|
-
this.shrinkCanvasBounds.spread(-2);
|
|
10073
|
+
this.shrinkCanvasBounds.spread(-(typeof dragOut === 'number' ? dragOut : 2));
|
|
10305
10074
|
}
|
|
10306
10075
|
__listenEvents() {
|
|
10307
10076
|
const { target } = this;
|
|
@@ -10321,7 +10090,8 @@ class InteractionBase {
|
|
|
10321
10090
|
this.stop();
|
|
10322
10091
|
this.__removeListenEvents();
|
|
10323
10092
|
this.dragger.destroy();
|
|
10324
|
-
this.transformer
|
|
10093
|
+
if (this.transformer)
|
|
10094
|
+
this.transformer.destroy();
|
|
10325
10095
|
this.downData = this.overPath = this.enterPath = null;
|
|
10326
10096
|
}
|
|
10327
10097
|
}
|
|
@@ -10557,46 +10327,6 @@ const PointerEventHelper = {
|
|
|
10557
10327
|
}
|
|
10558
10328
|
};
|
|
10559
10329
|
|
|
10560
|
-
const WheelEventHelper = {
|
|
10561
|
-
getMove(e, config) {
|
|
10562
|
-
let { moveSpeed } = config;
|
|
10563
|
-
let { deltaX, deltaY } = e;
|
|
10564
|
-
if (e.shiftKey && !deltaX) {
|
|
10565
|
-
deltaX = deltaY;
|
|
10566
|
-
deltaY = 0;
|
|
10567
|
-
}
|
|
10568
|
-
if (deltaX > 50)
|
|
10569
|
-
deltaX = Math.max(50, deltaX / 3);
|
|
10570
|
-
if (deltaY > 50)
|
|
10571
|
-
deltaY = Math.max(50, deltaY / 3);
|
|
10572
|
-
return { x: -deltaX * moveSpeed * 2, y: -deltaY * moveSpeed * 2 };
|
|
10573
|
-
},
|
|
10574
|
-
getScale(e, config) {
|
|
10575
|
-
let zoom;
|
|
10576
|
-
let scale = 1;
|
|
10577
|
-
let { zoomMode, zoomSpeed } = config;
|
|
10578
|
-
const delta = e.deltaY || e.deltaX;
|
|
10579
|
-
if (zoomMode) {
|
|
10580
|
-
zoom = (zoomMode === 'mouse') ? true : (!e.deltaX && (Platform.intWheelDeltaY ? Math.abs(delta) > 17 : Math.ceil(delta) !== delta));
|
|
10581
|
-
if (e.shiftKey || e.metaKey || e.ctrlKey)
|
|
10582
|
-
zoom = true;
|
|
10583
|
-
}
|
|
10584
|
-
else {
|
|
10585
|
-
zoom = !e.shiftKey && (e.metaKey || e.ctrlKey);
|
|
10586
|
-
}
|
|
10587
|
-
if (zoom) {
|
|
10588
|
-
zoomSpeed = MathHelper.within(zoomSpeed, 0, 1);
|
|
10589
|
-
const min = e.deltaY ? config.delta.y : config.delta.x;
|
|
10590
|
-
scale = 1 - delta / (min * 4) * zoomSpeed;
|
|
10591
|
-
if (scale < 0.5)
|
|
10592
|
-
scale = 0.5;
|
|
10593
|
-
if (scale >= 1.5)
|
|
10594
|
-
scale = 1.5;
|
|
10595
|
-
}
|
|
10596
|
-
return scale;
|
|
10597
|
-
}
|
|
10598
|
-
};
|
|
10599
|
-
|
|
10600
10330
|
const KeyEventHelper = {
|
|
10601
10331
|
convert(e) {
|
|
10602
10332
|
const base = InteractionHelper.getBase(e);
|
|
@@ -10605,7 +10335,7 @@ const KeyEventHelper = {
|
|
|
10605
10335
|
}
|
|
10606
10336
|
};
|
|
10607
10337
|
|
|
10608
|
-
const {
|
|
10338
|
+
const { pathCanDrag } = InteractionHelper;
|
|
10609
10339
|
class Interaction extends InteractionBase {
|
|
10610
10340
|
__listenEvents() {
|
|
10611
10341
|
super.__listenEvents();
|
|
@@ -10815,13 +10545,7 @@ class Interaction extends InteractionBase {
|
|
|
10815
10545
|
}
|
|
10816
10546
|
onWheel(e) {
|
|
10817
10547
|
this.preventDefaultWheel(e);
|
|
10818
|
-
|
|
10819
|
-
if (wheel.disabled)
|
|
10820
|
-
return;
|
|
10821
|
-
const scale = wheel.getScale ? wheel.getScale(e, wheel) : WheelEventHelper.getScale(e, wheel);
|
|
10822
|
-
const local = this.getLocal(e);
|
|
10823
|
-
const eventBase = InteractionHelper.getBase(e);
|
|
10824
|
-
scale !== 1 ? this.zoom(getZoomEventData(local, scale, eventBase)) : this.move(getMoveEventData(local, wheel.getMove ? wheel.getMove(e, wheel) : WheelEventHelper.getMove(e, wheel), eventBase));
|
|
10548
|
+
this.wheel(Object.assign(Object.assign(Object.assign({}, InteractionHelper.getBase(e)), this.getLocal(e)), { deltaX: e.deltaX, deltaY: e.deltaY }));
|
|
10825
10549
|
}
|
|
10826
10550
|
onGesturestart(e) {
|
|
10827
10551
|
if (this.useMultiTouch)
|
|
@@ -10834,14 +10558,12 @@ class Interaction extends InteractionBase {
|
|
|
10834
10558
|
if (this.useMultiTouch)
|
|
10835
10559
|
return;
|
|
10836
10560
|
this.preventDefaultWheel(e);
|
|
10837
|
-
const local = this.getLocal(e);
|
|
10838
10561
|
const eventBase = InteractionHelper.getBase(e);
|
|
10839
|
-
|
|
10840
|
-
const
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
this.
|
|
10844
|
-
this.rotate(getRotateEventData(local, changeAngle / Math.PI * 180 * (rotateSpeed / 4 + 0.1), eventBase));
|
|
10562
|
+
Object.assign(eventBase, this.getLocal(e));
|
|
10563
|
+
const scale = (e.scale / this.lastGestureScale);
|
|
10564
|
+
const rotation = (e.rotation - this.lastGestureRotation) / Math.PI * 180 * (MathHelper.within(this.config.wheel.rotateSpeed, 0, 1) / 4 + 0.1);
|
|
10565
|
+
this.zoom(Object.assign(Object.assign({}, eventBase), { scale: scale * scale }));
|
|
10566
|
+
this.rotate(Object.assign(Object.assign({}, eventBase), { rotation }));
|
|
10845
10567
|
this.lastGestureScale = e.scale;
|
|
10846
10568
|
this.lastGestureRotation = e.rotation;
|
|
10847
10569
|
}
|
|
@@ -12561,4 +12283,4 @@ Object.assign(Creator, {
|
|
|
12561
12283
|
});
|
|
12562
12284
|
useCanvas();
|
|
12563
12285
|
|
|
12564
|
-
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$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage,
|
|
12286
|
+
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$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, 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 };
|