@leafer/core 1.0.2 → 1.0.4
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/lib/core.cjs +297 -203
- package/lib/core.esm.js +295 -202
- package/lib/core.esm.min.js +1 -1
- package/lib/core.min.cjs +1 -1
- package/package.json +17 -18
- package/src/index.ts +1 -4
- package/types/index.d.ts +2 -4
package/lib/core.cjs
CHANGED
|
@@ -121,11 +121,18 @@ const MathHelper = {
|
|
|
121
121
|
scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
|
|
122
122
|
scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
|
|
123
123
|
}
|
|
124
|
-
else if (scale)
|
|
125
|
-
scaleData
|
|
126
|
-
scaleData.scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
127
|
-
}
|
|
124
|
+
else if (scale)
|
|
125
|
+
MathHelper.assignScale(scaleData, scale);
|
|
128
126
|
return scaleData;
|
|
127
|
+
},
|
|
128
|
+
assignScale(scaleData, scale) {
|
|
129
|
+
if (typeof scale === 'number') {
|
|
130
|
+
scaleData.scaleX = scaleData.scaleY = scale;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
scaleData.scaleX = scale.x;
|
|
134
|
+
scaleData.scaleY = scale.y;
|
|
135
|
+
}
|
|
129
136
|
}
|
|
130
137
|
};
|
|
131
138
|
const OneRadian = PI$2 / 180;
|
|
@@ -1257,7 +1264,6 @@ const AroundHelper = {
|
|
|
1257
1264
|
tempPoint: {},
|
|
1258
1265
|
get,
|
|
1259
1266
|
toPoint(around, bounds, to, onlySize, pointBounds) {
|
|
1260
|
-
to || (to = {});
|
|
1261
1267
|
const point = get(around);
|
|
1262
1268
|
to.x = point.x;
|
|
1263
1269
|
to.y = point.y;
|
|
@@ -1392,6 +1398,10 @@ const Run = {
|
|
|
1392
1398
|
};
|
|
1393
1399
|
const R = Run;
|
|
1394
1400
|
|
|
1401
|
+
function needPlugin(name) {
|
|
1402
|
+
console.error('need plugin: @leafer-in/' + name);
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1395
1405
|
const debug$7 = Debug.get('UICreator');
|
|
1396
1406
|
const UICreator = {
|
|
1397
1407
|
list: {},
|
|
@@ -1654,6 +1664,9 @@ exports.Answer = void 0;
|
|
|
1654
1664
|
Answer[Answer["YesAndSkip"] = 3] = "YesAndSkip";
|
|
1655
1665
|
})(exports.Answer || (exports.Answer = {}));
|
|
1656
1666
|
const emptyData = {};
|
|
1667
|
+
function isNull(value) {
|
|
1668
|
+
return value === undefined || value === null;
|
|
1669
|
+
}
|
|
1657
1670
|
|
|
1658
1671
|
/******************************************************************************
|
|
1659
1672
|
Copyright (c) Microsoft Corporation.
|
|
@@ -2419,7 +2432,7 @@ const BezierHelper = {
|
|
|
2419
2432
|
let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
|
|
2420
2433
|
let fromX = cx + x, fromY = cy + y;
|
|
2421
2434
|
if (data)
|
|
2422
|
-
data.push(L$6, fromX, fromY);
|
|
2435
|
+
data.push(data.length ? L$6 : M$5, fromX, fromY);
|
|
2423
2436
|
if (setPointBounds)
|
|
2424
2437
|
setPoint$1(setPointBounds, fromX, fromY);
|
|
2425
2438
|
if (setStartPoint)
|
|
@@ -3088,8 +3101,7 @@ const PathBounds = {
|
|
|
3088
3101
|
toTwoPointBounds(data, setPointBounds) {
|
|
3089
3102
|
if (!data || !data.length)
|
|
3090
3103
|
return setPoint(setPointBounds, 0, 0);
|
|
3091
|
-
let command;
|
|
3092
|
-
let i = 0, x = 0, y = 0, x1, y1, toX, toY;
|
|
3104
|
+
let i = 0, x = 0, y = 0, x1, y1, toX, toY, command;
|
|
3093
3105
|
const len = data.length;
|
|
3094
3106
|
while (i < len) {
|
|
3095
3107
|
command = data[i];
|
|
@@ -3745,7 +3757,7 @@ function autoLayoutType(defaultValue) {
|
|
|
3745
3757
|
set(value) {
|
|
3746
3758
|
if (this.__setAttr(key, value)) {
|
|
3747
3759
|
this.__layout.matrixChanged || this.__layout.matrixChange();
|
|
3748
|
-
this.__hasAutoLayout = !!
|
|
3760
|
+
this.__hasAutoLayout = !!(this.origin || this.around || this.flow);
|
|
3749
3761
|
if (!this.__local)
|
|
3750
3762
|
this.__layout.createLocal();
|
|
3751
3763
|
}
|
|
@@ -3838,14 +3850,25 @@ function visibleType(defaultValue) {
|
|
|
3838
3850
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3839
3851
|
set(value) {
|
|
3840
3852
|
const oldValue = this.visible;
|
|
3841
|
-
if (
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3853
|
+
if (oldValue === true && value === 0) {
|
|
3854
|
+
if (this.animationOut)
|
|
3855
|
+
return this.__runAnimation('out', () => doVisible(this, key, value, oldValue));
|
|
3856
|
+
}
|
|
3857
|
+
else if (oldValue === 0 && value === true) {
|
|
3858
|
+
if (this.animation)
|
|
3859
|
+
this.__runAnimation('in');
|
|
3845
3860
|
}
|
|
3861
|
+
doVisible(this, key, value, oldValue);
|
|
3846
3862
|
}
|
|
3847
3863
|
}));
|
|
3848
3864
|
}
|
|
3865
|
+
function doVisible(leaf, key, value, oldValue) {
|
|
3866
|
+
if (leaf.__setAttr(key, value)) {
|
|
3867
|
+
leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
|
|
3868
|
+
if (oldValue === 0 || value === 0)
|
|
3869
|
+
doBoundsType(leaf);
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3849
3872
|
function sortType(defaultValue) {
|
|
3850
3873
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3851
3874
|
set(value) {
|
|
@@ -3929,7 +3952,16 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
3929
3952
|
if (defaultValue === undefined) {
|
|
3930
3953
|
property.get = function () { return this[computedKey]; };
|
|
3931
3954
|
}
|
|
3932
|
-
else if (
|
|
3955
|
+
else if (typeof defaultValue === 'object') {
|
|
3956
|
+
const { clone } = DataHelper;
|
|
3957
|
+
property.get = function () {
|
|
3958
|
+
let v = this[computedKey];
|
|
3959
|
+
if (v === undefined)
|
|
3960
|
+
this[computedKey] = v = clone(defaultValue);
|
|
3961
|
+
return v;
|
|
3962
|
+
};
|
|
3963
|
+
}
|
|
3964
|
+
if (key === 'width') {
|
|
3933
3965
|
property.get = function () {
|
|
3934
3966
|
const v = this[computedKey];
|
|
3935
3967
|
if (v === undefined) {
|
|
@@ -4453,15 +4485,16 @@ class LeafLayout {
|
|
|
4453
4485
|
}
|
|
4454
4486
|
getLayoutBounds(type, relative = 'world', unscale) {
|
|
4455
4487
|
const { leaf } = this;
|
|
4456
|
-
let point, matrix, bounds = this.getInnerBounds(type);
|
|
4488
|
+
let point, matrix, layoutBounds, bounds = this.getInnerBounds(type);
|
|
4457
4489
|
switch (relative) {
|
|
4458
4490
|
case 'world':
|
|
4459
4491
|
point = leaf.getWorldPoint(bounds);
|
|
4460
4492
|
matrix = leaf.__world;
|
|
4461
4493
|
break;
|
|
4462
4494
|
case 'local':
|
|
4495
|
+
const { scaleX, scaleY, rotation, skewX, skewY } = leaf.__;
|
|
4496
|
+
layoutBounds = { scaleX, scaleY, rotation, skewX, skewY };
|
|
4463
4497
|
point = leaf.getLocalPointByInner(bounds);
|
|
4464
|
-
matrix = leaf.__localMatrix;
|
|
4465
4498
|
break;
|
|
4466
4499
|
case 'inner':
|
|
4467
4500
|
point = bounds;
|
|
@@ -4473,7 +4506,8 @@ class LeafLayout {
|
|
|
4473
4506
|
point = leaf.getWorldPoint(bounds, relative);
|
|
4474
4507
|
matrix = getRelativeWorld$1(leaf, relative, true);
|
|
4475
4508
|
}
|
|
4476
|
-
|
|
4509
|
+
if (!layoutBounds)
|
|
4510
|
+
layoutBounds = MatrixHelper.getLayout(matrix);
|
|
4477
4511
|
copy$2(layoutBounds, bounds);
|
|
4478
4512
|
PointHelper.copy(layoutBounds, point);
|
|
4479
4513
|
if (unscale) {
|
|
@@ -4596,144 +4630,6 @@ class LeafLayout {
|
|
|
4596
4630
|
destroy() { }
|
|
4597
4631
|
}
|
|
4598
4632
|
|
|
4599
|
-
const empty = {};
|
|
4600
|
-
const LeafEventer = {
|
|
4601
|
-
on(type, listener, options) {
|
|
4602
|
-
let capture, once;
|
|
4603
|
-
if (options) {
|
|
4604
|
-
if (options === 'once') {
|
|
4605
|
-
once = true;
|
|
4606
|
-
}
|
|
4607
|
-
else if (typeof options === 'boolean') {
|
|
4608
|
-
capture = options;
|
|
4609
|
-
}
|
|
4610
|
-
else {
|
|
4611
|
-
capture = options.capture;
|
|
4612
|
-
once = options.once;
|
|
4613
|
-
}
|
|
4614
|
-
}
|
|
4615
|
-
let events;
|
|
4616
|
-
const map = __getListenerMap(this, capture, true);
|
|
4617
|
-
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4618
|
-
const item = once ? { listener, once } : { listener };
|
|
4619
|
-
typeList.forEach(type => {
|
|
4620
|
-
if (type) {
|
|
4621
|
-
events = map[type];
|
|
4622
|
-
if (events) {
|
|
4623
|
-
if (events.findIndex(item => item.listener === listener) === -1)
|
|
4624
|
-
events.push(item);
|
|
4625
|
-
}
|
|
4626
|
-
else {
|
|
4627
|
-
map[type] = [item];
|
|
4628
|
-
}
|
|
4629
|
-
}
|
|
4630
|
-
});
|
|
4631
|
-
},
|
|
4632
|
-
off(type, listener, options) {
|
|
4633
|
-
if (type) {
|
|
4634
|
-
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4635
|
-
if (listener) {
|
|
4636
|
-
let capture;
|
|
4637
|
-
if (options)
|
|
4638
|
-
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4639
|
-
let events, index;
|
|
4640
|
-
const map = __getListenerMap(this, capture);
|
|
4641
|
-
typeList.forEach(type => {
|
|
4642
|
-
if (type) {
|
|
4643
|
-
events = map[type];
|
|
4644
|
-
if (events) {
|
|
4645
|
-
index = events.findIndex(item => item.listener === listener);
|
|
4646
|
-
if (index > -1)
|
|
4647
|
-
events.splice(index, 1);
|
|
4648
|
-
if (!events.length)
|
|
4649
|
-
delete map[type];
|
|
4650
|
-
}
|
|
4651
|
-
}
|
|
4652
|
-
});
|
|
4653
|
-
}
|
|
4654
|
-
else {
|
|
4655
|
-
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4656
|
-
typeList.forEach(type => {
|
|
4657
|
-
if (b)
|
|
4658
|
-
delete b[type];
|
|
4659
|
-
if (c)
|
|
4660
|
-
delete c[type];
|
|
4661
|
-
});
|
|
4662
|
-
}
|
|
4663
|
-
}
|
|
4664
|
-
else {
|
|
4665
|
-
this.__bubbleMap = this.__captureMap = undefined;
|
|
4666
|
-
}
|
|
4667
|
-
},
|
|
4668
|
-
on_(type, listener, bind, options) {
|
|
4669
|
-
if (bind)
|
|
4670
|
-
listener = listener.bind(bind);
|
|
4671
|
-
this.on(type, listener, options);
|
|
4672
|
-
return { type, current: this, listener, options };
|
|
4673
|
-
},
|
|
4674
|
-
off_(id) {
|
|
4675
|
-
if (!id)
|
|
4676
|
-
return;
|
|
4677
|
-
const list = id instanceof Array ? id : [id];
|
|
4678
|
-
list.forEach(item => item.current.off(item.type, item.listener, item.options));
|
|
4679
|
-
list.length = 0;
|
|
4680
|
-
},
|
|
4681
|
-
once(type, listener, capture) {
|
|
4682
|
-
this.on(type, listener, { once: true, capture });
|
|
4683
|
-
},
|
|
4684
|
-
emit(type, event, capture) {
|
|
4685
|
-
if (!event && EventCreator.has(type))
|
|
4686
|
-
event = EventCreator.get(type, { type, target: this, current: this });
|
|
4687
|
-
const map = __getListenerMap(this, capture);
|
|
4688
|
-
const list = map[type];
|
|
4689
|
-
if (list) {
|
|
4690
|
-
let item;
|
|
4691
|
-
for (let i = 0, len = list.length; i < len; i++) {
|
|
4692
|
-
item = list[i];
|
|
4693
|
-
item.listener(event);
|
|
4694
|
-
if (item.once) {
|
|
4695
|
-
this.off(type, item.listener, capture);
|
|
4696
|
-
i--, len--;
|
|
4697
|
-
}
|
|
4698
|
-
if (event && event.isStopNow)
|
|
4699
|
-
break;
|
|
4700
|
-
}
|
|
4701
|
-
}
|
|
4702
|
-
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4703
|
-
},
|
|
4704
|
-
emitEvent(event, capture) {
|
|
4705
|
-
event.current = this;
|
|
4706
|
-
this.emit(event.type, event, capture);
|
|
4707
|
-
},
|
|
4708
|
-
hasEvent(type, capture) {
|
|
4709
|
-
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4710
|
-
return true;
|
|
4711
|
-
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4712
|
-
const hasB = b && b[type], hasC = c && c[type];
|
|
4713
|
-
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
4714
|
-
},
|
|
4715
|
-
};
|
|
4716
|
-
function __getListenerMap(eventer, capture, create) {
|
|
4717
|
-
if (capture) {
|
|
4718
|
-
const { __captureMap: c } = eventer;
|
|
4719
|
-
if (c) {
|
|
4720
|
-
return c;
|
|
4721
|
-
}
|
|
4722
|
-
else {
|
|
4723
|
-
return create ? eventer.__captureMap = {} : empty;
|
|
4724
|
-
}
|
|
4725
|
-
}
|
|
4726
|
-
else {
|
|
4727
|
-
const { __bubbleMap: b } = eventer;
|
|
4728
|
-
if (b) {
|
|
4729
|
-
return b;
|
|
4730
|
-
}
|
|
4731
|
-
else {
|
|
4732
|
-
return create ? eventer.__bubbleMap = {} : empty;
|
|
4733
|
-
}
|
|
4734
|
-
}
|
|
4735
|
-
}
|
|
4736
|
-
|
|
4737
4633
|
class Event {
|
|
4738
4634
|
constructor(type, target) {
|
|
4739
4635
|
this.bubbles = false;
|
|
@@ -4768,7 +4664,10 @@ class ChildEvent extends Event {
|
|
|
4768
4664
|
}
|
|
4769
4665
|
ChildEvent.ADD = 'child.add';
|
|
4770
4666
|
ChildEvent.REMOVE = 'child.remove';
|
|
4771
|
-
ChildEvent.
|
|
4667
|
+
ChildEvent.CREATED = 'created';
|
|
4668
|
+
ChildEvent.MOUNTED = 'mounted';
|
|
4669
|
+
ChildEvent.UNMOUNTED = 'unmounted';
|
|
4670
|
+
ChildEvent.DESTROY = 'destroy';
|
|
4772
4671
|
|
|
4773
4672
|
class PropertyEvent extends Event {
|
|
4774
4673
|
constructor(type, target, attrName, oldValue, newValue) {
|
|
@@ -4846,10 +4745,6 @@ LayoutEvent.AFTER = 'layout.after';
|
|
|
4846
4745
|
LayoutEvent.AGAIN = 'layout.again';
|
|
4847
4746
|
LayoutEvent.END = 'layout.end';
|
|
4848
4747
|
|
|
4849
|
-
class AnimateEvent extends Event {
|
|
4850
|
-
}
|
|
4851
|
-
AnimateEvent.FRAME = 'animate.frame';
|
|
4852
|
-
|
|
4853
4748
|
class RenderEvent extends Event {
|
|
4854
4749
|
constructor(type, times, bounds, options) {
|
|
4855
4750
|
super(type);
|
|
@@ -4882,6 +4777,157 @@ LeaferEvent.STOP = 'leafer.stop';
|
|
|
4882
4777
|
LeaferEvent.RESTART = 'leafer.restart';
|
|
4883
4778
|
LeaferEvent.END = 'leafer.end';
|
|
4884
4779
|
|
|
4780
|
+
const empty = {};
|
|
4781
|
+
class Eventer {
|
|
4782
|
+
set event(map) { this.on(map); }
|
|
4783
|
+
on(type, listener, options) {
|
|
4784
|
+
if (!listener) {
|
|
4785
|
+
let event, map = type;
|
|
4786
|
+
for (let key in map)
|
|
4787
|
+
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
|
|
4788
|
+
return;
|
|
4789
|
+
}
|
|
4790
|
+
let capture, once;
|
|
4791
|
+
if (options) {
|
|
4792
|
+
if (options === 'once') {
|
|
4793
|
+
once = true;
|
|
4794
|
+
}
|
|
4795
|
+
else if (typeof options === 'boolean') {
|
|
4796
|
+
capture = options;
|
|
4797
|
+
}
|
|
4798
|
+
else {
|
|
4799
|
+
capture = options.capture;
|
|
4800
|
+
once = options.once;
|
|
4801
|
+
}
|
|
4802
|
+
}
|
|
4803
|
+
let events;
|
|
4804
|
+
const map = __getListenerMap(this, capture, true);
|
|
4805
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4806
|
+
const item = once ? { listener, once } : { listener };
|
|
4807
|
+
typeList.forEach(type => {
|
|
4808
|
+
if (type) {
|
|
4809
|
+
events = map[type];
|
|
4810
|
+
if (events) {
|
|
4811
|
+
if (events.findIndex(item => item.listener === listener) === -1)
|
|
4812
|
+
events.push(item);
|
|
4813
|
+
}
|
|
4814
|
+
else {
|
|
4815
|
+
map[type] = [item];
|
|
4816
|
+
}
|
|
4817
|
+
}
|
|
4818
|
+
});
|
|
4819
|
+
}
|
|
4820
|
+
off(type, listener, options) {
|
|
4821
|
+
if (type) {
|
|
4822
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4823
|
+
if (listener) {
|
|
4824
|
+
let capture;
|
|
4825
|
+
if (options)
|
|
4826
|
+
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4827
|
+
let events, index;
|
|
4828
|
+
const map = __getListenerMap(this, capture);
|
|
4829
|
+
typeList.forEach(type => {
|
|
4830
|
+
if (type) {
|
|
4831
|
+
events = map[type];
|
|
4832
|
+
if (events) {
|
|
4833
|
+
index = events.findIndex(item => item.listener === listener);
|
|
4834
|
+
if (index > -1)
|
|
4835
|
+
events.splice(index, 1);
|
|
4836
|
+
if (!events.length)
|
|
4837
|
+
delete map[type];
|
|
4838
|
+
}
|
|
4839
|
+
}
|
|
4840
|
+
});
|
|
4841
|
+
}
|
|
4842
|
+
else {
|
|
4843
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4844
|
+
typeList.forEach(type => {
|
|
4845
|
+
if (b)
|
|
4846
|
+
delete b[type];
|
|
4847
|
+
if (c)
|
|
4848
|
+
delete c[type];
|
|
4849
|
+
});
|
|
4850
|
+
}
|
|
4851
|
+
}
|
|
4852
|
+
else {
|
|
4853
|
+
this.__bubbleMap = this.__captureMap = undefined;
|
|
4854
|
+
}
|
|
4855
|
+
}
|
|
4856
|
+
on_(type, listener, bind, options) {
|
|
4857
|
+
if (bind)
|
|
4858
|
+
listener = listener.bind(bind);
|
|
4859
|
+
this.on(type, listener, options);
|
|
4860
|
+
return { type, current: this, listener, options };
|
|
4861
|
+
}
|
|
4862
|
+
off_(id) {
|
|
4863
|
+
if (!id)
|
|
4864
|
+
return;
|
|
4865
|
+
const list = id instanceof Array ? id : [id];
|
|
4866
|
+
list.forEach(item => item.current.off(item.type, item.listener, item.options));
|
|
4867
|
+
list.length = 0;
|
|
4868
|
+
}
|
|
4869
|
+
once(type, listener, capture) {
|
|
4870
|
+
this.on(type, listener, { once: true, capture });
|
|
4871
|
+
}
|
|
4872
|
+
emit(type, event, capture) {
|
|
4873
|
+
if (!event && EventCreator.has(type))
|
|
4874
|
+
event = EventCreator.get(type, { type, target: this, current: this });
|
|
4875
|
+
const map = __getListenerMap(this, capture);
|
|
4876
|
+
const list = map[type];
|
|
4877
|
+
if (list) {
|
|
4878
|
+
let item;
|
|
4879
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
4880
|
+
item = list[i];
|
|
4881
|
+
item.listener(event);
|
|
4882
|
+
if (item.once) {
|
|
4883
|
+
this.off(type, item.listener, capture);
|
|
4884
|
+
i--, len--;
|
|
4885
|
+
}
|
|
4886
|
+
if (event && event.isStopNow)
|
|
4887
|
+
break;
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4890
|
+
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4891
|
+
}
|
|
4892
|
+
emitEvent(event, capture) {
|
|
4893
|
+
event.current = this;
|
|
4894
|
+
this.emit(event.type, event, capture);
|
|
4895
|
+
}
|
|
4896
|
+
hasEvent(type, capture) {
|
|
4897
|
+
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4898
|
+
return true;
|
|
4899
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4900
|
+
const hasB = b && b[type], hasC = c && c[type];
|
|
4901
|
+
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
4902
|
+
}
|
|
4903
|
+
destroy() {
|
|
4904
|
+
this.__captureMap = this.__bubbleMap = this.syncEventer = null;
|
|
4905
|
+
}
|
|
4906
|
+
}
|
|
4907
|
+
function __getListenerMap(eventer, capture, create) {
|
|
4908
|
+
if (capture) {
|
|
4909
|
+
const { __captureMap: c } = eventer;
|
|
4910
|
+
if (c) {
|
|
4911
|
+
return c;
|
|
4912
|
+
}
|
|
4913
|
+
else {
|
|
4914
|
+
return create ? eventer.__captureMap = {} : empty;
|
|
4915
|
+
}
|
|
4916
|
+
}
|
|
4917
|
+
else {
|
|
4918
|
+
const { __bubbleMap: b } = eventer;
|
|
4919
|
+
if (b) {
|
|
4920
|
+
return b;
|
|
4921
|
+
}
|
|
4922
|
+
else {
|
|
4923
|
+
return create ? eventer.__bubbleMap = {} : empty;
|
|
4924
|
+
}
|
|
4925
|
+
}
|
|
4926
|
+
}
|
|
4927
|
+
|
|
4928
|
+
const { on, on_, off, off_, once, emit, emitEvent, hasEvent, destroy } = Eventer.prototype;
|
|
4929
|
+
const LeafEventer = { on, on_, off, off_, once, emit, emitEvent, hasEvent, destroyEventer: destroy };
|
|
4930
|
+
|
|
4885
4931
|
const { isFinite } = Number;
|
|
4886
4932
|
const debug = Debug.get('setAttr');
|
|
4887
4933
|
const LeafDataProxy = {
|
|
@@ -4893,9 +4939,7 @@ const LeafDataProxy = {
|
|
|
4893
4939
|
newValue = undefined;
|
|
4894
4940
|
}
|
|
4895
4941
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
4896
|
-
this.
|
|
4897
|
-
if (this.__proxyData)
|
|
4898
|
-
this.setProxyAttr(name, newValue);
|
|
4942
|
+
this.__realSetAttr(name, newValue);
|
|
4899
4943
|
const { CHANGE } = PropertyEvent;
|
|
4900
4944
|
const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
|
|
4901
4945
|
if (this.isLeafer) {
|
|
@@ -4913,12 +4957,18 @@ const LeafDataProxy = {
|
|
|
4913
4957
|
}
|
|
4914
4958
|
}
|
|
4915
4959
|
else {
|
|
4916
|
-
this.
|
|
4917
|
-
if (this.__proxyData)
|
|
4918
|
-
this.setProxyAttr(name, newValue);
|
|
4960
|
+
this.__realSetAttr(name, newValue);
|
|
4919
4961
|
return true;
|
|
4920
4962
|
}
|
|
4921
4963
|
},
|
|
4964
|
+
__realSetAttr(name, newValue) {
|
|
4965
|
+
const data = this.__;
|
|
4966
|
+
data[name] = newValue;
|
|
4967
|
+
if (this.__proxyData)
|
|
4968
|
+
this.setProxyAttr(name, newValue);
|
|
4969
|
+
if (data.normalStyle)
|
|
4970
|
+
this.lockNormalStyle || data.normalStyle[name] === undefined || (data.normalStyle[name] = newValue);
|
|
4971
|
+
},
|
|
4922
4972
|
__getAttr(name) {
|
|
4923
4973
|
if (this.__proxyData)
|
|
4924
4974
|
return this.getProxyAttr(name);
|
|
@@ -5021,6 +5071,8 @@ const LeafBounds = {
|
|
|
5021
5071
|
layout.boundsChanged = false;
|
|
5022
5072
|
},
|
|
5023
5073
|
__updateLocalBoxBounds() {
|
|
5074
|
+
if (this.__hasMotionPath)
|
|
5075
|
+
this.__updateMotionPath();
|
|
5024
5076
|
if (this.__hasAutoLayout)
|
|
5025
5077
|
this.__updateAutoLayout();
|
|
5026
5078
|
toOuterOf$1(this.__layout.boxBounds, this.__local, this.__local);
|
|
@@ -5173,7 +5225,7 @@ const BranchRender = {
|
|
|
5173
5225
|
const { LEAF, create } = IncrementId;
|
|
5174
5226
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5175
5227
|
const { toOuterOf } = BoundsHelper;
|
|
5176
|
-
const { copy } = PointHelper;
|
|
5228
|
+
const { copy, move } = PointHelper;
|
|
5177
5229
|
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5178
5230
|
exports.Leaf = class Leaf {
|
|
5179
5231
|
get tag() { return this.__tag; }
|
|
@@ -5200,13 +5252,16 @@ exports.Leaf = class Leaf {
|
|
|
5200
5252
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5201
5253
|
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5202
5254
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5203
|
-
set event(map) {
|
|
5204
|
-
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
|
|
5255
|
+
set event(map) { this.on(map); }
|
|
5205
5256
|
constructor(data) {
|
|
5206
5257
|
this.innerId = create(LEAF);
|
|
5207
5258
|
this.reset(data);
|
|
5259
|
+
if (this.__bubbleMap)
|
|
5260
|
+
this.__emitLifeEvent(ChildEvent.CREATED);
|
|
5208
5261
|
}
|
|
5209
5262
|
reset(data) {
|
|
5263
|
+
if (this.leafer)
|
|
5264
|
+
this.leafer.forceRender(this.__world);
|
|
5210
5265
|
this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1 };
|
|
5211
5266
|
if (data !== null)
|
|
5212
5267
|
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -5228,12 +5283,12 @@ exports.Leaf = class Leaf {
|
|
|
5228
5283
|
waitParent(item, bind) {
|
|
5229
5284
|
if (bind)
|
|
5230
5285
|
item = item.bind(bind);
|
|
5231
|
-
this.parent ? item() :
|
|
5286
|
+
this.parent ? item() : this.on(ChildEvent.ADD, item, 'once');
|
|
5232
5287
|
}
|
|
5233
5288
|
waitLeafer(item, bind) {
|
|
5234
5289
|
if (bind)
|
|
5235
5290
|
item = item.bind(bind);
|
|
5236
|
-
this.leafer ? item() :
|
|
5291
|
+
this.leafer ? item() : this.on(ChildEvent.MOUNTED, item, 'once');
|
|
5237
5292
|
}
|
|
5238
5293
|
nextRender(item, bind, off) {
|
|
5239
5294
|
this.leafer ? this.leafer.nextRender(item, bind, off) : this.waitLeafer(() => this.leafer.nextRender(item, bind, off));
|
|
@@ -5242,18 +5297,21 @@ exports.Leaf = class Leaf {
|
|
|
5242
5297
|
this.nextRender(item, null, 'off');
|
|
5243
5298
|
}
|
|
5244
5299
|
__bindLeafer(leafer) {
|
|
5245
|
-
if (this.isLeafer)
|
|
5246
|
-
|
|
5247
|
-
leafer = this;
|
|
5248
|
-
}
|
|
5300
|
+
if (this.isLeafer && leafer !== null)
|
|
5301
|
+
leafer = this;
|
|
5249
5302
|
if (this.leafer && !leafer)
|
|
5250
5303
|
this.leafer.leafs--;
|
|
5251
5304
|
this.leafer = leafer;
|
|
5252
5305
|
if (leafer) {
|
|
5253
5306
|
leafer.leafs++;
|
|
5254
5307
|
this.__level = this.parent ? this.parent.__level + 1 : 1;
|
|
5255
|
-
if (this.
|
|
5256
|
-
|
|
5308
|
+
if (this.animation)
|
|
5309
|
+
this.__runAnimation('in');
|
|
5310
|
+
if (this.__bubbleMap)
|
|
5311
|
+
this.__emitLifeEvent(ChildEvent.MOUNTED);
|
|
5312
|
+
}
|
|
5313
|
+
else {
|
|
5314
|
+
this.__emitLifeEvent(ChildEvent.UNMOUNTED);
|
|
5257
5315
|
}
|
|
5258
5316
|
if (this.isBranch) {
|
|
5259
5317
|
const { children } = this;
|
|
@@ -5262,7 +5320,7 @@ exports.Leaf = class Leaf {
|
|
|
5262
5320
|
}
|
|
5263
5321
|
}
|
|
5264
5322
|
}
|
|
5265
|
-
set(_data) { }
|
|
5323
|
+
set(_data, _isTemp) { }
|
|
5266
5324
|
get(_name) { return undefined; }
|
|
5267
5325
|
setAttr(name, value) { this[name] = value; }
|
|
5268
5326
|
getAttr(name) { return this[name]; }
|
|
@@ -5287,6 +5345,7 @@ exports.Leaf = class Leaf {
|
|
|
5287
5345
|
findOne(_condition, _options) { return undefined; }
|
|
5288
5346
|
findId(_id) { return undefined; }
|
|
5289
5347
|
focus(_value) { }
|
|
5348
|
+
updateState() { }
|
|
5290
5349
|
updateLayout() {
|
|
5291
5350
|
this.__layout.update();
|
|
5292
5351
|
}
|
|
@@ -5394,11 +5453,24 @@ exports.Leaf = class Leaf {
|
|
|
5394
5453
|
if (relative)
|
|
5395
5454
|
relative.worldToInner(to ? to : inner, null, distance);
|
|
5396
5455
|
}
|
|
5456
|
+
getBoxPoint(world, relative, distance, change) {
|
|
5457
|
+
return this.getBoxPointByInner(this.getInnerPoint(world, relative, distance, change), null, null, true);
|
|
5458
|
+
}
|
|
5459
|
+
getBoxPointByInner(inner, _relative, _distance, change) {
|
|
5460
|
+
const point = change ? inner : Object.assign({}, inner), { x, y } = this.boxBounds;
|
|
5461
|
+
move(point, -x, -y);
|
|
5462
|
+
return point;
|
|
5463
|
+
}
|
|
5397
5464
|
getInnerPoint(world, relative, distance, change) {
|
|
5398
5465
|
const point = change ? world : {};
|
|
5399
5466
|
this.worldToInner(world, point, distance, relative);
|
|
5400
5467
|
return point;
|
|
5401
5468
|
}
|
|
5469
|
+
getInnerPointByBox(box, _relative, _distance, change) {
|
|
5470
|
+
const point = change ? box : Object.assign({}, box), { x, y } = this.boxBounds;
|
|
5471
|
+
move(point, x, y);
|
|
5472
|
+
return point;
|
|
5473
|
+
}
|
|
5402
5474
|
getInnerPointByLocal(local, _relative, distance, change) {
|
|
5403
5475
|
return this.getInnerPoint(local, this.parent, distance, change);
|
|
5404
5476
|
}
|
|
@@ -5410,20 +5482,23 @@ exports.Leaf = class Leaf {
|
|
|
5410
5482
|
getLocalPointByInner(inner, _relative, distance, change) {
|
|
5411
5483
|
return this.getWorldPoint(inner, this.parent, distance, change);
|
|
5412
5484
|
}
|
|
5485
|
+
getPagePoint(world, relative, distance, change) {
|
|
5486
|
+
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5487
|
+
return layer.getInnerPoint(world, relative, distance, change);
|
|
5488
|
+
}
|
|
5413
5489
|
getWorldPoint(inner, relative, distance, change) {
|
|
5414
5490
|
const point = change ? inner : {};
|
|
5415
5491
|
this.innerToWorld(inner, point, distance, relative);
|
|
5416
5492
|
return point;
|
|
5417
5493
|
}
|
|
5494
|
+
getWorldPointByBox(box, relative, distance, change) {
|
|
5495
|
+
return this.getWorldPoint(this.getInnerPointByBox(box, null, null, change), relative, distance, true);
|
|
5496
|
+
}
|
|
5418
5497
|
getWorldPointByLocal(local, relative, distance, change) {
|
|
5419
5498
|
const point = change ? local : {};
|
|
5420
5499
|
this.localToWorld(local, point, distance, relative);
|
|
5421
5500
|
return point;
|
|
5422
5501
|
}
|
|
5423
|
-
getPagePoint(world, relative, distance, change) {
|
|
5424
|
-
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5425
|
-
return layer.getInnerPoint(world, relative, distance, change);
|
|
5426
|
-
}
|
|
5427
5502
|
getWorldPointByPage(page, relative, distance, change) {
|
|
5428
5503
|
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5429
5504
|
return layer.getWorldPoint(page, relative, distance, change);
|
|
@@ -5492,6 +5567,17 @@ exports.Leaf = class Leaf {
|
|
|
5492
5567
|
__drawRenderPath(_canvas) { }
|
|
5493
5568
|
__updatePath() { }
|
|
5494
5569
|
__updateRenderPath() { }
|
|
5570
|
+
getMotionPathData() {
|
|
5571
|
+
return needPlugin('path');
|
|
5572
|
+
}
|
|
5573
|
+
getMotionPoint(_motionDistance) {
|
|
5574
|
+
return needPlugin('path');
|
|
5575
|
+
}
|
|
5576
|
+
getMotionTotal() {
|
|
5577
|
+
return 0;
|
|
5578
|
+
}
|
|
5579
|
+
__updateMotionPath() { }
|
|
5580
|
+
__runAnimation(_type, _complete) { }
|
|
5495
5581
|
__updateSortChildren() { }
|
|
5496
5582
|
add(_child, _index) { }
|
|
5497
5583
|
remove(_child, destroy) {
|
|
@@ -5517,6 +5603,10 @@ exports.Leaf = class Leaf {
|
|
|
5517
5603
|
fn = boundsType;
|
|
5518
5604
|
fn(defaultValue)(this.prototype, attrName);
|
|
5519
5605
|
}
|
|
5606
|
+
__emitLifeEvent(type) {
|
|
5607
|
+
if (this.hasEvent(type))
|
|
5608
|
+
this.emitEvent(new ChildEvent(type, this, this.parent));
|
|
5609
|
+
}
|
|
5520
5610
|
destroy() {
|
|
5521
5611
|
if (!this.destroyed) {
|
|
5522
5612
|
const { parent } = this;
|
|
@@ -5524,11 +5614,10 @@ exports.Leaf = class Leaf {
|
|
|
5524
5614
|
this.remove();
|
|
5525
5615
|
if (this.children)
|
|
5526
5616
|
this.removeAll(true);
|
|
5527
|
-
|
|
5528
|
-
this.emitEvent(new ChildEvent(ChildEvent.DESTROY, this, parent));
|
|
5617
|
+
this.__emitLifeEvent(ChildEvent.DESTROY);
|
|
5529
5618
|
this.__.destroy();
|
|
5530
5619
|
this.__layout.destroy();
|
|
5531
|
-
this.
|
|
5620
|
+
this.destroyEventer();
|
|
5532
5621
|
this.destroyed = true;
|
|
5533
5622
|
}
|
|
5534
5623
|
}
|
|
@@ -5594,8 +5683,8 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5594
5683
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5595
5684
|
child.__layout.boxChanged || child.__layout.boxChange();
|
|
5596
5685
|
child.__layout.matrixChanged || child.__layout.matrixChange();
|
|
5597
|
-
if (child.
|
|
5598
|
-
|
|
5686
|
+
if (child.__bubbleMap)
|
|
5687
|
+
child.__emitLifeEvent(ChildEvent.ADD);
|
|
5599
5688
|
if (this.leafer) {
|
|
5600
5689
|
child.__bindLeafer(this.leafer);
|
|
5601
5690
|
if (this.leafer.created)
|
|
@@ -5608,16 +5697,10 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5608
5697
|
}
|
|
5609
5698
|
remove(child, destroy) {
|
|
5610
5699
|
if (child) {
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1;
|
|
5616
|
-
this.__preRemove();
|
|
5617
|
-
this.__realRemoveChild(child);
|
|
5618
|
-
if (destroy)
|
|
5619
|
-
child.destroy();
|
|
5620
|
-
}
|
|
5700
|
+
if (child.animationOut)
|
|
5701
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5702
|
+
else
|
|
5703
|
+
this.__remove(child, destroy);
|
|
5621
5704
|
}
|
|
5622
5705
|
else if (child === undefined) {
|
|
5623
5706
|
super.remove(null, destroy);
|
|
@@ -5639,6 +5722,18 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5639
5722
|
clear() {
|
|
5640
5723
|
this.removeAll(true);
|
|
5641
5724
|
}
|
|
5725
|
+
__remove(child, destroy) {
|
|
5726
|
+
const index = this.children.indexOf(child);
|
|
5727
|
+
if (index > -1) {
|
|
5728
|
+
this.children.splice(index, 1);
|
|
5729
|
+
if (child.isBranch)
|
|
5730
|
+
this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1;
|
|
5731
|
+
this.__preRemove();
|
|
5732
|
+
this.__realRemoveChild(child);
|
|
5733
|
+
if (destroy)
|
|
5734
|
+
child.destroy();
|
|
5735
|
+
}
|
|
5736
|
+
}
|
|
5642
5737
|
__preRemove() {
|
|
5643
5738
|
if (this.__hasMask)
|
|
5644
5739
|
this.__updateMask();
|
|
@@ -5648,6 +5743,7 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5648
5743
|
this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
|
|
5649
5744
|
}
|
|
5650
5745
|
__realRemoveChild(child) {
|
|
5746
|
+
child.__emitLifeEvent(ChildEvent.REMOVE);
|
|
5651
5747
|
child.parent = null;
|
|
5652
5748
|
if (this.leafer) {
|
|
5653
5749
|
child.__bindLeafer(null);
|
|
@@ -5660,8 +5756,6 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5660
5756
|
}
|
|
5661
5757
|
__emitChildEvent(type, child) {
|
|
5662
5758
|
const event = new ChildEvent(type, child, this);
|
|
5663
|
-
if (child.hasEvent(type))
|
|
5664
|
-
child.emitEvent(event);
|
|
5665
5759
|
if (this.hasEvent(type) && !this.isLeafer)
|
|
5666
5760
|
this.emitEvent(event);
|
|
5667
5761
|
this.leafer.emitEvent(event);
|
|
@@ -5824,11 +5918,9 @@ class LeafLevelList {
|
|
|
5824
5918
|
}
|
|
5825
5919
|
}
|
|
5826
5920
|
|
|
5827
|
-
const version = "1.0.
|
|
5828
|
-
const inviteCode = {};
|
|
5921
|
+
const version = "1.0.4";
|
|
5829
5922
|
|
|
5830
5923
|
exports.AlignHelper = AlignHelper;
|
|
5831
|
-
exports.AnimateEvent = AnimateEvent;
|
|
5832
5924
|
exports.AroundHelper = AroundHelper;
|
|
5833
5925
|
exports.AutoBounds = AutoBounds;
|
|
5834
5926
|
exports.BezierHelper = BezierHelper;
|
|
@@ -5844,6 +5936,7 @@ exports.Debug = Debug;
|
|
|
5844
5936
|
exports.EllipseHelper = EllipseHelper;
|
|
5845
5937
|
exports.Event = Event;
|
|
5846
5938
|
exports.EventCreator = EventCreator;
|
|
5939
|
+
exports.Eventer = Eventer;
|
|
5847
5940
|
exports.FileHelper = FileHelper;
|
|
5848
5941
|
exports.ImageEvent = ImageEvent;
|
|
5849
5942
|
exports.ImageManager = ImageManager;
|
|
@@ -5918,10 +6011,11 @@ exports.getDescriptor = getDescriptor;
|
|
|
5918
6011
|
exports.getMatrixData = getMatrixData;
|
|
5919
6012
|
exports.getPointData = getPointData;
|
|
5920
6013
|
exports.hitType = hitType;
|
|
5921
|
-
exports.
|
|
6014
|
+
exports.isNull = isNull;
|
|
5922
6015
|
exports.layoutProcessor = layoutProcessor;
|
|
5923
6016
|
exports.maskType = maskType;
|
|
5924
6017
|
exports.naturalBoundsType = naturalBoundsType;
|
|
6018
|
+
exports.needPlugin = needPlugin;
|
|
5925
6019
|
exports.opacityType = opacityType;
|
|
5926
6020
|
exports.pathInputType = pathInputType;
|
|
5927
6021
|
exports.pathType = pathType;
|