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.js
CHANGED
|
@@ -1414,14 +1414,14 @@ var LeaferUI = (function (exports) {
|
|
|
1414
1414
|
list: {},
|
|
1415
1415
|
register(UI) {
|
|
1416
1416
|
const { __tag: tag } = UI.prototype;
|
|
1417
|
-
if (list$
|
|
1417
|
+
if (list$1[tag])
|
|
1418
1418
|
debug$f.repeat(tag);
|
|
1419
|
-
list$
|
|
1419
|
+
list$1[tag] = UI;
|
|
1420
1420
|
},
|
|
1421
1421
|
get(tag, data, x, y, width, height) {
|
|
1422
|
-
if (!list$
|
|
1422
|
+
if (!list$1[tag])
|
|
1423
1423
|
debug$f.error('not register ' + tag);
|
|
1424
|
-
const ui = new list$
|
|
1424
|
+
const ui = new list$1[tag](data);
|
|
1425
1425
|
if (x !== undefined) {
|
|
1426
1426
|
ui.x = x;
|
|
1427
1427
|
if (y)
|
|
@@ -1434,7 +1434,7 @@ var LeaferUI = (function (exports) {
|
|
|
1434
1434
|
return ui;
|
|
1435
1435
|
}
|
|
1436
1436
|
};
|
|
1437
|
-
const { list: list$
|
|
1437
|
+
const { list: list$1 } = UICreator;
|
|
1438
1438
|
|
|
1439
1439
|
const debug$e = Debug.get('EventCreator');
|
|
1440
1440
|
const EventCreator = {
|
|
@@ -1516,17 +1516,19 @@ var LeaferUI = (function (exports) {
|
|
|
1516
1516
|
assign(t, defaultData);
|
|
1517
1517
|
return t;
|
|
1518
1518
|
},
|
|
1519
|
-
assign(t, merge) {
|
|
1519
|
+
assign(t, merge, exclude) {
|
|
1520
1520
|
let value;
|
|
1521
1521
|
Object.keys(merge).forEach(key => {
|
|
1522
|
-
var _a;
|
|
1522
|
+
var _a, _b;
|
|
1523
1523
|
value = merge[key];
|
|
1524
|
-
if ((value === null || value === void 0 ? void 0 : value.constructor) === Object)
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1524
|
+
if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object)
|
|
1525
|
+
return assign(t[key], merge[key], exclude && exclude[key]);
|
|
1526
|
+
if (exclude && (key in exclude)) {
|
|
1527
|
+
if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object)
|
|
1528
|
+
assign(t[key] = {}, merge[key], exclude[key]);
|
|
1529
|
+
return;
|
|
1529
1530
|
}
|
|
1531
|
+
t[key] = merge[key];
|
|
1530
1532
|
});
|
|
1531
1533
|
},
|
|
1532
1534
|
copyAttrs(t, from, include) {
|
|
@@ -3894,6 +3896,8 @@ var LeaferUI = (function (exports) {
|
|
|
3894
3896
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3895
3897
|
set(value) {
|
|
3896
3898
|
this.__setAttr(key, value) && (this.__layout.opacityChanged || this.__layout.opacityChange());
|
|
3899
|
+
if (this.mask)
|
|
3900
|
+
checkMask(this);
|
|
3897
3901
|
}
|
|
3898
3902
|
}));
|
|
3899
3903
|
}
|
|
@@ -3910,9 +3914,20 @@ var LeaferUI = (function (exports) {
|
|
|
3910
3914
|
this.__runAnimation('in');
|
|
3911
3915
|
}
|
|
3912
3916
|
doVisible(this, key, value, oldValue);
|
|
3917
|
+
if (this.mask)
|
|
3918
|
+
checkMask(this);
|
|
3913
3919
|
}
|
|
3914
3920
|
}));
|
|
3915
3921
|
}
|
|
3922
|
+
function checkMask(leaf) {
|
|
3923
|
+
const { parent } = leaf;
|
|
3924
|
+
if (parent) {
|
|
3925
|
+
const { __hasMask } = parent;
|
|
3926
|
+
parent.__updateMask();
|
|
3927
|
+
if (__hasMask !== parent.__hasMask)
|
|
3928
|
+
parent.forceUpdate();
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3916
3931
|
function doVisible(leaf, key, value, oldValue) {
|
|
3917
3932
|
if (leaf.__setAttr(key, value)) {
|
|
3918
3933
|
leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
|
|
@@ -4051,11 +4066,11 @@ var LeaferUI = (function (exports) {
|
|
|
4051
4066
|
}
|
|
4052
4067
|
|
|
4053
4068
|
const debug$9 = new Debug('rewrite');
|
|
4054
|
-
const list
|
|
4069
|
+
const list = [];
|
|
4055
4070
|
const excludeNames = ['destroy', 'constructor'];
|
|
4056
4071
|
function rewrite(method) {
|
|
4057
4072
|
return (target, key) => {
|
|
4058
|
-
list
|
|
4073
|
+
list.push({ name: target.constructor.name + '.' + key, run: () => { target[key] = method; } });
|
|
4059
4074
|
};
|
|
4060
4075
|
}
|
|
4061
4076
|
function rewriteAble() {
|
|
@@ -4064,13 +4079,13 @@ var LeaferUI = (function (exports) {
|
|
|
4064
4079
|
};
|
|
4065
4080
|
}
|
|
4066
4081
|
function doRewrite(error) {
|
|
4067
|
-
if (list
|
|
4068
|
-
list
|
|
4082
|
+
if (list.length) {
|
|
4083
|
+
list.forEach(item => {
|
|
4069
4084
|
if (error)
|
|
4070
4085
|
debug$9.error(item.name, '需在Class上装饰@rewriteAble()');
|
|
4071
4086
|
item.run();
|
|
4072
4087
|
});
|
|
4073
|
-
list
|
|
4088
|
+
list.length = 0;
|
|
4074
4089
|
}
|
|
4075
4090
|
}
|
|
4076
4091
|
setTimeout(() => doRewrite(true));
|
|
@@ -5437,8 +5452,8 @@ var LeaferUI = (function (exports) {
|
|
|
5437
5452
|
canvas.clearRect(r.x, r.y, r.width, r.height);
|
|
5438
5453
|
canvas.restore();
|
|
5439
5454
|
}
|
|
5440
|
-
__updateMask(
|
|
5441
|
-
this.__hasMask =
|
|
5455
|
+
__updateMask(_value) {
|
|
5456
|
+
this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
|
|
5442
5457
|
}
|
|
5443
5458
|
__renderMask(_canvas, _options) { }
|
|
5444
5459
|
__getNowWorld(options) {
|
|
@@ -5681,6 +5696,7 @@ var LeaferUI = (function (exports) {
|
|
|
5681
5696
|
const { setListWithFn } = BoundsHelper;
|
|
5682
5697
|
const { sort } = BranchHelper;
|
|
5683
5698
|
const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
|
|
5699
|
+
const debug$7 = new Debug('Branch');
|
|
5684
5700
|
exports.Branch = class Branch extends exports.Leaf {
|
|
5685
5701
|
__updateStrokeSpread() {
|
|
5686
5702
|
const { children } = this;
|
|
@@ -5721,8 +5737,8 @@ var LeaferUI = (function (exports) {
|
|
|
5721
5737
|
}
|
|
5722
5738
|
}
|
|
5723
5739
|
add(child, index) {
|
|
5724
|
-
if (child === this)
|
|
5725
|
-
return;
|
|
5740
|
+
if (child === this || child.destroyed)
|
|
5741
|
+
return debug$7.warn('add self or destroyed');
|
|
5726
5742
|
const noIndex = index === undefined;
|
|
5727
5743
|
if (!child.__) {
|
|
5728
5744
|
if (child instanceof Array)
|
|
@@ -5736,8 +5752,9 @@ var LeaferUI = (function (exports) {
|
|
|
5736
5752
|
noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
|
|
5737
5753
|
if (child.isBranch)
|
|
5738
5754
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5739
|
-
|
|
5740
|
-
|
|
5755
|
+
const childLayout = child.__layout;
|
|
5756
|
+
childLayout.boxChanged || childLayout.boxChange();
|
|
5757
|
+
childLayout.matrixChanged || childLayout.matrixChange();
|
|
5741
5758
|
if (child.__bubbleMap)
|
|
5742
5759
|
child.__emitLifeEvent(ChildEvent.ADD);
|
|
5743
5760
|
if (this.leafer) {
|
|
@@ -5975,9 +5992,9 @@ var LeaferUI = (function (exports) {
|
|
|
5975
5992
|
}
|
|
5976
5993
|
}
|
|
5977
5994
|
|
|
5978
|
-
const version = "1.1.
|
|
5995
|
+
const version = "1.1.1";
|
|
5979
5996
|
|
|
5980
|
-
const debug$
|
|
5997
|
+
const debug$6 = Debug.get('LeaferCanvas');
|
|
5981
5998
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5982
5999
|
set zIndex(zIndex) {
|
|
5983
6000
|
const { style } = this.view;
|
|
@@ -6049,7 +6066,7 @@ var LeaferUI = (function (exports) {
|
|
|
6049
6066
|
}
|
|
6050
6067
|
}
|
|
6051
6068
|
else {
|
|
6052
|
-
debug$
|
|
6069
|
+
debug$6.error(`no id: ${inputView}`);
|
|
6053
6070
|
this.__createView();
|
|
6054
6071
|
}
|
|
6055
6072
|
}
|
|
@@ -6086,7 +6103,7 @@ var LeaferUI = (function (exports) {
|
|
|
6086
6103
|
}
|
|
6087
6104
|
else {
|
|
6088
6105
|
this.checkAutoBounds(this.view);
|
|
6089
|
-
debug$
|
|
6106
|
+
debug$6.warn('no parent');
|
|
6090
6107
|
}
|
|
6091
6108
|
}
|
|
6092
6109
|
catch (_a) {
|
|
@@ -6422,7 +6439,7 @@ var LeaferUI = (function (exports) {
|
|
|
6422
6439
|
}
|
|
6423
6440
|
|
|
6424
6441
|
const { updateAllMatrix, updateAllChange } = LeafHelper;
|
|
6425
|
-
const debug$
|
|
6442
|
+
const debug$5 = Debug.get('Layouter');
|
|
6426
6443
|
class Layouter {
|
|
6427
6444
|
constructor(target, userConfig) {
|
|
6428
6445
|
this.totalTimes = 0;
|
|
@@ -6457,7 +6474,7 @@ var LeaferUI = (function (exports) {
|
|
|
6457
6474
|
target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
|
|
6458
6475
|
}
|
|
6459
6476
|
catch (e) {
|
|
6460
|
-
debug$
|
|
6477
|
+
debug$5.error(e);
|
|
6461
6478
|
}
|
|
6462
6479
|
this.layoutedBlocks = null;
|
|
6463
6480
|
}
|
|
@@ -6471,9 +6488,9 @@ var LeaferUI = (function (exports) {
|
|
|
6471
6488
|
}
|
|
6472
6489
|
layoutOnce() {
|
|
6473
6490
|
if (this.layouting)
|
|
6474
|
-
return debug$
|
|
6491
|
+
return debug$5.warn('layouting');
|
|
6475
6492
|
if (this.times > 3)
|
|
6476
|
-
return debug$
|
|
6493
|
+
return debug$5.warn('layout max times');
|
|
6477
6494
|
this.times++;
|
|
6478
6495
|
this.totalTimes++;
|
|
6479
6496
|
this.layouting = true;
|
|
@@ -6577,7 +6594,7 @@ var LeaferUI = (function (exports) {
|
|
|
6577
6594
|
}
|
|
6578
6595
|
}
|
|
6579
6596
|
|
|
6580
|
-
const debug$
|
|
6597
|
+
const debug$4 = Debug.get('Renderer');
|
|
6581
6598
|
class Renderer {
|
|
6582
6599
|
get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
|
|
6583
6600
|
constructor(target, canvas, userConfig) {
|
|
@@ -6593,29 +6610,29 @@ var LeaferUI = (function (exports) {
|
|
|
6593
6610
|
if (userConfig)
|
|
6594
6611
|
this.config = DataHelper.default(userConfig, this.config);
|
|
6595
6612
|
this.__listenEvents();
|
|
6596
|
-
this.__requestRender();
|
|
6597
6613
|
}
|
|
6598
6614
|
start() {
|
|
6599
6615
|
this.running = true;
|
|
6616
|
+
this.update(false);
|
|
6600
6617
|
}
|
|
6601
6618
|
stop() {
|
|
6602
6619
|
this.running = false;
|
|
6603
6620
|
}
|
|
6604
|
-
update() {
|
|
6605
|
-
this.changed
|
|
6621
|
+
update(change = true) {
|
|
6622
|
+
if (!this.changed)
|
|
6623
|
+
this.changed = change;
|
|
6624
|
+
this.__requestRender();
|
|
6606
6625
|
}
|
|
6607
6626
|
requestLayout() {
|
|
6608
6627
|
this.target.emit(LayoutEvent.REQUEST);
|
|
6609
6628
|
}
|
|
6610
6629
|
render(callback) {
|
|
6611
|
-
if (!(this.running && this.canvas.view))
|
|
6612
|
-
this.
|
|
6613
|
-
return;
|
|
6614
|
-
}
|
|
6630
|
+
if (!(this.running && this.canvas.view))
|
|
6631
|
+
return this.update();
|
|
6615
6632
|
const { target } = this;
|
|
6616
6633
|
this.times = 0;
|
|
6617
6634
|
this.totalBounds = new Bounds();
|
|
6618
|
-
debug$
|
|
6635
|
+
debug$4.log(target.innerName, '--->');
|
|
6619
6636
|
try {
|
|
6620
6637
|
if (!target.isApp)
|
|
6621
6638
|
target.app.emit(RenderEvent.CHILD_START, target);
|
|
@@ -6626,9 +6643,9 @@ var LeaferUI = (function (exports) {
|
|
|
6626
6643
|
}
|
|
6627
6644
|
catch (e) {
|
|
6628
6645
|
this.rendering = false;
|
|
6629
|
-
debug$
|
|
6646
|
+
debug$4.error(e);
|
|
6630
6647
|
}
|
|
6631
|
-
debug$
|
|
6648
|
+
debug$4.log('-------------|');
|
|
6632
6649
|
}
|
|
6633
6650
|
renderAgain() {
|
|
6634
6651
|
if (this.rendering) {
|
|
@@ -6640,9 +6657,9 @@ var LeaferUI = (function (exports) {
|
|
|
6640
6657
|
}
|
|
6641
6658
|
renderOnce(callback) {
|
|
6642
6659
|
if (this.rendering)
|
|
6643
|
-
return debug$
|
|
6660
|
+
return debug$4.warn('rendering');
|
|
6644
6661
|
if (this.times > 3)
|
|
6645
|
-
return debug$
|
|
6662
|
+
return debug$4.warn('render max times');
|
|
6646
6663
|
this.times++;
|
|
6647
6664
|
this.totalTimes++;
|
|
6648
6665
|
this.rendering = true;
|
|
@@ -6679,7 +6696,7 @@ var LeaferUI = (function (exports) {
|
|
|
6679
6696
|
partRender() {
|
|
6680
6697
|
const { canvas, updateBlocks: list } = this;
|
|
6681
6698
|
if (!list)
|
|
6682
|
-
return debug$
|
|
6699
|
+
return debug$4.warn('PartRender: need update attr');
|
|
6683
6700
|
this.mergeBlocks();
|
|
6684
6701
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6685
6702
|
this.clipRender(block); });
|
|
@@ -6745,16 +6762,17 @@ var LeaferUI = (function (exports) {
|
|
|
6745
6762
|
}
|
|
6746
6763
|
}
|
|
6747
6764
|
__requestRender() {
|
|
6748
|
-
|
|
6765
|
+
if (this.requestTime)
|
|
6766
|
+
return;
|
|
6767
|
+
const requestTime = this.requestTime = Date.now();
|
|
6749
6768
|
Platform.requestRender(() => {
|
|
6750
|
-
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() -
|
|
6769
|
+
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
6770
|
+
this.requestTime = 0;
|
|
6751
6771
|
if (this.running) {
|
|
6752
6772
|
if (this.changed && this.canvas.view)
|
|
6753
6773
|
this.render();
|
|
6754
6774
|
this.target.emit(RenderEvent.NEXT);
|
|
6755
6775
|
}
|
|
6756
|
-
if (this.target)
|
|
6757
|
-
this.__requestRender();
|
|
6758
6776
|
});
|
|
6759
6777
|
}
|
|
6760
6778
|
__onResize(e) {
|
|
@@ -6770,7 +6788,7 @@ var LeaferUI = (function (exports) {
|
|
|
6770
6788
|
}
|
|
6771
6789
|
}
|
|
6772
6790
|
this.addBlock(new Bounds(0, 0, 1, 1));
|
|
6773
|
-
this.
|
|
6791
|
+
this.update();
|
|
6774
6792
|
}
|
|
6775
6793
|
__onLayoutEnd(event) {
|
|
6776
6794
|
if (event.data)
|
|
@@ -6781,7 +6799,7 @@ var LeaferUI = (function (exports) {
|
|
|
6781
6799
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
6782
6800
|
if (empty) {
|
|
6783
6801
|
if (!leaf.isLeafer)
|
|
6784
|
-
debug$
|
|
6802
|
+
debug$4.tip(leaf.innerName, ': empty');
|
|
6785
6803
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
6786
6804
|
}
|
|
6787
6805
|
return empty;
|
|
@@ -7156,7 +7174,7 @@ var LeaferUI = (function (exports) {
|
|
|
7156
7174
|
|
|
7157
7175
|
const { parse, objectToCanvasData } = PathConvert;
|
|
7158
7176
|
const emptyPaint = {};
|
|
7159
|
-
const debug$
|
|
7177
|
+
const debug$3 = Debug.get('UIData');
|
|
7160
7178
|
class UIData extends LeafData {
|
|
7161
7179
|
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
7162
7180
|
get __strokeWidth() {
|
|
@@ -7178,7 +7196,7 @@ var LeaferUI = (function (exports) {
|
|
|
7178
7196
|
return true;
|
|
7179
7197
|
return t.fill && this.__hasStroke;
|
|
7180
7198
|
}
|
|
7181
|
-
get __clipAfterFill() { return (
|
|
7199
|
+
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
7182
7200
|
get __autoWidth() { return !this._width; }
|
|
7183
7201
|
get __autoHeight() { return !this._height; }
|
|
7184
7202
|
get __autoSide() { return !this._width || !this._height; }
|
|
@@ -7193,7 +7211,7 @@ var LeaferUI = (function (exports) {
|
|
|
7193
7211
|
if (value < 0) {
|
|
7194
7212
|
this._width = -value;
|
|
7195
7213
|
this.__leaf.scaleX *= -1;
|
|
7196
|
-
debug$
|
|
7214
|
+
debug$3.warn('width < 0, instead -scaleX ', this);
|
|
7197
7215
|
}
|
|
7198
7216
|
else
|
|
7199
7217
|
this._width = value;
|
|
@@ -7202,7 +7220,7 @@ var LeaferUI = (function (exports) {
|
|
|
7202
7220
|
if (value < 0) {
|
|
7203
7221
|
this._height = -value;
|
|
7204
7222
|
this.__leaf.scaleY *= -1;
|
|
7205
|
-
debug$
|
|
7223
|
+
debug$3.warn('height < 0, instead -scaleY', this);
|
|
7206
7224
|
}
|
|
7207
7225
|
else
|
|
7208
7226
|
this._height = value;
|
|
@@ -7292,7 +7310,7 @@ var LeaferUI = (function (exports) {
|
|
|
7292
7310
|
|
|
7293
7311
|
class BoxData extends GroupData {
|
|
7294
7312
|
get __boxStroke() { return !this.__pathInputed; }
|
|
7295
|
-
get __drawAfterFill() { return
|
|
7313
|
+
get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
|
|
7296
7314
|
get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
|
|
7297
7315
|
}
|
|
7298
7316
|
|
|
@@ -7938,7 +7956,7 @@ var LeaferUI = (function (exports) {
|
|
|
7938
7956
|
], exports.Group);
|
|
7939
7957
|
|
|
7940
7958
|
var Leafer_1;
|
|
7941
|
-
const debug$
|
|
7959
|
+
const debug$2 = Debug.get('Leafer');
|
|
7942
7960
|
exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
7943
7961
|
get __tag() { return 'Leafer'; }
|
|
7944
7962
|
get isApp() { return false; }
|
|
@@ -7952,20 +7970,10 @@ var LeaferUI = (function (exports) {
|
|
|
7952
7970
|
constructor(userConfig, data) {
|
|
7953
7971
|
super(data);
|
|
7954
7972
|
this.config = {
|
|
7955
|
-
type: 'design',
|
|
7956
7973
|
start: true,
|
|
7957
7974
|
hittable: true,
|
|
7958
7975
|
smooth: true,
|
|
7959
|
-
lazySpeard: 100
|
|
7960
|
-
zoom: {
|
|
7961
|
-
min: 0.01,
|
|
7962
|
-
max: 256
|
|
7963
|
-
},
|
|
7964
|
-
move: {
|
|
7965
|
-
holdSpaceKey: true,
|
|
7966
|
-
holdMiddleKey: true,
|
|
7967
|
-
autoDistance: 2
|
|
7968
|
-
}
|
|
7976
|
+
lazySpeard: 100
|
|
7969
7977
|
};
|
|
7970
7978
|
this.leafs = 0;
|
|
7971
7979
|
this.__eventIds = [];
|
|
@@ -7982,23 +7990,27 @@ var LeaferUI = (function (exports) {
|
|
|
7982
7990
|
init(userConfig, parentApp) {
|
|
7983
7991
|
if (this.canvas)
|
|
7984
7992
|
return;
|
|
7985
|
-
this.__setLeafer(this);
|
|
7986
|
-
if (userConfig)
|
|
7987
|
-
DataHelper.assign(this.config, userConfig);
|
|
7988
7993
|
let start;
|
|
7989
7994
|
const { config } = this;
|
|
7990
|
-
this.
|
|
7995
|
+
this.__setLeafer(this);
|
|
7996
|
+
if (parentApp) {
|
|
7997
|
+
this.parentApp = parentApp;
|
|
7998
|
+
this.__bindApp(parentApp);
|
|
7999
|
+
start = parentApp.running;
|
|
8000
|
+
}
|
|
8001
|
+
if (userConfig) {
|
|
8002
|
+
this.parent = parentApp;
|
|
8003
|
+
this.initType(userConfig.type);
|
|
8004
|
+
this.parent = undefined;
|
|
8005
|
+
DataHelper.assign(config, userConfig);
|
|
8006
|
+
}
|
|
7991
8007
|
const canvas = this.canvas = Creator.canvas(config);
|
|
7992
8008
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7993
8009
|
if (this.isApp)
|
|
7994
8010
|
this.__setApp();
|
|
7995
8011
|
this.__checkAutoLayout(config, parentApp);
|
|
7996
8012
|
this.view = canvas.view;
|
|
7997
|
-
if (parentApp) {
|
|
7998
|
-
this.__bindApp(parentApp);
|
|
7999
|
-
start = parentApp.running;
|
|
8000
|
-
}
|
|
8001
|
-
else {
|
|
8013
|
+
if (!parentApp) {
|
|
8002
8014
|
this.selector = Creator.selector(this);
|
|
8003
8015
|
this.interaction = Creator.interaction(this, canvas, this.selector, config);
|
|
8004
8016
|
if (this.interaction) {
|
|
@@ -8055,7 +8067,11 @@ var LeaferUI = (function (exports) {
|
|
|
8055
8067
|
forceRender(bounds) {
|
|
8056
8068
|
this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
|
|
8057
8069
|
if (this.viewReady)
|
|
8058
|
-
this.renderer.
|
|
8070
|
+
this.renderer.render();
|
|
8071
|
+
}
|
|
8072
|
+
requestRender(change = false) {
|
|
8073
|
+
if (this.renderer)
|
|
8074
|
+
this.renderer.update(change);
|
|
8059
8075
|
}
|
|
8060
8076
|
updateCursor(cursor) {
|
|
8061
8077
|
const i = this.interaction;
|
|
@@ -8102,7 +8118,7 @@ var LeaferUI = (function (exports) {
|
|
|
8102
8118
|
if (this.canvas) {
|
|
8103
8119
|
if (canvasSizeAttrs.includes(attrName)) {
|
|
8104
8120
|
if (!newValue)
|
|
8105
|
-
debug$
|
|
8121
|
+
debug$2.warn(attrName + ' is 0');
|
|
8106
8122
|
this.__changeCanvasSize(attrName, newValue);
|
|
8107
8123
|
}
|
|
8108
8124
|
else if (attrName === 'fill') {
|
|
@@ -8163,8 +8179,10 @@ var LeaferUI = (function (exports) {
|
|
|
8163
8179
|
const { imageReady } = this;
|
|
8164
8180
|
if (imageReady && !this.viewCompleted)
|
|
8165
8181
|
this.__checkViewCompleted();
|
|
8166
|
-
if (!imageReady)
|
|
8182
|
+
if (!imageReady) {
|
|
8167
8183
|
this.viewCompleted = false;
|
|
8184
|
+
this.requestRender();
|
|
8185
|
+
}
|
|
8168
8186
|
}
|
|
8169
8187
|
}
|
|
8170
8188
|
__checkViewCompleted(emit = true) {
|
|
@@ -8222,6 +8240,7 @@ var LeaferUI = (function (exports) {
|
|
|
8222
8240
|
}
|
|
8223
8241
|
else
|
|
8224
8242
|
list.push(item);
|
|
8243
|
+
this.requestRender();
|
|
8225
8244
|
}
|
|
8226
8245
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
8227
8246
|
return needPlugin('view');
|
|
@@ -8275,14 +8294,14 @@ var LeaferUI = (function (exports) {
|
|
|
8275
8294
|
this.canvasManager.destroy();
|
|
8276
8295
|
}
|
|
8277
8296
|
this.canvas.destroy();
|
|
8278
|
-
this.config.view = this.view = null;
|
|
8297
|
+
this.config.view = this.view = this.parentApp = null;
|
|
8279
8298
|
if (this.userConfig)
|
|
8280
8299
|
this.userConfig.view = null;
|
|
8281
8300
|
super.destroy();
|
|
8282
8301
|
setTimeout(() => { ImageManager.clearRecycled(); }, 100);
|
|
8283
8302
|
}
|
|
8284
8303
|
catch (e) {
|
|
8285
|
-
debug$
|
|
8304
|
+
debug$2.error(e);
|
|
8286
8305
|
}
|
|
8287
8306
|
}
|
|
8288
8307
|
};
|
|
@@ -9002,9 +9021,9 @@ var LeaferUI = (function (exports) {
|
|
|
9002
9021
|
if (ground)
|
|
9003
9022
|
this.ground = this.addLeafer(ground);
|
|
9004
9023
|
if (tree || editor)
|
|
9005
|
-
this.tree = this.addLeafer(tree);
|
|
9024
|
+
this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
|
|
9006
9025
|
if (sky || editor)
|
|
9007
|
-
this.sky = this.addLeafer(sky
|
|
9026
|
+
this.sky = this.addLeafer(sky);
|
|
9008
9027
|
if (editor)
|
|
9009
9028
|
this.sky.add(this.editor = Creator.editor(editor));
|
|
9010
9029
|
}
|
|
@@ -9358,184 +9377,7 @@ var LeaferUI = (function (exports) {
|
|
|
9358
9377
|
registerUIEvent()
|
|
9359
9378
|
], exports.KeyEvent);
|
|
9360
9379
|
|
|
9361
|
-
function addInteractionWindow(leafer) {
|
|
9362
|
-
if (leafer.isApp)
|
|
9363
|
-
return;
|
|
9364
|
-
leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => {
|
|
9365
|
-
leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
|
|
9366
|
-
}), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
|
|
9367
|
-
const { zoomLayer } = leafer;
|
|
9368
|
-
const changeScale = leafer.getValidScale(e.scale);
|
|
9369
|
-
if (changeScale !== 1) {
|
|
9370
|
-
PointHelper.scaleOf(zoomLayer, e, changeScale);
|
|
9371
|
-
zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
|
|
9372
|
-
}
|
|
9373
|
-
}));
|
|
9374
|
-
}
|
|
9375
|
-
|
|
9376
|
-
function document$1(leafer) {
|
|
9377
|
-
addInteractionWindow(leafer);
|
|
9378
|
-
const { move, zoom } = leafer.config;
|
|
9379
|
-
move.scroll = 'limit';
|
|
9380
|
-
zoom.min = 1;
|
|
9381
|
-
}
|
|
9382
|
-
|
|
9383
|
-
function block(leafer) {
|
|
9384
|
-
const { config } = leafer;
|
|
9385
|
-
(config.wheel || (config.wheel = {})).preventDefault = false;
|
|
9386
|
-
(config.touch || (config.touch = {})).preventDefault = 'auto';
|
|
9387
|
-
}
|
|
9388
|
-
|
|
9389
|
-
const debug$2 = Debug.get('LeaferTypeCreator');
|
|
9390
|
-
const LeaferTypeCreator = {
|
|
9391
|
-
list: {},
|
|
9392
|
-
register(name, fn) {
|
|
9393
|
-
list[name] && debug$2.repeat(name);
|
|
9394
|
-
list[name] = fn;
|
|
9395
|
-
},
|
|
9396
|
-
run(name, leafer) {
|
|
9397
|
-
const fn = list[name];
|
|
9398
|
-
fn && fn(leafer);
|
|
9399
|
-
}
|
|
9400
|
-
};
|
|
9401
|
-
const { list, register } = LeaferTypeCreator;
|
|
9402
|
-
register('design', addInteractionWindow);
|
|
9403
|
-
register('document', document$1);
|
|
9404
|
-
register('block', block);
|
|
9405
|
-
|
|
9406
|
-
const leafer = exports.Leafer.prototype;
|
|
9407
|
-
leafer.initType = function (type) {
|
|
9408
|
-
LeaferTypeCreator.run(type, this);
|
|
9409
|
-
};
|
|
9410
|
-
leafer.getValidMove = function (moveX, moveY) {
|
|
9411
|
-
const { scroll, disabled } = this.app.config.move;
|
|
9412
|
-
if (scroll) {
|
|
9413
|
-
Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
|
|
9414
|
-
if (scroll === 'limit') {
|
|
9415
|
-
const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
|
|
9416
|
-
const right = x + width - this.width, bottom = y + height - this.height;
|
|
9417
|
-
if (x >= 0 && right <= 0)
|
|
9418
|
-
moveX = 0;
|
|
9419
|
-
else if (moveX > 0) {
|
|
9420
|
-
if (x + moveX > 0)
|
|
9421
|
-
moveX = -x;
|
|
9422
|
-
}
|
|
9423
|
-
else if (moveX < 0 && right + moveX < 0)
|
|
9424
|
-
moveX = -right;
|
|
9425
|
-
if (y >= 0 && bottom <= 0)
|
|
9426
|
-
moveY = 0;
|
|
9427
|
-
else if (moveY > 0) {
|
|
9428
|
-
if (y + moveY > 0)
|
|
9429
|
-
moveY = -y;
|
|
9430
|
-
}
|
|
9431
|
-
else if (moveY < 0 && bottom + moveY < 0)
|
|
9432
|
-
moveY = -bottom;
|
|
9433
|
-
}
|
|
9434
|
-
}
|
|
9435
|
-
return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
|
|
9436
|
-
};
|
|
9437
|
-
leafer.getValidScale = function (changeScale) {
|
|
9438
|
-
const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
|
|
9439
|
-
if (absScale < min)
|
|
9440
|
-
changeScale = min / scaleX;
|
|
9441
|
-
else if (absScale > max)
|
|
9442
|
-
changeScale = max / scaleX;
|
|
9443
|
-
return disabled ? 1 : changeScale;
|
|
9444
|
-
};
|
|
9445
|
-
|
|
9446
|
-
class Transformer {
|
|
9447
|
-
get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
|
|
9448
|
-
constructor(interaction) {
|
|
9449
|
-
this.interaction = interaction;
|
|
9450
|
-
}
|
|
9451
|
-
move(data) {
|
|
9452
|
-
const { interaction } = this;
|
|
9453
|
-
if (!data.moveType)
|
|
9454
|
-
data.moveType = 'move';
|
|
9455
|
-
if (!this.moveData) {
|
|
9456
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9457
|
-
data.path = path;
|
|
9458
|
-
this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
|
|
9459
|
-
interaction.cancelHover();
|
|
9460
|
-
interaction.emit(exports.MoveEvent.START, this.moveData);
|
|
9461
|
-
}
|
|
9462
|
-
data.path = this.moveData.path;
|
|
9463
|
-
interaction.emit(exports.MoveEvent.BEFORE_MOVE, data);
|
|
9464
|
-
interaction.emit(exports.MoveEvent.MOVE, data);
|
|
9465
|
-
this.transformEndWait();
|
|
9466
|
-
}
|
|
9467
|
-
zoom(data) {
|
|
9468
|
-
const { interaction } = this;
|
|
9469
|
-
if (!this.zoomData) {
|
|
9470
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9471
|
-
data.path = path;
|
|
9472
|
-
this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
|
|
9473
|
-
interaction.cancelHover();
|
|
9474
|
-
interaction.emit(exports.ZoomEvent.START, this.zoomData);
|
|
9475
|
-
}
|
|
9476
|
-
data.path = this.zoomData.path;
|
|
9477
|
-
interaction.emit(exports.ZoomEvent.BEFORE_ZOOM, data);
|
|
9478
|
-
interaction.emit(exports.ZoomEvent.ZOOM, data);
|
|
9479
|
-
this.transformEndWait();
|
|
9480
|
-
}
|
|
9481
|
-
rotate(data) {
|
|
9482
|
-
const { interaction } = this;
|
|
9483
|
-
if (!this.rotateData) {
|
|
9484
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9485
|
-
data.path = path;
|
|
9486
|
-
this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
|
|
9487
|
-
interaction.cancelHover();
|
|
9488
|
-
interaction.emit(exports.RotateEvent.START, this.rotateData);
|
|
9489
|
-
}
|
|
9490
|
-
data.path = this.rotateData.path;
|
|
9491
|
-
interaction.emit(exports.RotateEvent.BEFORE_ROTATE, data);
|
|
9492
|
-
interaction.emit(exports.RotateEvent.ROTATE, data);
|
|
9493
|
-
this.transformEndWait();
|
|
9494
|
-
}
|
|
9495
|
-
transformEndWait() {
|
|
9496
|
-
clearTimeout(this.transformTimer);
|
|
9497
|
-
this.transformTimer = setTimeout(() => {
|
|
9498
|
-
this.transformEnd();
|
|
9499
|
-
}, this.interaction.config.pointer.transformTime);
|
|
9500
|
-
}
|
|
9501
|
-
transformEnd() {
|
|
9502
|
-
this.moveEnd();
|
|
9503
|
-
this.zoomEnd();
|
|
9504
|
-
this.rotateEnd();
|
|
9505
|
-
}
|
|
9506
|
-
moveEnd() {
|
|
9507
|
-
if (this.moveData) {
|
|
9508
|
-
this.interaction.emit(exports.MoveEvent.END, this.moveData);
|
|
9509
|
-
this.moveData = null;
|
|
9510
|
-
}
|
|
9511
|
-
}
|
|
9512
|
-
zoomEnd() {
|
|
9513
|
-
if (this.zoomData) {
|
|
9514
|
-
this.interaction.emit(exports.ZoomEvent.END, this.zoomData);
|
|
9515
|
-
this.zoomData = null;
|
|
9516
|
-
}
|
|
9517
|
-
}
|
|
9518
|
-
rotateEnd() {
|
|
9519
|
-
if (this.rotateData) {
|
|
9520
|
-
this.interaction.emit(exports.RotateEvent.END, this.rotateData);
|
|
9521
|
-
this.rotateData = null;
|
|
9522
|
-
}
|
|
9523
|
-
}
|
|
9524
|
-
destroy() {
|
|
9525
|
-
this.zoomData = this.moveData = this.rotateData = null;
|
|
9526
|
-
}
|
|
9527
|
-
}
|
|
9528
|
-
|
|
9529
9380
|
const InteractionHelper = {
|
|
9530
|
-
getMoveEventData(center, move, event) {
|
|
9531
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, moveX: move.x, moveY: move.y });
|
|
9532
|
-
},
|
|
9533
|
-
getRotateEventData(center, angle, event) {
|
|
9534
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, rotation: angle });
|
|
9535
|
-
},
|
|
9536
|
-
getZoomEventData(center, scale, event) {
|
|
9537
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, scale });
|
|
9538
|
-
},
|
|
9539
9381
|
getDragEventData(startPoint, lastPoint, event) {
|
|
9540
9382
|
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 });
|
|
9541
9383
|
},
|
|
@@ -9544,18 +9386,14 @@ var LeaferUI = (function (exports) {
|
|
|
9544
9386
|
data });
|
|
9545
9387
|
},
|
|
9546
9388
|
getSwipeDirection(angle) {
|
|
9547
|
-
if (angle < -45 && angle > -135)
|
|
9389
|
+
if (angle < -45 && angle > -135)
|
|
9548
9390
|
return exports.SwipeEvent.UP;
|
|
9549
|
-
|
|
9550
|
-
else if (angle > 45 && angle < 135) {
|
|
9391
|
+
else if (angle > 45 && angle < 135)
|
|
9551
9392
|
return exports.SwipeEvent.DOWN;
|
|
9552
|
-
|
|
9553
|
-
else if (angle <= 45 && angle >= -45) {
|
|
9393
|
+
else if (angle <= 45 && angle >= -45)
|
|
9554
9394
|
return exports.SwipeEvent.RIGHT;
|
|
9555
|
-
|
|
9556
|
-
else {
|
|
9395
|
+
else
|
|
9557
9396
|
return exports.SwipeEvent.LEFT;
|
|
9558
|
-
}
|
|
9559
9397
|
},
|
|
9560
9398
|
getSwipeEventData(startPoint, lastDragData, event) {
|
|
9561
9399
|
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)) });
|
|
@@ -9628,9 +9466,8 @@ var LeaferUI = (function (exports) {
|
|
|
9628
9466
|
interaction.emit(exports.MoveEvent.START, this.dragData);
|
|
9629
9467
|
}
|
|
9630
9468
|
}
|
|
9631
|
-
if (!this.moving)
|
|
9469
|
+
if (!this.moving)
|
|
9632
9470
|
this.dragStart(data, canDrag);
|
|
9633
|
-
}
|
|
9634
9471
|
this.drag(data);
|
|
9635
9472
|
}
|
|
9636
9473
|
dragStart(data, canDrag) {
|
|
@@ -9708,16 +9545,9 @@ var LeaferUI = (function (exports) {
|
|
|
9708
9545
|
dragEnd(data, speed) {
|
|
9709
9546
|
if (!this.dragging && !this.moving)
|
|
9710
9547
|
return;
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
speed = (speed || (data.pointerType === 'touch' ? 2 : 1)) * 0.9;
|
|
9715
|
-
PointHelper.move(data, moveX * speed, moveY * speed);
|
|
9716
|
-
this.drag(data);
|
|
9717
|
-
this.animate(() => { this.dragEnd(data, 1); });
|
|
9718
|
-
}
|
|
9719
|
-
else
|
|
9720
|
-
this.dragEndReal(data);
|
|
9548
|
+
if (this.checkDragEndAnimate(data, speed))
|
|
9549
|
+
return;
|
|
9550
|
+
this.dragEndReal(data);
|
|
9721
9551
|
}
|
|
9722
9552
|
dragEndReal(data) {
|
|
9723
9553
|
const { interaction, downData, dragData } = this;
|
|
@@ -9744,12 +9574,6 @@ var LeaferUI = (function (exports) {
|
|
|
9744
9574
|
this.dragReset();
|
|
9745
9575
|
this.animate(null, 'off');
|
|
9746
9576
|
}
|
|
9747
|
-
animate(func, off) {
|
|
9748
|
-
const animateWait = func || this.animateWait;
|
|
9749
|
-
if (animateWait)
|
|
9750
|
-
this.interaction.target.nextRender(animateWait, null, off);
|
|
9751
|
-
this.animateWait = func;
|
|
9752
|
-
}
|
|
9753
9577
|
swipe(data, downData, dragData, endDragData) {
|
|
9754
9578
|
const { interaction } = this;
|
|
9755
9579
|
if (PointHelper.getDistance(downData, data) > interaction.config.pointer.swipeDistance) {
|
|
@@ -9766,39 +9590,11 @@ var LeaferUI = (function (exports) {
|
|
|
9766
9590
|
dragReset() {
|
|
9767
9591
|
exports.DragEvent.list = exports.DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
|
|
9768
9592
|
}
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
}
|
|
9775
|
-
autoMoveOnDragOut(data) {
|
|
9776
|
-
const { interaction, downData, canDragOut } = this;
|
|
9777
|
-
const { autoDistance, dragOut } = interaction.config.move;
|
|
9778
|
-
if (!dragOut || !canDragOut || !autoDistance)
|
|
9779
|
-
return;
|
|
9780
|
-
const bounds = interaction.shrinkCanvasBounds;
|
|
9781
|
-
const { x, y } = bounds;
|
|
9782
|
-
const right = BoundsHelper.maxX(bounds);
|
|
9783
|
-
const bottom = BoundsHelper.maxY(bounds);
|
|
9784
|
-
const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
|
|
9785
|
-
const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
|
|
9786
|
-
let totalX = 0, totalY = 0;
|
|
9787
|
-
this.autoMoveTimer = setInterval(() => {
|
|
9788
|
-
totalX += moveX;
|
|
9789
|
-
totalY += moveY;
|
|
9790
|
-
PointHelper.move(downData, moveX, moveY);
|
|
9791
|
-
PointHelper.move(this.dragData, moveX, moveY);
|
|
9792
|
-
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
|
|
9793
|
-
interaction.pointerMoveReal(data);
|
|
9794
|
-
}, 10);
|
|
9795
|
-
}
|
|
9796
|
-
autoMoveCancel() {
|
|
9797
|
-
if (this.autoMoveTimer) {
|
|
9798
|
-
clearInterval(this.autoMoveTimer);
|
|
9799
|
-
this.autoMoveTimer = 0;
|
|
9800
|
-
}
|
|
9801
|
-
}
|
|
9593
|
+
checkDragEndAnimate(_data, _speed) { return false; }
|
|
9594
|
+
animate(_func, _off) { }
|
|
9595
|
+
checkDragOut(_data) { }
|
|
9596
|
+
autoMoveOnDragOut(_data) { }
|
|
9597
|
+
autoMoveCancel() { }
|
|
9802
9598
|
destroy() {
|
|
9803
9599
|
this.dragReset();
|
|
9804
9600
|
}
|
|
@@ -9868,28 +9664,12 @@ var LeaferUI = (function (exports) {
|
|
|
9868
9664
|
return excludePath && excludePath.has(leaf);
|
|
9869
9665
|
}
|
|
9870
9666
|
|
|
9871
|
-
const MultiTouchHelper = {
|
|
9872
|
-
getData(list) {
|
|
9873
|
-
const a = list[0];
|
|
9874
|
-
const b = list[1];
|
|
9875
|
-
const lastCenter = PointHelper.getCenter(a.from, b.from);
|
|
9876
|
-
const center = PointHelper.getCenter(a.to, b.to);
|
|
9877
|
-
const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
|
|
9878
|
-
const lastDistance = PointHelper.getDistance(a.from, b.from);
|
|
9879
|
-
const distance = PointHelper.getDistance(a.to, b.to);
|
|
9880
|
-
const scale = distance / lastDistance;
|
|
9881
|
-
const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
|
|
9882
|
-
return { move, scale, angle, center };
|
|
9883
|
-
}
|
|
9884
|
-
};
|
|
9885
|
-
|
|
9886
9667
|
const config = {
|
|
9887
9668
|
wheel: {
|
|
9888
9669
|
zoomSpeed: 0.5,
|
|
9889
9670
|
moveSpeed: 0.5,
|
|
9890
9671
|
rotateSpeed: 0.5,
|
|
9891
9672
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9892
|
-
preventDefault: true
|
|
9893
9673
|
},
|
|
9894
9674
|
pointer: {
|
|
9895
9675
|
hitRadius: 5,
|
|
@@ -9900,17 +9680,18 @@ var LeaferUI = (function (exports) {
|
|
|
9900
9680
|
dragHover: true,
|
|
9901
9681
|
dragDistance: 2,
|
|
9902
9682
|
swipeDistance: 20,
|
|
9903
|
-
preventDefaultMenu: true
|
|
9904
9683
|
},
|
|
9905
9684
|
touch: {
|
|
9906
|
-
preventDefault:
|
|
9685
|
+
preventDefault: 'auto'
|
|
9907
9686
|
},
|
|
9908
9687
|
multiTouch: {},
|
|
9688
|
+
move: { autoDistance: 2 },
|
|
9689
|
+
zoom: {},
|
|
9909
9690
|
cursor: true,
|
|
9910
9691
|
keyEvent: true
|
|
9911
9692
|
};
|
|
9912
9693
|
|
|
9913
|
-
const { pathHasEventType,
|
|
9694
|
+
const { pathHasEventType, pathCanDrag: pathCanDrag$1, pathHasOutside } = InteractionHelper;
|
|
9914
9695
|
class InteractionBase {
|
|
9915
9696
|
get dragging() { return this.dragger.dragging; }
|
|
9916
9697
|
get transforming() { return this.transformer.transforming; }
|
|
@@ -9932,7 +9713,7 @@ var LeaferUI = (function (exports) {
|
|
|
9932
9713
|
this.canvas = canvas;
|
|
9933
9714
|
this.selector = selector;
|
|
9934
9715
|
this.defaultPath = new LeafList(target);
|
|
9935
|
-
this.
|
|
9716
|
+
this.createTransformer();
|
|
9936
9717
|
this.dragger = new Dragger(this);
|
|
9937
9718
|
if (userConfig)
|
|
9938
9719
|
this.config = DataHelper.default(userConfig, this.config);
|
|
@@ -10033,14 +9814,6 @@ var LeaferUI = (function (exports) {
|
|
|
10033
9814
|
data.isCancel = true;
|
|
10034
9815
|
this.pointerUp(data);
|
|
10035
9816
|
}
|
|
10036
|
-
multiTouch(data, list) {
|
|
10037
|
-
if (this.config.multiTouch.disabled)
|
|
10038
|
-
return;
|
|
10039
|
-
const { move, angle, scale, center } = MultiTouchHelper.getData(list);
|
|
10040
|
-
this.rotate(getRotateEventData$1(center, angle, data));
|
|
10041
|
-
this.zoom(getZoomEventData$1(center, scale, data));
|
|
10042
|
-
this.move(getMoveEventData$1(center, move, data));
|
|
10043
|
-
}
|
|
10044
9817
|
menu(data) {
|
|
10045
9818
|
this.findPath(data);
|
|
10046
9819
|
this.emit(exports.PointerEvent.MENU, data);
|
|
@@ -10054,18 +9827,13 @@ var LeaferUI = (function (exports) {
|
|
|
10054
9827
|
this.waitRightTap = this.waitMenuTap = false;
|
|
10055
9828
|
}
|
|
10056
9829
|
}
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
}
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
}
|
|
10063
|
-
|
|
10064
|
-
this.transformer.rotate(data);
|
|
10065
|
-
}
|
|
10066
|
-
transformEnd() {
|
|
10067
|
-
this.transformer.transformEnd();
|
|
10068
|
-
}
|
|
9830
|
+
createTransformer() { }
|
|
9831
|
+
move(_data) { }
|
|
9832
|
+
zoom(_data) { }
|
|
9833
|
+
rotate(_data) { }
|
|
9834
|
+
transformEnd() { }
|
|
9835
|
+
wheel(_data) { }
|
|
9836
|
+
multiTouch(_data, _list) { }
|
|
10069
9837
|
keyDown(data) {
|
|
10070
9838
|
if (!this.config.keyEvent)
|
|
10071
9839
|
return;
|
|
@@ -10303,8 +10071,9 @@ var LeaferUI = (function (exports) {
|
|
|
10303
10071
|
this.longPressed = false;
|
|
10304
10072
|
}
|
|
10305
10073
|
__onResize() {
|
|
10074
|
+
const { dragOut } = this.m;
|
|
10306
10075
|
this.shrinkCanvasBounds = new Bounds(this.canvas.bounds);
|
|
10307
|
-
this.shrinkCanvasBounds.spread(-2);
|
|
10076
|
+
this.shrinkCanvasBounds.spread(-(typeof dragOut === 'number' ? dragOut : 2));
|
|
10308
10077
|
}
|
|
10309
10078
|
__listenEvents() {
|
|
10310
10079
|
const { target } = this;
|
|
@@ -10324,7 +10093,8 @@ var LeaferUI = (function (exports) {
|
|
|
10324
10093
|
this.stop();
|
|
10325
10094
|
this.__removeListenEvents();
|
|
10326
10095
|
this.dragger.destroy();
|
|
10327
|
-
this.transformer
|
|
10096
|
+
if (this.transformer)
|
|
10097
|
+
this.transformer.destroy();
|
|
10328
10098
|
this.downData = this.overPath = this.enterPath = null;
|
|
10329
10099
|
}
|
|
10330
10100
|
}
|
|
@@ -10560,46 +10330,6 @@ var LeaferUI = (function (exports) {
|
|
|
10560
10330
|
}
|
|
10561
10331
|
};
|
|
10562
10332
|
|
|
10563
|
-
const WheelEventHelper = {
|
|
10564
|
-
getMove(e, config) {
|
|
10565
|
-
let { moveSpeed } = config;
|
|
10566
|
-
let { deltaX, deltaY } = e;
|
|
10567
|
-
if (e.shiftKey && !deltaX) {
|
|
10568
|
-
deltaX = deltaY;
|
|
10569
|
-
deltaY = 0;
|
|
10570
|
-
}
|
|
10571
|
-
if (deltaX > 50)
|
|
10572
|
-
deltaX = Math.max(50, deltaX / 3);
|
|
10573
|
-
if (deltaY > 50)
|
|
10574
|
-
deltaY = Math.max(50, deltaY / 3);
|
|
10575
|
-
return { x: -deltaX * moveSpeed * 2, y: -deltaY * moveSpeed * 2 };
|
|
10576
|
-
},
|
|
10577
|
-
getScale(e, config) {
|
|
10578
|
-
let zoom;
|
|
10579
|
-
let scale = 1;
|
|
10580
|
-
let { zoomMode, zoomSpeed } = config;
|
|
10581
|
-
const delta = e.deltaY || e.deltaX;
|
|
10582
|
-
if (zoomMode) {
|
|
10583
|
-
zoom = (zoomMode === 'mouse') ? true : (!e.deltaX && (Platform.intWheelDeltaY ? Math.abs(delta) > 17 : Math.ceil(delta) !== delta));
|
|
10584
|
-
if (e.shiftKey || e.metaKey || e.ctrlKey)
|
|
10585
|
-
zoom = true;
|
|
10586
|
-
}
|
|
10587
|
-
else {
|
|
10588
|
-
zoom = !e.shiftKey && (e.metaKey || e.ctrlKey);
|
|
10589
|
-
}
|
|
10590
|
-
if (zoom) {
|
|
10591
|
-
zoomSpeed = MathHelper.within(zoomSpeed, 0, 1);
|
|
10592
|
-
const min = e.deltaY ? config.delta.y : config.delta.x;
|
|
10593
|
-
scale = 1 - delta / (min * 4) * zoomSpeed;
|
|
10594
|
-
if (scale < 0.5)
|
|
10595
|
-
scale = 0.5;
|
|
10596
|
-
if (scale >= 1.5)
|
|
10597
|
-
scale = 1.5;
|
|
10598
|
-
}
|
|
10599
|
-
return scale;
|
|
10600
|
-
}
|
|
10601
|
-
};
|
|
10602
|
-
|
|
10603
10333
|
const KeyEventHelper = {
|
|
10604
10334
|
convert(e) {
|
|
10605
10335
|
const base = InteractionHelper.getBase(e);
|
|
@@ -10608,7 +10338,7 @@ var LeaferUI = (function (exports) {
|
|
|
10608
10338
|
}
|
|
10609
10339
|
};
|
|
10610
10340
|
|
|
10611
|
-
const {
|
|
10341
|
+
const { pathCanDrag } = InteractionHelper;
|
|
10612
10342
|
class Interaction extends InteractionBase {
|
|
10613
10343
|
__listenEvents() {
|
|
10614
10344
|
super.__listenEvents();
|
|
@@ -10818,13 +10548,7 @@ var LeaferUI = (function (exports) {
|
|
|
10818
10548
|
}
|
|
10819
10549
|
onWheel(e) {
|
|
10820
10550
|
this.preventDefaultWheel(e);
|
|
10821
|
-
|
|
10822
|
-
if (wheel.disabled)
|
|
10823
|
-
return;
|
|
10824
|
-
const scale = wheel.getScale ? wheel.getScale(e, wheel) : WheelEventHelper.getScale(e, wheel);
|
|
10825
|
-
const local = this.getLocal(e);
|
|
10826
|
-
const eventBase = InteractionHelper.getBase(e);
|
|
10827
|
-
scale !== 1 ? this.zoom(getZoomEventData(local, scale, eventBase)) : this.move(getMoveEventData(local, wheel.getMove ? wheel.getMove(e, wheel) : WheelEventHelper.getMove(e, wheel), eventBase));
|
|
10551
|
+
this.wheel(Object.assign(Object.assign(Object.assign({}, InteractionHelper.getBase(e)), this.getLocal(e)), { deltaX: e.deltaX, deltaY: e.deltaY }));
|
|
10828
10552
|
}
|
|
10829
10553
|
onGesturestart(e) {
|
|
10830
10554
|
if (this.useMultiTouch)
|
|
@@ -10837,14 +10561,12 @@ var LeaferUI = (function (exports) {
|
|
|
10837
10561
|
if (this.useMultiTouch)
|
|
10838
10562
|
return;
|
|
10839
10563
|
this.preventDefaultWheel(e);
|
|
10840
|
-
const local = this.getLocal(e);
|
|
10841
10564
|
const eventBase = InteractionHelper.getBase(e);
|
|
10842
|
-
|
|
10843
|
-
const
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
this.
|
|
10847
|
-
this.rotate(getRotateEventData(local, changeAngle / Math.PI * 180 * (rotateSpeed / 4 + 0.1), eventBase));
|
|
10565
|
+
Object.assign(eventBase, this.getLocal(e));
|
|
10566
|
+
const scale = (e.scale / this.lastGestureScale);
|
|
10567
|
+
const rotation = (e.rotation - this.lastGestureRotation) / Math.PI * 180 * (MathHelper.within(this.config.wheel.rotateSpeed, 0, 1) / 4 + 0.1);
|
|
10568
|
+
this.zoom(Object.assign(Object.assign({}, eventBase), { scale: scale * scale }));
|
|
10569
|
+
this.rotate(Object.assign(Object.assign({}, eventBase), { rotation }));
|
|
10848
10570
|
this.lastGestureScale = e.scale;
|
|
10849
10571
|
this.lastGestureRotation = e.rotation;
|
|
10850
10572
|
}
|
|
@@ -12581,6 +12303,7 @@ var LeaferUI = (function (exports) {
|
|
|
12581
12303
|
exports.Cursor = Cursor;
|
|
12582
12304
|
exports.DataHelper = DataHelper;
|
|
12583
12305
|
exports.Debug = Debug;
|
|
12306
|
+
exports.Dragger = Dragger;
|
|
12584
12307
|
exports.Effect = Effect;
|
|
12585
12308
|
exports.EllipseData = EllipseData;
|
|
12586
12309
|
exports.EllipseHelper = EllipseHelper;
|
|
@@ -12618,12 +12341,10 @@ var LeaferUI = (function (exports) {
|
|
|
12618
12341
|
exports.LeaferData = LeaferData;
|
|
12619
12342
|
exports.LeaferEvent = LeaferEvent;
|
|
12620
12343
|
exports.LeaferImage = LeaferImage;
|
|
12621
|
-
exports.LeaferTypeCreator = LeaferTypeCreator;
|
|
12622
12344
|
exports.LineData = LineData;
|
|
12623
12345
|
exports.MathHelper = MathHelper;
|
|
12624
12346
|
exports.Matrix = Matrix;
|
|
12625
12347
|
exports.MatrixHelper = MatrixHelper;
|
|
12626
|
-
exports.MultiTouchHelper = MultiTouchHelper;
|
|
12627
12348
|
exports.MyDragEvent = MyDragEvent;
|
|
12628
12349
|
exports.MyImage = MyImage;
|
|
12629
12350
|
exports.MyPointerEvent = MyPointerEvent;
|
|
@@ -12679,7 +12400,6 @@ var LeaferUI = (function (exports) {
|
|
|
12679
12400
|
exports.WaitHelper = WaitHelper;
|
|
12680
12401
|
exports.WatchEvent = WatchEvent;
|
|
12681
12402
|
exports.Watcher = Watcher;
|
|
12682
|
-
exports.addInteractionWindow = addInteractionWindow;
|
|
12683
12403
|
exports.affectRenderBoundsType = affectRenderBoundsType;
|
|
12684
12404
|
exports.affectStrokeBoundsType = affectStrokeBoundsType;
|
|
12685
12405
|
exports.attr = attr;
|