@leafer-game/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 +26 -664
- package/dist/worker.esm.js +2 -651
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +248 -432
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +248 -430
- package/dist/worker.module.min.js +1 -1
- package/package.json +4 -4
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$2(10, maxLength) : 1000000000000;
|
|
114
|
+
const a = maxLength !== undefined ? pow$2(10, maxLength) : 1000000000000;
|
|
115
115
|
num = round$3(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$1(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$1(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$1(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$1.moveLocal(t, local.x, local.y);
|
|
4189
|
+
L$1.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$1.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: updateAllMatrix$1, 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
|
};
|
|
@@ -8336,7 +8356,7 @@ var LeaferUI = (function (exports) {
|
|
|
8336
8356
|
], exports.Ellipse);
|
|
8337
8357
|
|
|
8338
8358
|
const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
|
|
8339
|
-
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$
|
|
8359
|
+
const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$3, defaultPoint } = PointHelper;
|
|
8340
8360
|
const { toBounds: toBounds$1 } = PathBounds;
|
|
8341
8361
|
exports.Line = class Line extends exports.UI {
|
|
8342
8362
|
get __tag() { return 'Line'; }
|
|
@@ -8350,7 +8370,7 @@ var LeaferUI = (function (exports) {
|
|
|
8350
8370
|
return to;
|
|
8351
8371
|
}
|
|
8352
8372
|
set toPoint(value) {
|
|
8353
|
-
this.width = getDistance$
|
|
8373
|
+
this.width = getDistance$3(defaultPoint, value);
|
|
8354
8374
|
this.rotation = getAngle$1(defaultPoint, value);
|
|
8355
8375
|
if (this.height)
|
|
8356
8376
|
this.height = 0;
|
|
@@ -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) {
|
|
@@ -11055,7 +10833,7 @@ var LeaferUI = (function (exports) {
|
|
|
11055
10833
|
}
|
|
11056
10834
|
}
|
|
11057
10835
|
|
|
11058
|
-
const { getAngle, getDistance: getDistance$
|
|
10836
|
+
const { getAngle, getDistance: getDistance$2 } = PointHelper;
|
|
11059
10837
|
const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
|
|
11060
10838
|
const { toPoint: toPoint$1 } = AroundHelper;
|
|
11061
10839
|
const realFrom$1 = {};
|
|
@@ -11064,7 +10842,7 @@ var LeaferUI = (function (exports) {
|
|
|
11064
10842
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
11065
10843
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
11066
10844
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
11067
|
-
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$
|
|
10845
|
+
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$2(realFrom$1, realTo$1));
|
|
11068
10846
|
applyStops(style, paint.stops, opacity);
|
|
11069
10847
|
const data = { type, style };
|
|
11070
10848
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
@@ -11092,7 +10870,7 @@ var LeaferUI = (function (exports) {
|
|
|
11092
10870
|
return transform;
|
|
11093
10871
|
}
|
|
11094
10872
|
|
|
11095
|
-
const { getDistance } = PointHelper;
|
|
10873
|
+
const { getDistance: getDistance$1 } = PointHelper;
|
|
11096
10874
|
const { toPoint } = AroundHelper;
|
|
11097
10875
|
const realFrom = {};
|
|
11098
10876
|
const realTo = {};
|
|
@@ -11100,7 +10878,7 @@ var LeaferUI = (function (exports) {
|
|
|
11100
10878
|
let { from, to, type, opacity, blendMode, stretch } = paint;
|
|
11101
10879
|
toPoint(from || 'center', box, realFrom);
|
|
11102
10880
|
toPoint(to || 'bottom', box, realTo);
|
|
11103
|
-
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
10881
|
+
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance$1(realFrom, realTo));
|
|
11104
10882
|
applyStops(style, paint.stops, opacity);
|
|
11105
10883
|
const data = { type, style };
|
|
11106
10884
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
@@ -12079,15 +11857,18 @@ var LeaferUI = (function (exports) {
|
|
|
12079
11857
|
if (typeof action === 'number') {
|
|
12080
11858
|
this.now = action;
|
|
12081
11859
|
}
|
|
12082
|
-
else if (action
|
|
12083
|
-
const
|
|
11860
|
+
else if (typeof action === 'object') {
|
|
11861
|
+
const isArray = action instanceof Array;
|
|
11862
|
+
const keyframes = isArray ? action : action.keyframes;
|
|
11863
|
+
this.__action = isArray ? undefined : action;
|
|
11864
|
+
const { length } = keyframes;
|
|
12084
11865
|
if (length > 1) {
|
|
12085
|
-
const start = this.now =
|
|
11866
|
+
const start = this.now = keyframes[0], end = keyframes[keyframes.length - 1];
|
|
12086
11867
|
this.play();
|
|
12087
11868
|
this.__runAction(start, end);
|
|
12088
11869
|
}
|
|
12089
11870
|
else if (length)
|
|
12090
|
-
this.now =
|
|
11871
|
+
this.now = keyframes[0];
|
|
12091
11872
|
}
|
|
12092
11873
|
}
|
|
12093
11874
|
__loadRobot(frame, start, end) {
|
|
@@ -12115,16 +11896,26 @@ var LeaferUI = (function (exports) {
|
|
|
12115
11896
|
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
12116
11897
|
}
|
|
12117
11898
|
__runAction(start, end) {
|
|
11899
|
+
let { FPS, loop, __action: a } = this;
|
|
11900
|
+
if (a) {
|
|
11901
|
+
if (a.FPS)
|
|
11902
|
+
FPS = a.FPS;
|
|
11903
|
+
if (a.loop !== undefined)
|
|
11904
|
+
loop = a.loop;
|
|
11905
|
+
}
|
|
12118
11906
|
this.__timer = setTimeout(() => {
|
|
12119
11907
|
if (this.running) {
|
|
12120
|
-
if (this.now === end)
|
|
11908
|
+
if (this.now === end) {
|
|
11909
|
+
if (!loop)
|
|
11910
|
+
return this.stop();
|
|
12121
11911
|
this.now = start;
|
|
11912
|
+
}
|
|
12122
11913
|
else
|
|
12123
11914
|
this.now++;
|
|
12124
11915
|
this.__updateRobotBounds();
|
|
12125
11916
|
}
|
|
12126
11917
|
this.__runAction(start, end);
|
|
12127
|
-
}, 1000 /
|
|
11918
|
+
}, 1000 / FPS);
|
|
12128
11919
|
}
|
|
12129
11920
|
__updateRobotBounds() {
|
|
12130
11921
|
const { nowFrame } = this;
|
|
@@ -12237,7 +12028,7 @@ var LeaferUI = (function (exports) {
|
|
|
12237
12028
|
const fromStyle = transition ? getFromStyle(leaf, style) : undefined;
|
|
12238
12029
|
leaf.killAnimate('transition');
|
|
12239
12030
|
if (normalStyle)
|
|
12240
|
-
leaf.set(normalStyle,
|
|
12031
|
+
leaf.set(normalStyle, 'temp');
|
|
12241
12032
|
const statesStyle = getStyle(leaf);
|
|
12242
12033
|
if (statesStyle) {
|
|
12243
12034
|
const { animation } = statesStyle;
|
|
@@ -12251,14 +12042,14 @@ var LeaferUI = (function (exports) {
|
|
|
12251
12042
|
delete statesStyle.animation;
|
|
12252
12043
|
}
|
|
12253
12044
|
leaf.normalStyle = filterStyle(statesStyle, leaf);
|
|
12254
|
-
leaf.set(statesStyle,
|
|
12045
|
+
leaf.set(statesStyle, 'temp');
|
|
12255
12046
|
}
|
|
12256
12047
|
else {
|
|
12257
12048
|
leaf.normalStyle = undefined;
|
|
12258
12049
|
}
|
|
12259
12050
|
if (transition) {
|
|
12260
12051
|
const toStyle = filterStyle(fromStyle, leaf);
|
|
12261
|
-
leaf.set(fromStyle,
|
|
12052
|
+
leaf.set(fromStyle, 'temp');
|
|
12262
12053
|
leaf.animate([fromStyle, toStyle], transition, 'transition', true);
|
|
12263
12054
|
}
|
|
12264
12055
|
leaf.__layout.stateStyleChanged = false;
|
|
@@ -12956,7 +12747,7 @@ var LeaferUI = (function (exports) {
|
|
|
12956
12747
|
this.emit(AnimateEvent.UPDATE, this);
|
|
12957
12748
|
}
|
|
12958
12749
|
setStyle(style) {
|
|
12959
|
-
this.target.set(style, this.isTemp);
|
|
12750
|
+
this.target.set(style, this.isTemp ? 'temp' : false);
|
|
12960
12751
|
}
|
|
12961
12752
|
clearTimer(fn) {
|
|
12962
12753
|
if (this.timer) {
|
|
@@ -13332,6 +13123,9 @@ var LeaferUI = (function (exports) {
|
|
|
13332
13123
|
from = fourNumber(from), to = fourNumber(to);
|
|
13333
13124
|
return from.map((f, i) => number(f, to[i], t));
|
|
13334
13125
|
},
|
|
13126
|
+
text(from, to, t) {
|
|
13127
|
+
return (typeof from === 'number' || typeof to === 'number') ? MathHelper.float(number(from, to, t), Math.max(getDecimalLen(from), getDecimalLen(to))) : to;
|
|
13128
|
+
},
|
|
13335
13129
|
shadow,
|
|
13336
13130
|
innerShadow: shadow
|
|
13337
13131
|
};
|
|
@@ -13340,6 +13134,10 @@ var LeaferUI = (function (exports) {
|
|
|
13340
13134
|
number,
|
|
13341
13135
|
color
|
|
13342
13136
|
};
|
|
13137
|
+
function getDecimalLen(num) {
|
|
13138
|
+
const decimal = String(num).split('.')[1];
|
|
13139
|
+
return decimal ? decimal.length : 0;
|
|
13140
|
+
}
|
|
13343
13141
|
function value(from, to, t) {
|
|
13344
13142
|
return (typeof from === 'number' && typeof to === 'number') ? from + (to - from) * t : to;
|
|
13345
13143
|
}
|
|
@@ -13408,23 +13206,40 @@ var LeaferUI = (function (exports) {
|
|
|
13408
13206
|
const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
|
|
13409
13207
|
const { sqrt } = Math;
|
|
13410
13208
|
const HighBezierHelper = {
|
|
13411
|
-
getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY) {
|
|
13412
|
-
let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y;
|
|
13209
|
+
getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, t = 1) {
|
|
13210
|
+
let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y, half = t / 2;
|
|
13413
13211
|
for (let i = 0; i < gaussNodes.length; i++) {
|
|
13414
|
-
t1 =
|
|
13415
|
-
t2 =
|
|
13212
|
+
t1 = half * (1 + gaussNodes[i]);
|
|
13213
|
+
t2 = half * (1 - gaussNodes[i]);
|
|
13416
13214
|
d1X = getDerivative(t1, fromX, x1, x2, toX);
|
|
13417
13215
|
d1Y = getDerivative(t1, fromY, y1, y2, toY);
|
|
13418
13216
|
d2X = getDerivative(t2, fromX, x1, x2, toX);
|
|
13419
13217
|
d2Y = getDerivative(t2, fromY, y1, y2, toY);
|
|
13420
13218
|
distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y));
|
|
13421
13219
|
}
|
|
13422
|
-
return distance *
|
|
13220
|
+
return distance * half;
|
|
13423
13221
|
},
|
|
13424
13222
|
getDerivative(t, fromV, v1, v2, toV) {
|
|
13425
13223
|
const o = 1 - t;
|
|
13426
13224
|
return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
|
|
13427
13225
|
},
|
|
13226
|
+
getRotation(t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
|
|
13227
|
+
const dx = getDerivative(t, fromX, x1, x2, toX);
|
|
13228
|
+
const dy = getDerivative(t, fromY, y1, y2, toY);
|
|
13229
|
+
return Math.atan2(dy, dx) / OneRadian;
|
|
13230
|
+
},
|
|
13231
|
+
getT(distance, totalDistance, fromX, fromY, x1, y1, x2, y2, toX, toY, precision = 1) {
|
|
13232
|
+
let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3;
|
|
13233
|
+
if (middle >= 1)
|
|
13234
|
+
return 1;
|
|
13235
|
+
if (middle <= 0)
|
|
13236
|
+
return 0;
|
|
13237
|
+
while (high - low > realPrecision) {
|
|
13238
|
+
getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle;
|
|
13239
|
+
middle = (low + high) / 2;
|
|
13240
|
+
}
|
|
13241
|
+
return middle;
|
|
13242
|
+
},
|
|
13428
13243
|
cut(data, t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
|
|
13429
13244
|
const o = 1 - t;
|
|
13430
13245
|
const ax = o * fromX + t * x1, ay = o * fromY + t * y1;
|
|
@@ -13436,7 +13251,7 @@ var LeaferUI = (function (exports) {
|
|
|
13436
13251
|
data.push(PathCommandMap.C, ax, ay, bx, by, cx, cy);
|
|
13437
13252
|
}
|
|
13438
13253
|
};
|
|
13439
|
-
const { getDerivative } = HighBezierHelper;
|
|
13254
|
+
const { getDerivative, getDistance } = HighBezierHelper;
|
|
13440
13255
|
|
|
13441
13256
|
const { M, L, C, Z } = PathCommandMap;
|
|
13442
13257
|
const tempPoint = {}, tempFrom = {};
|
|
@@ -13504,11 +13319,12 @@ var LeaferUI = (function (exports) {
|
|
|
13504
13319
|
}
|
|
13505
13320
|
return { total, segments, data };
|
|
13506
13321
|
},
|
|
13507
|
-
getDistancePoint(distanceData, motionDistance) {
|
|
13322
|
+
getDistancePoint(distanceData, motionDistance, motionPrecision) {
|
|
13508
13323
|
const { segments, data } = distanceData;
|
|
13509
13324
|
motionDistance = UnitConvert.number(motionDistance, distanceData.total);
|
|
13510
13325
|
let total = 0, distance, to = {};
|
|
13511
13326
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
13327
|
+
let x1, y1, x2, y2, t;
|
|
13512
13328
|
const len = data.length;
|
|
13513
13329
|
while (i < len) {
|
|
13514
13330
|
command = data[i];
|
|
@@ -13538,11 +13354,10 @@ var LeaferUI = (function (exports) {
|
|
|
13538
13354
|
toY = data[i + 6];
|
|
13539
13355
|
distance = segments[index];
|
|
13540
13356
|
if (total + distance > motionDistance) {
|
|
13541
|
-
|
|
13542
|
-
motionDistance
|
|
13543
|
-
BezierHelper.getPointAndSet(
|
|
13544
|
-
|
|
13545
|
-
to.rotation = PointHelper.getAngle(tempFrom, to);
|
|
13357
|
+
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
13358
|
+
t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
13359
|
+
BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
|
|
13360
|
+
to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
|
|
13546
13361
|
return to;
|
|
13547
13362
|
}
|
|
13548
13363
|
x = toX;
|
|
@@ -13559,11 +13374,12 @@ var LeaferUI = (function (exports) {
|
|
|
13559
13374
|
}
|
|
13560
13375
|
return to;
|
|
13561
13376
|
},
|
|
13562
|
-
getDistancePath(distanceData, motionDistance) {
|
|
13377
|
+
getDistancePath(distanceData, motionDistance, motionPrecision) {
|
|
13563
13378
|
const { segments, data } = distanceData, path = [];
|
|
13564
13379
|
motionDistance = UnitConvert.number(motionDistance, distanceData.total);
|
|
13565
13380
|
let total = 0, distance, to = {};
|
|
13566
13381
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
13382
|
+
let x1, y1, x2, y2, t;
|
|
13567
13383
|
const len = data.length;
|
|
13568
13384
|
while (i < len) {
|
|
13569
13385
|
command = data[i];
|
|
@@ -13590,12 +13406,13 @@ var LeaferUI = (function (exports) {
|
|
|
13590
13406
|
path.push(command, x, y);
|
|
13591
13407
|
break;
|
|
13592
13408
|
case C:
|
|
13593
|
-
|
|
13409
|
+
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
13594
13410
|
toX = data[i + 5];
|
|
13595
13411
|
toY = data[i + 6];
|
|
13596
13412
|
distance = segments[index];
|
|
13597
13413
|
if (total + distance > motionDistance) {
|
|
13598
|
-
HighBezierHelper.
|
|
13414
|
+
t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
13415
|
+
HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
|
|
13599
13416
|
return path;
|
|
13600
13417
|
}
|
|
13601
13418
|
x = toX;
|
|
@@ -13644,6 +13461,7 @@ var LeaferUI = (function (exports) {
|
|
|
13644
13461
|
const { updateMatrix, updateAllMatrix } = LeafHelper;
|
|
13645
13462
|
const { updateBounds } = BranchHelper;
|
|
13646
13463
|
motionPathType()(ui, 'motionPath');
|
|
13464
|
+
motionPathType(1)(ui, 'motionPrecision');
|
|
13647
13465
|
motionPathType()(ui, 'motion');
|
|
13648
13466
|
motionPathType(true)(ui, 'motionRotation');
|
|
13649
13467
|
ui.getMotionPathData = function () {
|
|
@@ -13654,7 +13472,7 @@ var LeaferUI = (function (exports) {
|
|
|
13654
13472
|
const data = getMotionPathData(path);
|
|
13655
13473
|
if (!data.total)
|
|
13656
13474
|
return {};
|
|
13657
|
-
const point = HighCurveHelper.getDistancePoint(data, motionDistance);
|
|
13475
|
+
const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision);
|
|
13658
13476
|
MatrixHelper.toOuterPoint(path.localTransform, point);
|
|
13659
13477
|
const { motionRotation } = this;
|
|
13660
13478
|
if (motionRotation === false)
|
|
@@ -13694,7 +13512,7 @@ var LeaferUI = (function (exports) {
|
|
|
13694
13512
|
if (leaf.motionPath) {
|
|
13695
13513
|
const data = getMotionPathData(leaf);
|
|
13696
13514
|
if (data.total)
|
|
13697
|
-
leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion);
|
|
13515
|
+
leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
|
|
13698
13516
|
}
|
|
13699
13517
|
else {
|
|
13700
13518
|
leaf.set(leaf.getMotionPoint(motion));
|
|
@@ -13745,6 +13563,7 @@ var LeaferUI = (function (exports) {
|
|
|
13745
13563
|
exports.Cursor = Cursor;
|
|
13746
13564
|
exports.DataHelper = DataHelper;
|
|
13747
13565
|
exports.Debug = Debug;
|
|
13566
|
+
exports.Dragger = Dragger;
|
|
13748
13567
|
exports.Effect = Effect;
|
|
13749
13568
|
exports.EllipseData = EllipseData;
|
|
13750
13569
|
exports.EllipseHelper = EllipseHelper;
|
|
@@ -13783,12 +13602,10 @@ var LeaferUI = (function (exports) {
|
|
|
13783
13602
|
exports.LeaferData = LeaferData;
|
|
13784
13603
|
exports.LeaferEvent = LeaferEvent;
|
|
13785
13604
|
exports.LeaferImage = LeaferImage;
|
|
13786
|
-
exports.LeaferTypeCreator = LeaferTypeCreator;
|
|
13787
13605
|
exports.LineData = LineData;
|
|
13788
13606
|
exports.MathHelper = MathHelper;
|
|
13789
13607
|
exports.Matrix = Matrix;
|
|
13790
13608
|
exports.MatrixHelper = MatrixHelper;
|
|
13791
|
-
exports.MultiTouchHelper = MultiTouchHelper;
|
|
13792
13609
|
exports.MyDragEvent = MyDragEvent;
|
|
13793
13610
|
exports.MyImage = MyImage;
|
|
13794
13611
|
exports.MyPointerEvent = MyPointerEvent;
|
|
@@ -13845,7 +13662,6 @@ var LeaferUI = (function (exports) {
|
|
|
13845
13662
|
exports.WaitHelper = WaitHelper;
|
|
13846
13663
|
exports.WatchEvent = WatchEvent;
|
|
13847
13664
|
exports.Watcher = Watcher;
|
|
13848
|
-
exports.addInteractionWindow = addInteractionWindow;
|
|
13849
13665
|
exports.affectRenderBoundsType = affectRenderBoundsType;
|
|
13850
13666
|
exports.affectStrokeBoundsType = affectStrokeBoundsType;
|
|
13851
13667
|
exports.attr = attr;
|