@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.js
CHANGED
|
@@ -111,7 +111,7 @@ var LeaferUI = (function (exports) {
|
|
|
111
111
|
return rotation - oldRotation;
|
|
112
112
|
},
|
|
113
113
|
float(num, maxLength) {
|
|
114
|
-
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
114
|
+
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
115
115
|
num = round(num * a) / a;
|
|
116
116
|
return num === -0 ? 0 : num;
|
|
117
117
|
},
|
|
@@ -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$e.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$e.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$d = 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$8 = 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$8.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));
|
|
@@ -4168,20 +4183,17 @@ var LeaferUI = (function (exports) {
|
|
|
4168
4183
|
}
|
|
4169
4184
|
return true;
|
|
4170
4185
|
},
|
|
4171
|
-
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4186
|
+
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4172
4187
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4173
4188
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4174
|
-
L.moveLocal(t, local.x, local.y);
|
|
4189
|
+
L.moveLocal(t, local.x, local.y, transition);
|
|
4175
4190
|
},
|
|
4176
|
-
moveLocal(t, x, y = 0) {
|
|
4177
|
-
if (typeof x === 'object')
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
t.x += x;
|
|
4183
|
-
t.y += y;
|
|
4184
|
-
}
|
|
4191
|
+
moveLocal(t, x, y = 0, transition) {
|
|
4192
|
+
if (typeof x === 'object')
|
|
4193
|
+
y = x.y, x = x.x;
|
|
4194
|
+
x += t.x;
|
|
4195
|
+
y += t.y;
|
|
4196
|
+
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4185
4197
|
},
|
|
4186
4198
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4187
4199
|
L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -5440,8 +5452,8 @@ var LeaferUI = (function (exports) {
|
|
|
5440
5452
|
canvas.clearRect(r.x, r.y, r.width, r.height);
|
|
5441
5453
|
canvas.restore();
|
|
5442
5454
|
}
|
|
5443
|
-
__updateMask(
|
|
5444
|
-
this.__hasMask =
|
|
5455
|
+
__updateMask(_value) {
|
|
5456
|
+
this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
|
|
5445
5457
|
}
|
|
5446
5458
|
__renderMask(_canvas, _options) { }
|
|
5447
5459
|
__getNowWorld(options) {
|
|
@@ -5561,11 +5573,11 @@ var LeaferUI = (function (exports) {
|
|
|
5561
5573
|
transform(matrix, resize) {
|
|
5562
5574
|
transform(this, matrix, resize);
|
|
5563
5575
|
}
|
|
5564
|
-
move(x, y) {
|
|
5565
|
-
moveLocal(this, x, y);
|
|
5576
|
+
move(x, y, transition) {
|
|
5577
|
+
moveLocal(this, x, y, transition);
|
|
5566
5578
|
}
|
|
5567
|
-
moveInner(x, y) {
|
|
5568
|
-
moveWorld(this, x, y, true);
|
|
5579
|
+
moveInner(x, y, transition) {
|
|
5580
|
+
moveWorld(this, x, y, true, transition);
|
|
5569
5581
|
}
|
|
5570
5582
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5571
5583
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
@@ -5579,8 +5591,8 @@ var LeaferUI = (function (exports) {
|
|
|
5579
5591
|
transformWorld(worldTransform, resize) {
|
|
5580
5592
|
transformWorld(this, worldTransform, resize);
|
|
5581
5593
|
}
|
|
5582
|
-
moveWorld(x, y) {
|
|
5583
|
-
moveWorld(this, x, y);
|
|
5594
|
+
moveWorld(x, y, transition) {
|
|
5595
|
+
moveWorld(this, x, y, false, transition);
|
|
5584
5596
|
}
|
|
5585
5597
|
scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
|
|
5586
5598
|
zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
|
|
@@ -5684,6 +5696,7 @@ var LeaferUI = (function (exports) {
|
|
|
5684
5696
|
const { setListWithFn } = BoundsHelper;
|
|
5685
5697
|
const { sort } = BranchHelper;
|
|
5686
5698
|
const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
|
|
5699
|
+
const debug$6 = new Debug('Branch');
|
|
5687
5700
|
exports.Branch = class Branch extends exports.Leaf {
|
|
5688
5701
|
__updateStrokeSpread() {
|
|
5689
5702
|
const { children } = this;
|
|
@@ -5724,8 +5737,8 @@ var LeaferUI = (function (exports) {
|
|
|
5724
5737
|
}
|
|
5725
5738
|
}
|
|
5726
5739
|
add(child, index) {
|
|
5727
|
-
if (child === this)
|
|
5728
|
-
return;
|
|
5740
|
+
if (child === this || child.destroyed)
|
|
5741
|
+
return debug$6.warn('add self or destroyed');
|
|
5729
5742
|
const noIndex = index === undefined;
|
|
5730
5743
|
if (!child.__) {
|
|
5731
5744
|
if (child instanceof Array)
|
|
@@ -5739,8 +5752,9 @@ var LeaferUI = (function (exports) {
|
|
|
5739
5752
|
noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
|
|
5740
5753
|
if (child.isBranch)
|
|
5741
5754
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5742
|
-
|
|
5743
|
-
|
|
5755
|
+
const childLayout = child.__layout;
|
|
5756
|
+
childLayout.boxChanged || childLayout.boxChange();
|
|
5757
|
+
childLayout.matrixChanged || childLayout.matrixChange();
|
|
5744
5758
|
if (child.__bubbleMap)
|
|
5745
5759
|
child.__emitLifeEvent(ChildEvent.ADD);
|
|
5746
5760
|
if (this.leafer) {
|
|
@@ -5978,7 +5992,7 @@ var LeaferUI = (function (exports) {
|
|
|
5978
5992
|
}
|
|
5979
5993
|
}
|
|
5980
5994
|
|
|
5981
|
-
const version = "1.
|
|
5995
|
+
const version = "1.1.1";
|
|
5982
5996
|
|
|
5983
5997
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5984
5998
|
get allowBackgroundColor() { return true; }
|
|
@@ -6252,7 +6266,7 @@ var LeaferUI = (function (exports) {
|
|
|
6252
6266
|
}
|
|
6253
6267
|
|
|
6254
6268
|
const { updateAllMatrix, updateAllChange } = LeafHelper;
|
|
6255
|
-
const debug$
|
|
6269
|
+
const debug$5 = Debug.get('Layouter');
|
|
6256
6270
|
class Layouter {
|
|
6257
6271
|
constructor(target, userConfig) {
|
|
6258
6272
|
this.totalTimes = 0;
|
|
@@ -6287,7 +6301,7 @@ var LeaferUI = (function (exports) {
|
|
|
6287
6301
|
target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
|
|
6288
6302
|
}
|
|
6289
6303
|
catch (e) {
|
|
6290
|
-
debug$
|
|
6304
|
+
debug$5.error(e);
|
|
6291
6305
|
}
|
|
6292
6306
|
this.layoutedBlocks = null;
|
|
6293
6307
|
}
|
|
@@ -6301,9 +6315,9 @@ var LeaferUI = (function (exports) {
|
|
|
6301
6315
|
}
|
|
6302
6316
|
layoutOnce() {
|
|
6303
6317
|
if (this.layouting)
|
|
6304
|
-
return debug$
|
|
6318
|
+
return debug$5.warn('layouting');
|
|
6305
6319
|
if (this.times > 3)
|
|
6306
|
-
return debug$
|
|
6320
|
+
return debug$5.warn('layout max times');
|
|
6307
6321
|
this.times++;
|
|
6308
6322
|
this.totalTimes++;
|
|
6309
6323
|
this.layouting = true;
|
|
@@ -6407,7 +6421,7 @@ var LeaferUI = (function (exports) {
|
|
|
6407
6421
|
}
|
|
6408
6422
|
}
|
|
6409
6423
|
|
|
6410
|
-
const debug$
|
|
6424
|
+
const debug$4 = Debug.get('Renderer');
|
|
6411
6425
|
class Renderer {
|
|
6412
6426
|
get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
|
|
6413
6427
|
constructor(target, canvas, userConfig) {
|
|
@@ -6423,29 +6437,29 @@ var LeaferUI = (function (exports) {
|
|
|
6423
6437
|
if (userConfig)
|
|
6424
6438
|
this.config = DataHelper.default(userConfig, this.config);
|
|
6425
6439
|
this.__listenEvents();
|
|
6426
|
-
this.__requestRender();
|
|
6427
6440
|
}
|
|
6428
6441
|
start() {
|
|
6429
6442
|
this.running = true;
|
|
6443
|
+
this.update(false);
|
|
6430
6444
|
}
|
|
6431
6445
|
stop() {
|
|
6432
6446
|
this.running = false;
|
|
6433
6447
|
}
|
|
6434
|
-
update() {
|
|
6435
|
-
this.changed
|
|
6448
|
+
update(change = true) {
|
|
6449
|
+
if (!this.changed)
|
|
6450
|
+
this.changed = change;
|
|
6451
|
+
this.__requestRender();
|
|
6436
6452
|
}
|
|
6437
6453
|
requestLayout() {
|
|
6438
6454
|
this.target.emit(LayoutEvent.REQUEST);
|
|
6439
6455
|
}
|
|
6440
6456
|
render(callback) {
|
|
6441
|
-
if (!(this.running && this.canvas.view))
|
|
6442
|
-
this.
|
|
6443
|
-
return;
|
|
6444
|
-
}
|
|
6457
|
+
if (!(this.running && this.canvas.view))
|
|
6458
|
+
return this.update();
|
|
6445
6459
|
const { target } = this;
|
|
6446
6460
|
this.times = 0;
|
|
6447
6461
|
this.totalBounds = new Bounds();
|
|
6448
|
-
debug$
|
|
6462
|
+
debug$4.log(target.innerName, '--->');
|
|
6449
6463
|
try {
|
|
6450
6464
|
if (!target.isApp)
|
|
6451
6465
|
target.app.emit(RenderEvent.CHILD_START, target);
|
|
@@ -6456,9 +6470,9 @@ var LeaferUI = (function (exports) {
|
|
|
6456
6470
|
}
|
|
6457
6471
|
catch (e) {
|
|
6458
6472
|
this.rendering = false;
|
|
6459
|
-
debug$
|
|
6473
|
+
debug$4.error(e);
|
|
6460
6474
|
}
|
|
6461
|
-
debug$
|
|
6475
|
+
debug$4.log('-------------|');
|
|
6462
6476
|
}
|
|
6463
6477
|
renderAgain() {
|
|
6464
6478
|
if (this.rendering) {
|
|
@@ -6470,9 +6484,9 @@ var LeaferUI = (function (exports) {
|
|
|
6470
6484
|
}
|
|
6471
6485
|
renderOnce(callback) {
|
|
6472
6486
|
if (this.rendering)
|
|
6473
|
-
return debug$
|
|
6487
|
+
return debug$4.warn('rendering');
|
|
6474
6488
|
if (this.times > 3)
|
|
6475
|
-
return debug$
|
|
6489
|
+
return debug$4.warn('render max times');
|
|
6476
6490
|
this.times++;
|
|
6477
6491
|
this.totalTimes++;
|
|
6478
6492
|
this.rendering = true;
|
|
@@ -6509,7 +6523,7 @@ var LeaferUI = (function (exports) {
|
|
|
6509
6523
|
partRender() {
|
|
6510
6524
|
const { canvas, updateBlocks: list } = this;
|
|
6511
6525
|
if (!list)
|
|
6512
|
-
return debug$
|
|
6526
|
+
return debug$4.warn('PartRender: need update attr');
|
|
6513
6527
|
this.mergeBlocks();
|
|
6514
6528
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6515
6529
|
this.clipRender(block); });
|
|
@@ -6575,16 +6589,17 @@ var LeaferUI = (function (exports) {
|
|
|
6575
6589
|
}
|
|
6576
6590
|
}
|
|
6577
6591
|
__requestRender() {
|
|
6578
|
-
|
|
6592
|
+
if (this.requestTime)
|
|
6593
|
+
return;
|
|
6594
|
+
const requestTime = this.requestTime = Date.now();
|
|
6579
6595
|
Platform.requestRender(() => {
|
|
6580
|
-
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() -
|
|
6596
|
+
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
6597
|
+
this.requestTime = 0;
|
|
6581
6598
|
if (this.running) {
|
|
6582
6599
|
if (this.changed && this.canvas.view)
|
|
6583
6600
|
this.render();
|
|
6584
6601
|
this.target.emit(RenderEvent.NEXT);
|
|
6585
6602
|
}
|
|
6586
|
-
if (this.target)
|
|
6587
|
-
this.__requestRender();
|
|
6588
6603
|
});
|
|
6589
6604
|
}
|
|
6590
6605
|
__onResize(e) {
|
|
@@ -6600,7 +6615,7 @@ var LeaferUI = (function (exports) {
|
|
|
6600
6615
|
}
|
|
6601
6616
|
}
|
|
6602
6617
|
this.addBlock(new Bounds(0, 0, 1, 1));
|
|
6603
|
-
this.
|
|
6618
|
+
this.update();
|
|
6604
6619
|
}
|
|
6605
6620
|
__onLayoutEnd(event) {
|
|
6606
6621
|
if (event.data)
|
|
@@ -6611,7 +6626,7 @@ var LeaferUI = (function (exports) {
|
|
|
6611
6626
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
6612
6627
|
if (empty) {
|
|
6613
6628
|
if (!leaf.isLeafer)
|
|
6614
|
-
debug$
|
|
6629
|
+
debug$4.tip(leaf.innerName, ': empty');
|
|
6615
6630
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
6616
6631
|
}
|
|
6617
6632
|
return empty;
|
|
@@ -6986,7 +7001,7 @@ var LeaferUI = (function (exports) {
|
|
|
6986
7001
|
|
|
6987
7002
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6988
7003
|
const emptyPaint = {};
|
|
6989
|
-
const debug$
|
|
7004
|
+
const debug$3 = Debug.get('UIData');
|
|
6990
7005
|
class UIData extends LeafData {
|
|
6991
7006
|
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
6992
7007
|
get __strokeWidth() {
|
|
@@ -7008,7 +7023,7 @@ var LeaferUI = (function (exports) {
|
|
|
7008
7023
|
return true;
|
|
7009
7024
|
return t.fill && this.__hasStroke;
|
|
7010
7025
|
}
|
|
7011
|
-
get __clipAfterFill() { return (
|
|
7026
|
+
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
7012
7027
|
get __autoWidth() { return !this._width; }
|
|
7013
7028
|
get __autoHeight() { return !this._height; }
|
|
7014
7029
|
get __autoSide() { return !this._width || !this._height; }
|
|
@@ -7023,7 +7038,7 @@ var LeaferUI = (function (exports) {
|
|
|
7023
7038
|
if (value < 0) {
|
|
7024
7039
|
this._width = -value;
|
|
7025
7040
|
this.__leaf.scaleX *= -1;
|
|
7026
|
-
debug$
|
|
7041
|
+
debug$3.warn('width < 0, instead -scaleX ', this);
|
|
7027
7042
|
}
|
|
7028
7043
|
else
|
|
7029
7044
|
this._width = value;
|
|
@@ -7032,7 +7047,7 @@ var LeaferUI = (function (exports) {
|
|
|
7032
7047
|
if (value < 0) {
|
|
7033
7048
|
this._height = -value;
|
|
7034
7049
|
this.__leaf.scaleY *= -1;
|
|
7035
|
-
debug$
|
|
7050
|
+
debug$3.warn('height < 0, instead -scaleY', this);
|
|
7036
7051
|
}
|
|
7037
7052
|
else
|
|
7038
7053
|
this._height = value;
|
|
@@ -7122,7 +7137,7 @@ var LeaferUI = (function (exports) {
|
|
|
7122
7137
|
|
|
7123
7138
|
class BoxData extends GroupData {
|
|
7124
7139
|
get __boxStroke() { return !this.__pathInputed; }
|
|
7125
|
-
get __drawAfterFill() { return
|
|
7140
|
+
get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
|
|
7126
7141
|
get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
|
|
7127
7142
|
}
|
|
7128
7143
|
|
|
@@ -7408,11 +7423,15 @@ var LeaferUI = (function (exports) {
|
|
|
7408
7423
|
super(data);
|
|
7409
7424
|
}
|
|
7410
7425
|
reset(_data) { }
|
|
7411
|
-
set(data,
|
|
7412
|
-
if (
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7426
|
+
set(data, transition) {
|
|
7427
|
+
if (transition) {
|
|
7428
|
+
if (transition === 'temp') {
|
|
7429
|
+
this.lockNormalStyle = true;
|
|
7430
|
+
Object.assign(this, data);
|
|
7431
|
+
this.lockNormalStyle = false;
|
|
7432
|
+
}
|
|
7433
|
+
else
|
|
7434
|
+
this.animate(data, transition);
|
|
7416
7435
|
}
|
|
7417
7436
|
else
|
|
7418
7437
|
Object.assign(this, data);
|
|
@@ -7722,17 +7741,17 @@ var LeaferUI = (function (exports) {
|
|
|
7722
7741
|
if (!this.children)
|
|
7723
7742
|
this.children = [];
|
|
7724
7743
|
}
|
|
7725
|
-
set(data,
|
|
7744
|
+
set(data, transition) {
|
|
7726
7745
|
if (data.children) {
|
|
7727
7746
|
const { children } = data;
|
|
7728
7747
|
delete data.children;
|
|
7729
7748
|
this.children ? this.clear() : this.__setBranch();
|
|
7730
|
-
super.set(data,
|
|
7749
|
+
super.set(data, transition);
|
|
7731
7750
|
children.forEach(child => this.add(child));
|
|
7732
7751
|
data.children = children;
|
|
7733
7752
|
}
|
|
7734
7753
|
else
|
|
7735
|
-
super.set(data,
|
|
7754
|
+
super.set(data, transition);
|
|
7736
7755
|
}
|
|
7737
7756
|
toJSON(options) {
|
|
7738
7757
|
const data = super.toJSON(options);
|
|
@@ -7764,7 +7783,7 @@ var LeaferUI = (function (exports) {
|
|
|
7764
7783
|
], exports.Group);
|
|
7765
7784
|
|
|
7766
7785
|
var Leafer_1;
|
|
7767
|
-
const debug$
|
|
7786
|
+
const debug$2 = Debug.get('Leafer');
|
|
7768
7787
|
exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
|
|
7769
7788
|
get __tag() { return 'Leafer'; }
|
|
7770
7789
|
get isApp() { return false; }
|
|
@@ -7778,20 +7797,10 @@ var LeaferUI = (function (exports) {
|
|
|
7778
7797
|
constructor(userConfig, data) {
|
|
7779
7798
|
super(data);
|
|
7780
7799
|
this.config = {
|
|
7781
|
-
type: 'design',
|
|
7782
7800
|
start: true,
|
|
7783
7801
|
hittable: true,
|
|
7784
7802
|
smooth: true,
|
|
7785
|
-
lazySpeard: 100
|
|
7786
|
-
zoom: {
|
|
7787
|
-
min: 0.01,
|
|
7788
|
-
max: 256
|
|
7789
|
-
},
|
|
7790
|
-
move: {
|
|
7791
|
-
holdSpaceKey: true,
|
|
7792
|
-
holdMiddleKey: true,
|
|
7793
|
-
autoDistance: 2
|
|
7794
|
-
}
|
|
7803
|
+
lazySpeard: 100
|
|
7795
7804
|
};
|
|
7796
7805
|
this.leafs = 0;
|
|
7797
7806
|
this.__eventIds = [];
|
|
@@ -7808,23 +7817,27 @@ var LeaferUI = (function (exports) {
|
|
|
7808
7817
|
init(userConfig, parentApp) {
|
|
7809
7818
|
if (this.canvas)
|
|
7810
7819
|
return;
|
|
7811
|
-
this.__setLeafer(this);
|
|
7812
|
-
if (userConfig)
|
|
7813
|
-
DataHelper.assign(this.config, userConfig);
|
|
7814
7820
|
let start;
|
|
7815
7821
|
const { config } = this;
|
|
7816
|
-
this.
|
|
7822
|
+
this.__setLeafer(this);
|
|
7823
|
+
if (parentApp) {
|
|
7824
|
+
this.parentApp = parentApp;
|
|
7825
|
+
this.__bindApp(parentApp);
|
|
7826
|
+
start = parentApp.running;
|
|
7827
|
+
}
|
|
7828
|
+
if (userConfig) {
|
|
7829
|
+
this.parent = parentApp;
|
|
7830
|
+
this.initType(userConfig.type);
|
|
7831
|
+
this.parent = undefined;
|
|
7832
|
+
DataHelper.assign(config, userConfig);
|
|
7833
|
+
}
|
|
7817
7834
|
const canvas = this.canvas = Creator.canvas(config);
|
|
7818
7835
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7819
7836
|
if (this.isApp)
|
|
7820
7837
|
this.__setApp();
|
|
7821
7838
|
this.__checkAutoLayout(config, parentApp);
|
|
7822
7839
|
this.view = canvas.view;
|
|
7823
|
-
if (parentApp) {
|
|
7824
|
-
this.__bindApp(parentApp);
|
|
7825
|
-
start = parentApp.running;
|
|
7826
|
-
}
|
|
7827
|
-
else {
|
|
7840
|
+
if (!parentApp) {
|
|
7828
7841
|
this.selector = Creator.selector(this);
|
|
7829
7842
|
this.interaction = Creator.interaction(this, canvas, this.selector, config);
|
|
7830
7843
|
if (this.interaction) {
|
|
@@ -7845,8 +7858,8 @@ var LeaferUI = (function (exports) {
|
|
|
7845
7858
|
}
|
|
7846
7859
|
onInit() { }
|
|
7847
7860
|
initType(_type) { }
|
|
7848
|
-
set(data) {
|
|
7849
|
-
this.waitInit(() => { super.set(data); });
|
|
7861
|
+
set(data, transition) {
|
|
7862
|
+
this.waitInit(() => { super.set(data, transition); });
|
|
7850
7863
|
}
|
|
7851
7864
|
start() {
|
|
7852
7865
|
clearTimeout(this.__startTimer);
|
|
@@ -7881,7 +7894,11 @@ var LeaferUI = (function (exports) {
|
|
|
7881
7894
|
forceRender(bounds) {
|
|
7882
7895
|
this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
|
|
7883
7896
|
if (this.viewReady)
|
|
7884
|
-
this.renderer.
|
|
7897
|
+
this.renderer.render();
|
|
7898
|
+
}
|
|
7899
|
+
requestRender(change = false) {
|
|
7900
|
+
if (this.renderer)
|
|
7901
|
+
this.renderer.update(change);
|
|
7885
7902
|
}
|
|
7886
7903
|
updateCursor(cursor) {
|
|
7887
7904
|
const i = this.interaction;
|
|
@@ -7928,7 +7945,7 @@ var LeaferUI = (function (exports) {
|
|
|
7928
7945
|
if (this.canvas) {
|
|
7929
7946
|
if (canvasSizeAttrs.includes(attrName)) {
|
|
7930
7947
|
if (!newValue)
|
|
7931
|
-
debug$
|
|
7948
|
+
debug$2.warn(attrName + ' is 0');
|
|
7932
7949
|
this.__changeCanvasSize(attrName, newValue);
|
|
7933
7950
|
}
|
|
7934
7951
|
else if (attrName === 'fill') {
|
|
@@ -7989,8 +8006,10 @@ var LeaferUI = (function (exports) {
|
|
|
7989
8006
|
const { imageReady } = this;
|
|
7990
8007
|
if (imageReady && !this.viewCompleted)
|
|
7991
8008
|
this.__checkViewCompleted();
|
|
7992
|
-
if (!imageReady)
|
|
8009
|
+
if (!imageReady) {
|
|
7993
8010
|
this.viewCompleted = false;
|
|
8011
|
+
this.requestRender();
|
|
8012
|
+
}
|
|
7994
8013
|
}
|
|
7995
8014
|
}
|
|
7996
8015
|
__checkViewCompleted(emit = true) {
|
|
@@ -8048,6 +8067,7 @@ var LeaferUI = (function (exports) {
|
|
|
8048
8067
|
}
|
|
8049
8068
|
else
|
|
8050
8069
|
list.push(item);
|
|
8070
|
+
this.requestRender();
|
|
8051
8071
|
}
|
|
8052
8072
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
8053
8073
|
return needPlugin('view');
|
|
@@ -8101,14 +8121,14 @@ var LeaferUI = (function (exports) {
|
|
|
8101
8121
|
this.canvasManager.destroy();
|
|
8102
8122
|
}
|
|
8103
8123
|
this.canvas.destroy();
|
|
8104
|
-
this.config.view = this.view = null;
|
|
8124
|
+
this.config.view = this.view = this.parentApp = null;
|
|
8105
8125
|
if (this.userConfig)
|
|
8106
8126
|
this.userConfig.view = null;
|
|
8107
8127
|
super.destroy();
|
|
8108
8128
|
setTimeout(() => { ImageManager.clearRecycled(); }, 100);
|
|
8109
8129
|
}
|
|
8110
8130
|
catch (e) {
|
|
8111
|
-
debug$
|
|
8131
|
+
debug$2.error(e);
|
|
8112
8132
|
}
|
|
8113
8133
|
}
|
|
8114
8134
|
};
|
|
@@ -8828,9 +8848,9 @@ var LeaferUI = (function (exports) {
|
|
|
8828
8848
|
if (ground)
|
|
8829
8849
|
this.ground = this.addLeafer(ground);
|
|
8830
8850
|
if (tree || editor)
|
|
8831
|
-
this.tree = this.addLeafer(tree);
|
|
8851
|
+
this.tree = this.addLeafer(tree || { type: userConfig.type || 'design' });
|
|
8832
8852
|
if (sky || editor)
|
|
8833
|
-
this.sky = this.addLeafer(sky
|
|
8853
|
+
this.sky = this.addLeafer(sky);
|
|
8834
8854
|
if (editor)
|
|
8835
8855
|
this.sky.add(this.editor = Creator.editor(editor));
|
|
8836
8856
|
}
|
|
@@ -9035,10 +9055,8 @@ var LeaferUI = (function (exports) {
|
|
|
9035
9055
|
this.data = data;
|
|
9036
9056
|
}
|
|
9037
9057
|
static getValidMove(leaf, start, total) {
|
|
9038
|
-
const { draggable, dragBounds
|
|
9039
|
-
|
|
9040
|
-
move.x += start.x - x;
|
|
9041
|
-
move.y += start.y - y;
|
|
9058
|
+
const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
|
|
9059
|
+
PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
|
|
9042
9060
|
if (dragBounds)
|
|
9043
9061
|
this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
|
|
9044
9062
|
if (draggable === 'x')
|
|
@@ -9048,8 +9066,7 @@ var LeaferUI = (function (exports) {
|
|
|
9048
9066
|
return move;
|
|
9049
9067
|
}
|
|
9050
9068
|
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9051
|
-
const x = childBox.x + move.x, y = childBox.y + move.y;
|
|
9052
|
-
const right = x + childBox.width, bottom = y + childBox.height;
|
|
9069
|
+
const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
|
|
9053
9070
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9054
9071
|
if (!change)
|
|
9055
9072
|
move = Object.assign({}, move);
|
|
@@ -9101,9 +9118,7 @@ var LeaferUI = (function (exports) {
|
|
|
9101
9118
|
return this.getLocalMove(relative, true);
|
|
9102
9119
|
}
|
|
9103
9120
|
getPageBounds() {
|
|
9104
|
-
const total = this.getPageTotal();
|
|
9105
|
-
const start = this.getPagePoint();
|
|
9106
|
-
const bounds = {};
|
|
9121
|
+
const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
|
|
9107
9122
|
BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
|
|
9108
9123
|
BoundsHelper.unsign(bounds);
|
|
9109
9124
|
return bounds;
|
|
@@ -9189,184 +9204,7 @@ var LeaferUI = (function (exports) {
|
|
|
9189
9204
|
registerUIEvent()
|
|
9190
9205
|
], exports.KeyEvent);
|
|
9191
9206
|
|
|
9192
|
-
function addInteractionWindow(leafer) {
|
|
9193
|
-
if (leafer.isApp)
|
|
9194
|
-
return;
|
|
9195
|
-
leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => {
|
|
9196
|
-
leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
|
|
9197
|
-
}), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
|
|
9198
|
-
const { zoomLayer } = leafer;
|
|
9199
|
-
const changeScale = leafer.getValidScale(e.scale);
|
|
9200
|
-
if (changeScale !== 1) {
|
|
9201
|
-
PointHelper.scaleOf(zoomLayer, e, changeScale);
|
|
9202
|
-
zoomLayer.scale = zoomLayer.__.scaleX * changeScale;
|
|
9203
|
-
}
|
|
9204
|
-
}));
|
|
9205
|
-
}
|
|
9206
|
-
|
|
9207
|
-
function document(leafer) {
|
|
9208
|
-
addInteractionWindow(leafer);
|
|
9209
|
-
const { move, zoom } = leafer.config;
|
|
9210
|
-
move.scroll = 'limit';
|
|
9211
|
-
zoom.min = 1;
|
|
9212
|
-
}
|
|
9213
|
-
|
|
9214
|
-
function block(leafer) {
|
|
9215
|
-
const { config } = leafer;
|
|
9216
|
-
(config.wheel || (config.wheel = {})).preventDefault = false;
|
|
9217
|
-
(config.touch || (config.touch = {})).preventDefault = 'auto';
|
|
9218
|
-
}
|
|
9219
|
-
|
|
9220
|
-
const debug$2 = Debug.get('LeaferTypeCreator');
|
|
9221
|
-
const LeaferTypeCreator = {
|
|
9222
|
-
list: {},
|
|
9223
|
-
register(name, fn) {
|
|
9224
|
-
list[name] && debug$2.repeat(name);
|
|
9225
|
-
list[name] = fn;
|
|
9226
|
-
},
|
|
9227
|
-
run(name, leafer) {
|
|
9228
|
-
const fn = list[name];
|
|
9229
|
-
fn && fn(leafer);
|
|
9230
|
-
}
|
|
9231
|
-
};
|
|
9232
|
-
const { list, register } = LeaferTypeCreator;
|
|
9233
|
-
register('design', addInteractionWindow);
|
|
9234
|
-
register('document', document);
|
|
9235
|
-
register('block', block);
|
|
9236
|
-
|
|
9237
|
-
const leafer = exports.Leafer.prototype;
|
|
9238
|
-
leafer.initType = function (type) {
|
|
9239
|
-
LeaferTypeCreator.run(type, this);
|
|
9240
|
-
};
|
|
9241
|
-
leafer.getValidMove = function (moveX, moveY) {
|
|
9242
|
-
const { scroll, disabled } = this.app.config.move;
|
|
9243
|
-
if (scroll) {
|
|
9244
|
-
Math.abs(moveX) > Math.abs(moveY) ? moveY = 0 : moveX = 0;
|
|
9245
|
-
if (scroll === 'limit') {
|
|
9246
|
-
const { x, y, width, height } = new Bounds(this.__world).addPoint(this.zoomLayer);
|
|
9247
|
-
const right = x + width - this.width, bottom = y + height - this.height;
|
|
9248
|
-
if (x >= 0 && right <= 0)
|
|
9249
|
-
moveX = 0;
|
|
9250
|
-
else if (moveX > 0) {
|
|
9251
|
-
if (x + moveX > 0)
|
|
9252
|
-
moveX = -x;
|
|
9253
|
-
}
|
|
9254
|
-
else if (moveX < 0 && right + moveX < 0)
|
|
9255
|
-
moveX = -right;
|
|
9256
|
-
if (y >= 0 && bottom <= 0)
|
|
9257
|
-
moveY = 0;
|
|
9258
|
-
else if (moveY > 0) {
|
|
9259
|
-
if (y + moveY > 0)
|
|
9260
|
-
moveY = -y;
|
|
9261
|
-
}
|
|
9262
|
-
else if (moveY < 0 && bottom + moveY < 0)
|
|
9263
|
-
moveY = -bottom;
|
|
9264
|
-
}
|
|
9265
|
-
}
|
|
9266
|
-
return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
|
|
9267
|
-
};
|
|
9268
|
-
leafer.getValidScale = function (changeScale) {
|
|
9269
|
-
const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
|
|
9270
|
-
if (absScale < min)
|
|
9271
|
-
changeScale = min / scaleX;
|
|
9272
|
-
else if (absScale > max)
|
|
9273
|
-
changeScale = max / scaleX;
|
|
9274
|
-
return disabled ? 1 : changeScale;
|
|
9275
|
-
};
|
|
9276
|
-
|
|
9277
|
-
class Transformer {
|
|
9278
|
-
get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
|
|
9279
|
-
constructor(interaction) {
|
|
9280
|
-
this.interaction = interaction;
|
|
9281
|
-
}
|
|
9282
|
-
move(data) {
|
|
9283
|
-
const { interaction } = this;
|
|
9284
|
-
if (!data.moveType)
|
|
9285
|
-
data.moveType = 'move';
|
|
9286
|
-
if (!this.moveData) {
|
|
9287
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9288
|
-
data.path = path;
|
|
9289
|
-
this.moveData = Object.assign(Object.assign({}, data), { moveX: 0, moveY: 0 });
|
|
9290
|
-
interaction.cancelHover();
|
|
9291
|
-
interaction.emit(exports.MoveEvent.START, this.moveData);
|
|
9292
|
-
}
|
|
9293
|
-
data.path = this.moveData.path;
|
|
9294
|
-
interaction.emit(exports.MoveEvent.BEFORE_MOVE, data);
|
|
9295
|
-
interaction.emit(exports.MoveEvent.MOVE, data);
|
|
9296
|
-
this.transformEndWait();
|
|
9297
|
-
}
|
|
9298
|
-
zoom(data) {
|
|
9299
|
-
const { interaction } = this;
|
|
9300
|
-
if (!this.zoomData) {
|
|
9301
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9302
|
-
data.path = path;
|
|
9303
|
-
this.zoomData = Object.assign(Object.assign({}, data), { scale: 1 });
|
|
9304
|
-
interaction.cancelHover();
|
|
9305
|
-
interaction.emit(exports.ZoomEvent.START, this.zoomData);
|
|
9306
|
-
}
|
|
9307
|
-
data.path = this.zoomData.path;
|
|
9308
|
-
interaction.emit(exports.ZoomEvent.BEFORE_ZOOM, data);
|
|
9309
|
-
interaction.emit(exports.ZoomEvent.ZOOM, data);
|
|
9310
|
-
this.transformEndWait();
|
|
9311
|
-
}
|
|
9312
|
-
rotate(data) {
|
|
9313
|
-
const { interaction } = this;
|
|
9314
|
-
if (!this.rotateData) {
|
|
9315
|
-
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9316
|
-
data.path = path;
|
|
9317
|
-
this.rotateData = Object.assign(Object.assign({}, data), { rotation: 0 });
|
|
9318
|
-
interaction.cancelHover();
|
|
9319
|
-
interaction.emit(exports.RotateEvent.START, this.rotateData);
|
|
9320
|
-
}
|
|
9321
|
-
data.path = this.rotateData.path;
|
|
9322
|
-
interaction.emit(exports.RotateEvent.BEFORE_ROTATE, data);
|
|
9323
|
-
interaction.emit(exports.RotateEvent.ROTATE, data);
|
|
9324
|
-
this.transformEndWait();
|
|
9325
|
-
}
|
|
9326
|
-
transformEndWait() {
|
|
9327
|
-
clearTimeout(this.transformTimer);
|
|
9328
|
-
this.transformTimer = setTimeout(() => {
|
|
9329
|
-
this.transformEnd();
|
|
9330
|
-
}, this.interaction.config.pointer.transformTime);
|
|
9331
|
-
}
|
|
9332
|
-
transformEnd() {
|
|
9333
|
-
this.moveEnd();
|
|
9334
|
-
this.zoomEnd();
|
|
9335
|
-
this.rotateEnd();
|
|
9336
|
-
}
|
|
9337
|
-
moveEnd() {
|
|
9338
|
-
if (this.moveData) {
|
|
9339
|
-
this.interaction.emit(exports.MoveEvent.END, this.moveData);
|
|
9340
|
-
this.moveData = null;
|
|
9341
|
-
}
|
|
9342
|
-
}
|
|
9343
|
-
zoomEnd() {
|
|
9344
|
-
if (this.zoomData) {
|
|
9345
|
-
this.interaction.emit(exports.ZoomEvent.END, this.zoomData);
|
|
9346
|
-
this.zoomData = null;
|
|
9347
|
-
}
|
|
9348
|
-
}
|
|
9349
|
-
rotateEnd() {
|
|
9350
|
-
if (this.rotateData) {
|
|
9351
|
-
this.interaction.emit(exports.RotateEvent.END, this.rotateData);
|
|
9352
|
-
this.rotateData = null;
|
|
9353
|
-
}
|
|
9354
|
-
}
|
|
9355
|
-
destroy() {
|
|
9356
|
-
this.zoomData = this.moveData = this.rotateData = null;
|
|
9357
|
-
}
|
|
9358
|
-
}
|
|
9359
|
-
|
|
9360
9207
|
const InteractionHelper = {
|
|
9361
|
-
getMoveEventData(center, move, event) {
|
|
9362
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, moveX: move.x, moveY: move.y });
|
|
9363
|
-
},
|
|
9364
|
-
getRotateEventData(center, angle, event) {
|
|
9365
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, rotation: angle });
|
|
9366
|
-
},
|
|
9367
|
-
getZoomEventData(center, scale, event) {
|
|
9368
|
-
return Object.assign(Object.assign({}, event), { x: center.x, y: center.y, scale });
|
|
9369
|
-
},
|
|
9370
9208
|
getDragEventData(startPoint, lastPoint, event) {
|
|
9371
9209
|
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 });
|
|
9372
9210
|
},
|
|
@@ -9375,18 +9213,14 @@ var LeaferUI = (function (exports) {
|
|
|
9375
9213
|
data });
|
|
9376
9214
|
},
|
|
9377
9215
|
getSwipeDirection(angle) {
|
|
9378
|
-
if (angle < -45 && angle > -135)
|
|
9216
|
+
if (angle < -45 && angle > -135)
|
|
9379
9217
|
return exports.SwipeEvent.UP;
|
|
9380
|
-
|
|
9381
|
-
else if (angle > 45 && angle < 135) {
|
|
9218
|
+
else if (angle > 45 && angle < 135)
|
|
9382
9219
|
return exports.SwipeEvent.DOWN;
|
|
9383
|
-
|
|
9384
|
-
else if (angle <= 45 && angle >= -45) {
|
|
9220
|
+
else if (angle <= 45 && angle >= -45)
|
|
9385
9221
|
return exports.SwipeEvent.RIGHT;
|
|
9386
|
-
|
|
9387
|
-
else {
|
|
9222
|
+
else
|
|
9388
9223
|
return exports.SwipeEvent.LEFT;
|
|
9389
|
-
}
|
|
9390
9224
|
},
|
|
9391
9225
|
getSwipeEventData(startPoint, lastDragData, event) {
|
|
9392
9226
|
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)) });
|
|
@@ -9459,9 +9293,8 @@ var LeaferUI = (function (exports) {
|
|
|
9459
9293
|
interaction.emit(exports.MoveEvent.START, this.dragData);
|
|
9460
9294
|
}
|
|
9461
9295
|
}
|
|
9462
|
-
if (!this.moving)
|
|
9296
|
+
if (!this.moving)
|
|
9463
9297
|
this.dragStart(data, canDrag);
|
|
9464
|
-
}
|
|
9465
9298
|
this.drag(data);
|
|
9466
9299
|
}
|
|
9467
9300
|
dragStart(data, canDrag) {
|
|
@@ -9539,16 +9372,9 @@ var LeaferUI = (function (exports) {
|
|
|
9539
9372
|
dragEnd(data, speed) {
|
|
9540
9373
|
if (!this.dragging && !this.moving)
|
|
9541
9374
|
return;
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
speed = (speed || (data.pointerType === 'touch' ? 2 : 1)) * 0.9;
|
|
9546
|
-
PointHelper.move(data, moveX * speed, moveY * speed);
|
|
9547
|
-
this.drag(data);
|
|
9548
|
-
this.animate(() => { this.dragEnd(data, 1); });
|
|
9549
|
-
}
|
|
9550
|
-
else
|
|
9551
|
-
this.dragEndReal(data);
|
|
9375
|
+
if (this.checkDragEndAnimate(data, speed))
|
|
9376
|
+
return;
|
|
9377
|
+
this.dragEndReal(data);
|
|
9552
9378
|
}
|
|
9553
9379
|
dragEndReal(data) {
|
|
9554
9380
|
const { interaction, downData, dragData } = this;
|
|
@@ -9575,12 +9401,6 @@ var LeaferUI = (function (exports) {
|
|
|
9575
9401
|
this.dragReset();
|
|
9576
9402
|
this.animate(null, 'off');
|
|
9577
9403
|
}
|
|
9578
|
-
animate(func, off) {
|
|
9579
|
-
const animateWait = func || this.animateWait;
|
|
9580
|
-
if (animateWait)
|
|
9581
|
-
this.interaction.target.nextRender(animateWait, null, off);
|
|
9582
|
-
this.animateWait = func;
|
|
9583
|
-
}
|
|
9584
9404
|
swipe(data, downData, dragData, endDragData) {
|
|
9585
9405
|
const { interaction } = this;
|
|
9586
9406
|
if (PointHelper.getDistance(downData, data) > interaction.config.pointer.swipeDistance) {
|
|
@@ -9597,39 +9417,11 @@ var LeaferUI = (function (exports) {
|
|
|
9597
9417
|
dragReset() {
|
|
9598
9418
|
exports.DragEvent.list = exports.DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
|
|
9599
9419
|
}
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
}
|
|
9606
|
-
autoMoveOnDragOut(data) {
|
|
9607
|
-
const { interaction, downData, canDragOut } = this;
|
|
9608
|
-
const { autoDistance, dragOut } = interaction.config.move;
|
|
9609
|
-
if (!dragOut || !canDragOut || !autoDistance)
|
|
9610
|
-
return;
|
|
9611
|
-
const bounds = interaction.shrinkCanvasBounds;
|
|
9612
|
-
const { x, y } = bounds;
|
|
9613
|
-
const right = BoundsHelper.maxX(bounds);
|
|
9614
|
-
const bottom = BoundsHelper.maxY(bounds);
|
|
9615
|
-
const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
|
|
9616
|
-
const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
|
|
9617
|
-
let totalX = 0, totalY = 0;
|
|
9618
|
-
this.autoMoveTimer = setInterval(() => {
|
|
9619
|
-
totalX += moveX;
|
|
9620
|
-
totalY += moveY;
|
|
9621
|
-
PointHelper.move(downData, moveX, moveY);
|
|
9622
|
-
PointHelper.move(this.dragData, moveX, moveY);
|
|
9623
|
-
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
|
|
9624
|
-
interaction.pointerMoveReal(data);
|
|
9625
|
-
}, 10);
|
|
9626
|
-
}
|
|
9627
|
-
autoMoveCancel() {
|
|
9628
|
-
if (this.autoMoveTimer) {
|
|
9629
|
-
clearInterval(this.autoMoveTimer);
|
|
9630
|
-
this.autoMoveTimer = 0;
|
|
9631
|
-
}
|
|
9632
|
-
}
|
|
9420
|
+
checkDragEndAnimate(_data, _speed) { return false; }
|
|
9421
|
+
animate(_func, _off) { }
|
|
9422
|
+
checkDragOut(_data) { }
|
|
9423
|
+
autoMoveOnDragOut(_data) { }
|
|
9424
|
+
autoMoveCancel() { }
|
|
9633
9425
|
destroy() {
|
|
9634
9426
|
this.dragReset();
|
|
9635
9427
|
}
|
|
@@ -9699,28 +9491,12 @@ var LeaferUI = (function (exports) {
|
|
|
9699
9491
|
return excludePath && excludePath.has(leaf);
|
|
9700
9492
|
}
|
|
9701
9493
|
|
|
9702
|
-
const MultiTouchHelper = {
|
|
9703
|
-
getData(list) {
|
|
9704
|
-
const a = list[0];
|
|
9705
|
-
const b = list[1];
|
|
9706
|
-
const lastCenter = PointHelper.getCenter(a.from, b.from);
|
|
9707
|
-
const center = PointHelper.getCenter(a.to, b.to);
|
|
9708
|
-
const move = { x: center.x - lastCenter.x, y: center.y - lastCenter.y };
|
|
9709
|
-
const lastDistance = PointHelper.getDistance(a.from, b.from);
|
|
9710
|
-
const distance = PointHelper.getDistance(a.to, b.to);
|
|
9711
|
-
const scale = distance / lastDistance;
|
|
9712
|
-
const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
|
|
9713
|
-
return { move, scale, angle, center };
|
|
9714
|
-
}
|
|
9715
|
-
};
|
|
9716
|
-
|
|
9717
9494
|
const config = {
|
|
9718
9495
|
wheel: {
|
|
9719
9496
|
zoomSpeed: 0.5,
|
|
9720
9497
|
moveSpeed: 0.5,
|
|
9721
9498
|
rotateSpeed: 0.5,
|
|
9722
9499
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9723
|
-
preventDefault: true
|
|
9724
9500
|
},
|
|
9725
9501
|
pointer: {
|
|
9726
9502
|
hitRadius: 5,
|
|
@@ -9731,17 +9507,18 @@ var LeaferUI = (function (exports) {
|
|
|
9731
9507
|
dragHover: true,
|
|
9732
9508
|
dragDistance: 2,
|
|
9733
9509
|
swipeDistance: 20,
|
|
9734
|
-
preventDefaultMenu: true
|
|
9735
9510
|
},
|
|
9736
9511
|
touch: {
|
|
9737
|
-
preventDefault:
|
|
9512
|
+
preventDefault: 'auto'
|
|
9738
9513
|
},
|
|
9739
9514
|
multiTouch: {},
|
|
9515
|
+
move: { autoDistance: 2 },
|
|
9516
|
+
zoom: {},
|
|
9740
9517
|
cursor: true,
|
|
9741
9518
|
keyEvent: true
|
|
9742
9519
|
};
|
|
9743
9520
|
|
|
9744
|
-
const { pathHasEventType,
|
|
9521
|
+
const { pathHasEventType, pathCanDrag, pathHasOutside } = InteractionHelper;
|
|
9745
9522
|
class InteractionBase {
|
|
9746
9523
|
get dragging() { return this.dragger.dragging; }
|
|
9747
9524
|
get transforming() { return this.transformer.transforming; }
|
|
@@ -9763,7 +9540,7 @@ var LeaferUI = (function (exports) {
|
|
|
9763
9540
|
this.canvas = canvas;
|
|
9764
9541
|
this.selector = selector;
|
|
9765
9542
|
this.defaultPath = new LeafList(target);
|
|
9766
|
-
this.
|
|
9543
|
+
this.createTransformer();
|
|
9767
9544
|
this.dragger = new Dragger(this);
|
|
9768
9545
|
if (userConfig)
|
|
9769
9546
|
this.config = DataHelper.default(userConfig, this.config);
|
|
@@ -9864,14 +9641,6 @@ var LeaferUI = (function (exports) {
|
|
|
9864
9641
|
data.isCancel = true;
|
|
9865
9642
|
this.pointerUp(data);
|
|
9866
9643
|
}
|
|
9867
|
-
multiTouch(data, list) {
|
|
9868
|
-
if (this.config.multiTouch.disabled)
|
|
9869
|
-
return;
|
|
9870
|
-
const { move, angle, scale, center } = MultiTouchHelper.getData(list);
|
|
9871
|
-
this.rotate(getRotateEventData(center, angle, data));
|
|
9872
|
-
this.zoom(getZoomEventData(center, scale, data));
|
|
9873
|
-
this.move(getMoveEventData(center, move, data));
|
|
9874
|
-
}
|
|
9875
9644
|
menu(data) {
|
|
9876
9645
|
this.findPath(data);
|
|
9877
9646
|
this.emit(exports.PointerEvent.MENU, data);
|
|
@@ -9885,18 +9654,13 @@ var LeaferUI = (function (exports) {
|
|
|
9885
9654
|
this.waitRightTap = this.waitMenuTap = false;
|
|
9886
9655
|
}
|
|
9887
9656
|
}
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
}
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
}
|
|
9894
|
-
|
|
9895
|
-
this.transformer.rotate(data);
|
|
9896
|
-
}
|
|
9897
|
-
transformEnd() {
|
|
9898
|
-
this.transformer.transformEnd();
|
|
9899
|
-
}
|
|
9657
|
+
createTransformer() { }
|
|
9658
|
+
move(_data) { }
|
|
9659
|
+
zoom(_data) { }
|
|
9660
|
+
rotate(_data) { }
|
|
9661
|
+
transformEnd() { }
|
|
9662
|
+
wheel(_data) { }
|
|
9663
|
+
multiTouch(_data, _list) { }
|
|
9900
9664
|
keyDown(data) {
|
|
9901
9665
|
if (!this.config.keyEvent)
|
|
9902
9666
|
return;
|
|
@@ -10134,8 +9898,9 @@ var LeaferUI = (function (exports) {
|
|
|
10134
9898
|
this.longPressed = false;
|
|
10135
9899
|
}
|
|
10136
9900
|
__onResize() {
|
|
9901
|
+
const { dragOut } = this.m;
|
|
10137
9902
|
this.shrinkCanvasBounds = new Bounds(this.canvas.bounds);
|
|
10138
|
-
this.shrinkCanvasBounds.spread(-2);
|
|
9903
|
+
this.shrinkCanvasBounds.spread(-(typeof dragOut === 'number' ? dragOut : 2));
|
|
10139
9904
|
}
|
|
10140
9905
|
__listenEvents() {
|
|
10141
9906
|
const { target } = this;
|
|
@@ -10155,7 +9920,8 @@ var LeaferUI = (function (exports) {
|
|
|
10155
9920
|
this.stop();
|
|
10156
9921
|
this.__removeListenEvents();
|
|
10157
9922
|
this.dragger.destroy();
|
|
10158
|
-
this.transformer
|
|
9923
|
+
if (this.transformer)
|
|
9924
|
+
this.transformer.destroy();
|
|
10159
9925
|
this.downData = this.overPath = this.enterPath = null;
|
|
10160
9926
|
}
|
|
10161
9927
|
}
|
|
@@ -10491,6 +10257,8 @@ var LeaferUI = (function (exports) {
|
|
|
10491
10257
|
case 'center':
|
|
10492
10258
|
canvas.setStroke(stroke, __strokeWidth, options);
|
|
10493
10259
|
canvas.stroke();
|
|
10260
|
+
if (options.__useArrow)
|
|
10261
|
+
strokeArrow(ui, canvas);
|
|
10494
10262
|
break;
|
|
10495
10263
|
case 'inside':
|
|
10496
10264
|
canvas.save();
|
|
@@ -10528,6 +10296,8 @@ var LeaferUI = (function (exports) {
|
|
|
10528
10296
|
case 'center':
|
|
10529
10297
|
canvas.setStroke(undefined, __strokeWidth, options);
|
|
10530
10298
|
drawStrokesStyle(strokes, false, ui, canvas);
|
|
10299
|
+
if (options.__useArrow)
|
|
10300
|
+
strokeArrow(ui, canvas);
|
|
10531
10301
|
break;
|
|
10532
10302
|
case 'inside':
|
|
10533
10303
|
canvas.save();
|
|
@@ -10553,6 +10323,14 @@ var LeaferUI = (function (exports) {
|
|
|
10553
10323
|
}
|
|
10554
10324
|
}
|
|
10555
10325
|
}
|
|
10326
|
+
function strokeArrow(ui, canvas) {
|
|
10327
|
+
if (ui.__.dashPattern) {
|
|
10328
|
+
canvas.beginPath();
|
|
10329
|
+
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
10330
|
+
canvas.dashPattern = null;
|
|
10331
|
+
canvas.stroke();
|
|
10332
|
+
}
|
|
10333
|
+
}
|
|
10556
10334
|
|
|
10557
10335
|
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
|
|
10558
10336
|
function shape(ui, current, options) {
|
|
@@ -12048,6 +11826,7 @@ var LeaferUI = (function (exports) {
|
|
|
12048
11826
|
exports.Cursor = Cursor;
|
|
12049
11827
|
exports.DataHelper = DataHelper;
|
|
12050
11828
|
exports.Debug = Debug;
|
|
11829
|
+
exports.Dragger = Dragger;
|
|
12051
11830
|
exports.Effect = Effect;
|
|
12052
11831
|
exports.EllipseData = EllipseData;
|
|
12053
11832
|
exports.EllipseHelper = EllipseHelper;
|
|
@@ -12084,12 +11863,10 @@ var LeaferUI = (function (exports) {
|
|
|
12084
11863
|
exports.LeaferData = LeaferData;
|
|
12085
11864
|
exports.LeaferEvent = LeaferEvent;
|
|
12086
11865
|
exports.LeaferImage = LeaferImage;
|
|
12087
|
-
exports.LeaferTypeCreator = LeaferTypeCreator;
|
|
12088
11866
|
exports.LineData = LineData;
|
|
12089
11867
|
exports.MathHelper = MathHelper;
|
|
12090
11868
|
exports.Matrix = Matrix;
|
|
12091
11869
|
exports.MatrixHelper = MatrixHelper;
|
|
12092
|
-
exports.MultiTouchHelper = MultiTouchHelper;
|
|
12093
11870
|
exports.MyDragEvent = MyDragEvent;
|
|
12094
11871
|
exports.MyImage = MyImage;
|
|
12095
11872
|
exports.MyPointerEvent = MyPointerEvent;
|
|
@@ -12145,7 +11922,6 @@ var LeaferUI = (function (exports) {
|
|
|
12145
11922
|
exports.WaitHelper = WaitHelper;
|
|
12146
11923
|
exports.WatchEvent = WatchEvent;
|
|
12147
11924
|
exports.Watcher = Watcher;
|
|
12148
|
-
exports.addInteractionWindow = addInteractionWindow;
|
|
12149
11925
|
exports.affectRenderBoundsType = affectRenderBoundsType;
|
|
12150
11926
|
exports.affectStrokeBoundsType = affectStrokeBoundsType;
|
|
12151
11927
|
exports.attr = attr;
|