@leafer/core 1.0.2 → 1.0.3
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 +292 -200
- package/lib/core.esm.js +290 -199
- 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) {
|
|
@@ -4596,144 +4628,6 @@ class LeafLayout {
|
|
|
4596
4628
|
destroy() { }
|
|
4597
4629
|
}
|
|
4598
4630
|
|
|
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
4631
|
class Event {
|
|
4738
4632
|
constructor(type, target) {
|
|
4739
4633
|
this.bubbles = false;
|
|
@@ -4768,7 +4662,10 @@ class ChildEvent extends Event {
|
|
|
4768
4662
|
}
|
|
4769
4663
|
ChildEvent.ADD = 'child.add';
|
|
4770
4664
|
ChildEvent.REMOVE = 'child.remove';
|
|
4771
|
-
ChildEvent.
|
|
4665
|
+
ChildEvent.CREATED = 'created';
|
|
4666
|
+
ChildEvent.MOUNTED = 'mounted';
|
|
4667
|
+
ChildEvent.UNMOUNTED = 'unmounted';
|
|
4668
|
+
ChildEvent.DESTROY = 'destroy';
|
|
4772
4669
|
|
|
4773
4670
|
class PropertyEvent extends Event {
|
|
4774
4671
|
constructor(type, target, attrName, oldValue, newValue) {
|
|
@@ -4846,10 +4743,6 @@ LayoutEvent.AFTER = 'layout.after';
|
|
|
4846
4743
|
LayoutEvent.AGAIN = 'layout.again';
|
|
4847
4744
|
LayoutEvent.END = 'layout.end';
|
|
4848
4745
|
|
|
4849
|
-
class AnimateEvent extends Event {
|
|
4850
|
-
}
|
|
4851
|
-
AnimateEvent.FRAME = 'animate.frame';
|
|
4852
|
-
|
|
4853
4746
|
class RenderEvent extends Event {
|
|
4854
4747
|
constructor(type, times, bounds, options) {
|
|
4855
4748
|
super(type);
|
|
@@ -4882,6 +4775,157 @@ LeaferEvent.STOP = 'leafer.stop';
|
|
|
4882
4775
|
LeaferEvent.RESTART = 'leafer.restart';
|
|
4883
4776
|
LeaferEvent.END = 'leafer.end';
|
|
4884
4777
|
|
|
4778
|
+
const empty = {};
|
|
4779
|
+
class Eventer {
|
|
4780
|
+
set event(map) { this.on(map); }
|
|
4781
|
+
on(type, listener, options) {
|
|
4782
|
+
if (!listener) {
|
|
4783
|
+
let event, map = type;
|
|
4784
|
+
for (let key in map)
|
|
4785
|
+
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event);
|
|
4786
|
+
return;
|
|
4787
|
+
}
|
|
4788
|
+
let capture, once;
|
|
4789
|
+
if (options) {
|
|
4790
|
+
if (options === 'once') {
|
|
4791
|
+
once = true;
|
|
4792
|
+
}
|
|
4793
|
+
else if (typeof options === 'boolean') {
|
|
4794
|
+
capture = options;
|
|
4795
|
+
}
|
|
4796
|
+
else {
|
|
4797
|
+
capture = options.capture;
|
|
4798
|
+
once = options.once;
|
|
4799
|
+
}
|
|
4800
|
+
}
|
|
4801
|
+
let events;
|
|
4802
|
+
const map = __getListenerMap(this, capture, true);
|
|
4803
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4804
|
+
const item = once ? { listener, once } : { listener };
|
|
4805
|
+
typeList.forEach(type => {
|
|
4806
|
+
if (type) {
|
|
4807
|
+
events = map[type];
|
|
4808
|
+
if (events) {
|
|
4809
|
+
if (events.findIndex(item => item.listener === listener) === -1)
|
|
4810
|
+
events.push(item);
|
|
4811
|
+
}
|
|
4812
|
+
else {
|
|
4813
|
+
map[type] = [item];
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
});
|
|
4817
|
+
}
|
|
4818
|
+
off(type, listener, options) {
|
|
4819
|
+
if (type) {
|
|
4820
|
+
const typeList = typeof type === 'string' ? type.split(' ') : type;
|
|
4821
|
+
if (listener) {
|
|
4822
|
+
let capture;
|
|
4823
|
+
if (options)
|
|
4824
|
+
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4825
|
+
let events, index;
|
|
4826
|
+
const map = __getListenerMap(this, capture);
|
|
4827
|
+
typeList.forEach(type => {
|
|
4828
|
+
if (type) {
|
|
4829
|
+
events = map[type];
|
|
4830
|
+
if (events) {
|
|
4831
|
+
index = events.findIndex(item => item.listener === listener);
|
|
4832
|
+
if (index > -1)
|
|
4833
|
+
events.splice(index, 1);
|
|
4834
|
+
if (!events.length)
|
|
4835
|
+
delete map[type];
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
});
|
|
4839
|
+
}
|
|
4840
|
+
else {
|
|
4841
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4842
|
+
typeList.forEach(type => {
|
|
4843
|
+
if (b)
|
|
4844
|
+
delete b[type];
|
|
4845
|
+
if (c)
|
|
4846
|
+
delete c[type];
|
|
4847
|
+
});
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
else {
|
|
4851
|
+
this.__bubbleMap = this.__captureMap = undefined;
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4854
|
+
on_(type, listener, bind, options) {
|
|
4855
|
+
if (bind)
|
|
4856
|
+
listener = listener.bind(bind);
|
|
4857
|
+
this.on(type, listener, options);
|
|
4858
|
+
return { type, current: this, listener, options };
|
|
4859
|
+
}
|
|
4860
|
+
off_(id) {
|
|
4861
|
+
if (!id)
|
|
4862
|
+
return;
|
|
4863
|
+
const list = id instanceof Array ? id : [id];
|
|
4864
|
+
list.forEach(item => item.current.off(item.type, item.listener, item.options));
|
|
4865
|
+
list.length = 0;
|
|
4866
|
+
}
|
|
4867
|
+
once(type, listener, capture) {
|
|
4868
|
+
this.on(type, listener, { once: true, capture });
|
|
4869
|
+
}
|
|
4870
|
+
emit(type, event, capture) {
|
|
4871
|
+
if (!event && EventCreator.has(type))
|
|
4872
|
+
event = EventCreator.get(type, { type, target: this, current: this });
|
|
4873
|
+
const map = __getListenerMap(this, capture);
|
|
4874
|
+
const list = map[type];
|
|
4875
|
+
if (list) {
|
|
4876
|
+
let item;
|
|
4877
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
4878
|
+
item = list[i];
|
|
4879
|
+
item.listener(event);
|
|
4880
|
+
if (item.once) {
|
|
4881
|
+
this.off(type, item.listener, capture);
|
|
4882
|
+
i--, len--;
|
|
4883
|
+
}
|
|
4884
|
+
if (event && event.isStopNow)
|
|
4885
|
+
break;
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
this.syncEventer && this.syncEventer.emitEvent(event, capture);
|
|
4889
|
+
}
|
|
4890
|
+
emitEvent(event, capture) {
|
|
4891
|
+
event.current = this;
|
|
4892
|
+
this.emit(event.type, event, capture);
|
|
4893
|
+
}
|
|
4894
|
+
hasEvent(type, capture) {
|
|
4895
|
+
if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
|
|
4896
|
+
return true;
|
|
4897
|
+
const { __bubbleMap: b, __captureMap: c } = this;
|
|
4898
|
+
const hasB = b && b[type], hasC = c && c[type];
|
|
4899
|
+
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
|
|
4900
|
+
}
|
|
4901
|
+
destroy() {
|
|
4902
|
+
this.__captureMap = this.__bubbleMap = this.syncEventer = null;
|
|
4903
|
+
}
|
|
4904
|
+
}
|
|
4905
|
+
function __getListenerMap(eventer, capture, create) {
|
|
4906
|
+
if (capture) {
|
|
4907
|
+
const { __captureMap: c } = eventer;
|
|
4908
|
+
if (c) {
|
|
4909
|
+
return c;
|
|
4910
|
+
}
|
|
4911
|
+
else {
|
|
4912
|
+
return create ? eventer.__captureMap = {} : empty;
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
else {
|
|
4916
|
+
const { __bubbleMap: b } = eventer;
|
|
4917
|
+
if (b) {
|
|
4918
|
+
return b;
|
|
4919
|
+
}
|
|
4920
|
+
else {
|
|
4921
|
+
return create ? eventer.__bubbleMap = {} : empty;
|
|
4922
|
+
}
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
|
|
4926
|
+
const { on, on_, off, off_, once, emit, emitEvent, hasEvent, destroy } = Eventer.prototype;
|
|
4927
|
+
const LeafEventer = { on, on_, off, off_, once, emit, emitEvent, hasEvent, destroyEventer: destroy };
|
|
4928
|
+
|
|
4885
4929
|
const { isFinite } = Number;
|
|
4886
4930
|
const debug = Debug.get('setAttr');
|
|
4887
4931
|
const LeafDataProxy = {
|
|
@@ -4893,9 +4937,7 @@ const LeafDataProxy = {
|
|
|
4893
4937
|
newValue = undefined;
|
|
4894
4938
|
}
|
|
4895
4939
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
4896
|
-
this.
|
|
4897
|
-
if (this.__proxyData)
|
|
4898
|
-
this.setProxyAttr(name, newValue);
|
|
4940
|
+
this.__realSetAttr(name, newValue);
|
|
4899
4941
|
const { CHANGE } = PropertyEvent;
|
|
4900
4942
|
const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
|
|
4901
4943
|
if (this.isLeafer) {
|
|
@@ -4913,12 +4955,18 @@ const LeafDataProxy = {
|
|
|
4913
4955
|
}
|
|
4914
4956
|
}
|
|
4915
4957
|
else {
|
|
4916
|
-
this.
|
|
4917
|
-
if (this.__proxyData)
|
|
4918
|
-
this.setProxyAttr(name, newValue);
|
|
4958
|
+
this.__realSetAttr(name, newValue);
|
|
4919
4959
|
return true;
|
|
4920
4960
|
}
|
|
4921
4961
|
},
|
|
4962
|
+
__realSetAttr(name, newValue) {
|
|
4963
|
+
const data = this.__;
|
|
4964
|
+
data[name] = newValue;
|
|
4965
|
+
if (this.__proxyData)
|
|
4966
|
+
this.setProxyAttr(name, newValue);
|
|
4967
|
+
if (data.normalStyle)
|
|
4968
|
+
this.lockNormalStyle || data.normalStyle[name] === undefined || (data.normalStyle[name] = newValue);
|
|
4969
|
+
},
|
|
4922
4970
|
__getAttr(name) {
|
|
4923
4971
|
if (this.__proxyData)
|
|
4924
4972
|
return this.getProxyAttr(name);
|
|
@@ -5021,6 +5069,8 @@ const LeafBounds = {
|
|
|
5021
5069
|
layout.boundsChanged = false;
|
|
5022
5070
|
},
|
|
5023
5071
|
__updateLocalBoxBounds() {
|
|
5072
|
+
if (this.__hasMotionPath)
|
|
5073
|
+
this.__updateMotionPath();
|
|
5024
5074
|
if (this.__hasAutoLayout)
|
|
5025
5075
|
this.__updateAutoLayout();
|
|
5026
5076
|
toOuterOf$1(this.__layout.boxBounds, this.__local, this.__local);
|
|
@@ -5173,7 +5223,7 @@ const BranchRender = {
|
|
|
5173
5223
|
const { LEAF, create } = IncrementId;
|
|
5174
5224
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5175
5225
|
const { toOuterOf } = BoundsHelper;
|
|
5176
|
-
const { copy } = PointHelper;
|
|
5226
|
+
const { copy, move } = PointHelper;
|
|
5177
5227
|
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5178
5228
|
exports.Leaf = class Leaf {
|
|
5179
5229
|
get tag() { return this.__tag; }
|
|
@@ -5200,13 +5250,16 @@ exports.Leaf = class Leaf {
|
|
|
5200
5250
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5201
5251
|
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5202
5252
|
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); }
|
|
5253
|
+
set event(map) { this.on(map); }
|
|
5205
5254
|
constructor(data) {
|
|
5206
5255
|
this.innerId = create(LEAF);
|
|
5207
5256
|
this.reset(data);
|
|
5257
|
+
if (this.__bubbleMap)
|
|
5258
|
+
this.__emitLifeEvent(ChildEvent.CREATED);
|
|
5208
5259
|
}
|
|
5209
5260
|
reset(data) {
|
|
5261
|
+
if (this.leafer)
|
|
5262
|
+
this.leafer.forceRender(this.__world);
|
|
5210
5263
|
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
5264
|
if (data !== null)
|
|
5212
5265
|
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -5228,12 +5281,12 @@ exports.Leaf = class Leaf {
|
|
|
5228
5281
|
waitParent(item, bind) {
|
|
5229
5282
|
if (bind)
|
|
5230
5283
|
item = item.bind(bind);
|
|
5231
|
-
this.parent ? item() :
|
|
5284
|
+
this.parent ? item() : this.on(ChildEvent.ADD, item, 'once');
|
|
5232
5285
|
}
|
|
5233
5286
|
waitLeafer(item, bind) {
|
|
5234
5287
|
if (bind)
|
|
5235
5288
|
item = item.bind(bind);
|
|
5236
|
-
this.leafer ? item() :
|
|
5289
|
+
this.leafer ? item() : this.on(ChildEvent.MOUNTED, item, 'once');
|
|
5237
5290
|
}
|
|
5238
5291
|
nextRender(item, bind, off) {
|
|
5239
5292
|
this.leafer ? this.leafer.nextRender(item, bind, off) : this.waitLeafer(() => this.leafer.nextRender(item, bind, off));
|
|
@@ -5242,18 +5295,21 @@ exports.Leaf = class Leaf {
|
|
|
5242
5295
|
this.nextRender(item, null, 'off');
|
|
5243
5296
|
}
|
|
5244
5297
|
__bindLeafer(leafer) {
|
|
5245
|
-
if (this.isLeafer)
|
|
5246
|
-
|
|
5247
|
-
leafer = this;
|
|
5248
|
-
}
|
|
5298
|
+
if (this.isLeafer && leafer !== null)
|
|
5299
|
+
leafer = this;
|
|
5249
5300
|
if (this.leafer && !leafer)
|
|
5250
5301
|
this.leafer.leafs--;
|
|
5251
5302
|
this.leafer = leafer;
|
|
5252
5303
|
if (leafer) {
|
|
5253
5304
|
leafer.leafs++;
|
|
5254
5305
|
this.__level = this.parent ? this.parent.__level + 1 : 1;
|
|
5255
|
-
if (this.
|
|
5256
|
-
|
|
5306
|
+
if (this.animation)
|
|
5307
|
+
this.__runAnimation('in');
|
|
5308
|
+
if (this.__bubbleMap)
|
|
5309
|
+
this.__emitLifeEvent(ChildEvent.MOUNTED);
|
|
5310
|
+
}
|
|
5311
|
+
else {
|
|
5312
|
+
this.__emitLifeEvent(ChildEvent.UNMOUNTED);
|
|
5257
5313
|
}
|
|
5258
5314
|
if (this.isBranch) {
|
|
5259
5315
|
const { children } = this;
|
|
@@ -5262,7 +5318,7 @@ exports.Leaf = class Leaf {
|
|
|
5262
5318
|
}
|
|
5263
5319
|
}
|
|
5264
5320
|
}
|
|
5265
|
-
set(_data) { }
|
|
5321
|
+
set(_data, _isTemp) { }
|
|
5266
5322
|
get(_name) { return undefined; }
|
|
5267
5323
|
setAttr(name, value) { this[name] = value; }
|
|
5268
5324
|
getAttr(name) { return this[name]; }
|
|
@@ -5287,6 +5343,7 @@ exports.Leaf = class Leaf {
|
|
|
5287
5343
|
findOne(_condition, _options) { return undefined; }
|
|
5288
5344
|
findId(_id) { return undefined; }
|
|
5289
5345
|
focus(_value) { }
|
|
5346
|
+
updateState() { }
|
|
5290
5347
|
updateLayout() {
|
|
5291
5348
|
this.__layout.update();
|
|
5292
5349
|
}
|
|
@@ -5394,11 +5451,24 @@ exports.Leaf = class Leaf {
|
|
|
5394
5451
|
if (relative)
|
|
5395
5452
|
relative.worldToInner(to ? to : inner, null, distance);
|
|
5396
5453
|
}
|
|
5454
|
+
getBoxPoint(world, relative, distance, change) {
|
|
5455
|
+
return this.getBoxPointByInner(this.getInnerPoint(world, relative, distance, change), null, null, true);
|
|
5456
|
+
}
|
|
5457
|
+
getBoxPointByInner(inner, _relative, _distance, change) {
|
|
5458
|
+
const point = change ? inner : Object.assign({}, inner), { x, y } = this.boxBounds;
|
|
5459
|
+
move(point, -x, -y);
|
|
5460
|
+
return point;
|
|
5461
|
+
}
|
|
5397
5462
|
getInnerPoint(world, relative, distance, change) {
|
|
5398
5463
|
const point = change ? world : {};
|
|
5399
5464
|
this.worldToInner(world, point, distance, relative);
|
|
5400
5465
|
return point;
|
|
5401
5466
|
}
|
|
5467
|
+
getInnerPointByBox(box, _relative, _distance, change) {
|
|
5468
|
+
const point = change ? box : Object.assign({}, box), { x, y } = this.boxBounds;
|
|
5469
|
+
move(point, x, y);
|
|
5470
|
+
return point;
|
|
5471
|
+
}
|
|
5402
5472
|
getInnerPointByLocal(local, _relative, distance, change) {
|
|
5403
5473
|
return this.getInnerPoint(local, this.parent, distance, change);
|
|
5404
5474
|
}
|
|
@@ -5410,20 +5480,23 @@ exports.Leaf = class Leaf {
|
|
|
5410
5480
|
getLocalPointByInner(inner, _relative, distance, change) {
|
|
5411
5481
|
return this.getWorldPoint(inner, this.parent, distance, change);
|
|
5412
5482
|
}
|
|
5483
|
+
getPagePoint(world, relative, distance, change) {
|
|
5484
|
+
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5485
|
+
return layer.getInnerPoint(world, relative, distance, change);
|
|
5486
|
+
}
|
|
5413
5487
|
getWorldPoint(inner, relative, distance, change) {
|
|
5414
5488
|
const point = change ? inner : {};
|
|
5415
5489
|
this.innerToWorld(inner, point, distance, relative);
|
|
5416
5490
|
return point;
|
|
5417
5491
|
}
|
|
5492
|
+
getWorldPointByBox(box, relative, distance, change) {
|
|
5493
|
+
return this.getWorldPoint(this.getInnerPointByBox(box, null, null, change), relative, distance, true);
|
|
5494
|
+
}
|
|
5418
5495
|
getWorldPointByLocal(local, relative, distance, change) {
|
|
5419
5496
|
const point = change ? local : {};
|
|
5420
5497
|
this.localToWorld(local, point, distance, relative);
|
|
5421
5498
|
return point;
|
|
5422
5499
|
}
|
|
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
5500
|
getWorldPointByPage(page, relative, distance, change) {
|
|
5428
5501
|
const layer = this.leafer ? this.leafer.zoomLayer : this;
|
|
5429
5502
|
return layer.getWorldPoint(page, relative, distance, change);
|
|
@@ -5492,6 +5565,17 @@ exports.Leaf = class Leaf {
|
|
|
5492
5565
|
__drawRenderPath(_canvas) { }
|
|
5493
5566
|
__updatePath() { }
|
|
5494
5567
|
__updateRenderPath() { }
|
|
5568
|
+
getMotionPathData() {
|
|
5569
|
+
return needPlugin('path');
|
|
5570
|
+
}
|
|
5571
|
+
getMotionPoint(_motionDistance) {
|
|
5572
|
+
return needPlugin('path');
|
|
5573
|
+
}
|
|
5574
|
+
getMotionTotal() {
|
|
5575
|
+
return 0;
|
|
5576
|
+
}
|
|
5577
|
+
__updateMotionPath() { }
|
|
5578
|
+
__runAnimation(_type, _complete) { }
|
|
5495
5579
|
__updateSortChildren() { }
|
|
5496
5580
|
add(_child, _index) { }
|
|
5497
5581
|
remove(_child, destroy) {
|
|
@@ -5517,6 +5601,10 @@ exports.Leaf = class Leaf {
|
|
|
5517
5601
|
fn = boundsType;
|
|
5518
5602
|
fn(defaultValue)(this.prototype, attrName);
|
|
5519
5603
|
}
|
|
5604
|
+
__emitLifeEvent(type) {
|
|
5605
|
+
if (this.hasEvent(type))
|
|
5606
|
+
this.emitEvent(new ChildEvent(type, this, this.parent));
|
|
5607
|
+
}
|
|
5520
5608
|
destroy() {
|
|
5521
5609
|
if (!this.destroyed) {
|
|
5522
5610
|
const { parent } = this;
|
|
@@ -5524,11 +5612,10 @@ exports.Leaf = class Leaf {
|
|
|
5524
5612
|
this.remove();
|
|
5525
5613
|
if (this.children)
|
|
5526
5614
|
this.removeAll(true);
|
|
5527
|
-
|
|
5528
|
-
this.emitEvent(new ChildEvent(ChildEvent.DESTROY, this, parent));
|
|
5615
|
+
this.__emitLifeEvent(ChildEvent.DESTROY);
|
|
5529
5616
|
this.__.destroy();
|
|
5530
5617
|
this.__layout.destroy();
|
|
5531
|
-
this.
|
|
5618
|
+
this.destroyEventer();
|
|
5532
5619
|
this.destroyed = true;
|
|
5533
5620
|
}
|
|
5534
5621
|
}
|
|
@@ -5594,8 +5681,8 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5594
5681
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5595
5682
|
child.__layout.boxChanged || child.__layout.boxChange();
|
|
5596
5683
|
child.__layout.matrixChanged || child.__layout.matrixChange();
|
|
5597
|
-
if (child.
|
|
5598
|
-
|
|
5684
|
+
if (child.__bubbleMap)
|
|
5685
|
+
child.__emitLifeEvent(ChildEvent.ADD);
|
|
5599
5686
|
if (this.leafer) {
|
|
5600
5687
|
child.__bindLeafer(this.leafer);
|
|
5601
5688
|
if (this.leafer.created)
|
|
@@ -5608,16 +5695,10 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5608
5695
|
}
|
|
5609
5696
|
remove(child, destroy) {
|
|
5610
5697
|
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
|
-
}
|
|
5698
|
+
if (child.animationOut)
|
|
5699
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5700
|
+
else
|
|
5701
|
+
this.__remove(child, destroy);
|
|
5621
5702
|
}
|
|
5622
5703
|
else if (child === undefined) {
|
|
5623
5704
|
super.remove(null, destroy);
|
|
@@ -5639,6 +5720,18 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5639
5720
|
clear() {
|
|
5640
5721
|
this.removeAll(true);
|
|
5641
5722
|
}
|
|
5723
|
+
__remove(child, destroy) {
|
|
5724
|
+
const index = this.children.indexOf(child);
|
|
5725
|
+
if (index > -1) {
|
|
5726
|
+
this.children.splice(index, 1);
|
|
5727
|
+
if (child.isBranch)
|
|
5728
|
+
this.__.__childBranchNumber = (this.__.__childBranchNumber || 1) - 1;
|
|
5729
|
+
this.__preRemove();
|
|
5730
|
+
this.__realRemoveChild(child);
|
|
5731
|
+
if (destroy)
|
|
5732
|
+
child.destroy();
|
|
5733
|
+
}
|
|
5734
|
+
}
|
|
5642
5735
|
__preRemove() {
|
|
5643
5736
|
if (this.__hasMask)
|
|
5644
5737
|
this.__updateMask();
|
|
@@ -5648,6 +5741,7 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5648
5741
|
this.__layout.affectChildrenSort && this.__layout.childrenSortChange();
|
|
5649
5742
|
}
|
|
5650
5743
|
__realRemoveChild(child) {
|
|
5744
|
+
child.__emitLifeEvent(ChildEvent.REMOVE);
|
|
5651
5745
|
child.parent = null;
|
|
5652
5746
|
if (this.leafer) {
|
|
5653
5747
|
child.__bindLeafer(null);
|
|
@@ -5660,8 +5754,6 @@ exports.Branch = class Branch extends exports.Leaf {
|
|
|
5660
5754
|
}
|
|
5661
5755
|
__emitChildEvent(type, child) {
|
|
5662
5756
|
const event = new ChildEvent(type, child, this);
|
|
5663
|
-
if (child.hasEvent(type))
|
|
5664
|
-
child.emitEvent(event);
|
|
5665
5757
|
if (this.hasEvent(type) && !this.isLeafer)
|
|
5666
5758
|
this.emitEvent(event);
|
|
5667
5759
|
this.leafer.emitEvent(event);
|
|
@@ -5824,11 +5916,9 @@ class LeafLevelList {
|
|
|
5824
5916
|
}
|
|
5825
5917
|
}
|
|
5826
5918
|
|
|
5827
|
-
const version = "1.0.
|
|
5828
|
-
const inviteCode = {};
|
|
5919
|
+
const version = "1.0.3";
|
|
5829
5920
|
|
|
5830
5921
|
exports.AlignHelper = AlignHelper;
|
|
5831
|
-
exports.AnimateEvent = AnimateEvent;
|
|
5832
5922
|
exports.AroundHelper = AroundHelper;
|
|
5833
5923
|
exports.AutoBounds = AutoBounds;
|
|
5834
5924
|
exports.BezierHelper = BezierHelper;
|
|
@@ -5844,6 +5934,7 @@ exports.Debug = Debug;
|
|
|
5844
5934
|
exports.EllipseHelper = EllipseHelper;
|
|
5845
5935
|
exports.Event = Event;
|
|
5846
5936
|
exports.EventCreator = EventCreator;
|
|
5937
|
+
exports.Eventer = Eventer;
|
|
5847
5938
|
exports.FileHelper = FileHelper;
|
|
5848
5939
|
exports.ImageEvent = ImageEvent;
|
|
5849
5940
|
exports.ImageManager = ImageManager;
|
|
@@ -5918,10 +6009,11 @@ exports.getDescriptor = getDescriptor;
|
|
|
5918
6009
|
exports.getMatrixData = getMatrixData;
|
|
5919
6010
|
exports.getPointData = getPointData;
|
|
5920
6011
|
exports.hitType = hitType;
|
|
5921
|
-
exports.
|
|
6012
|
+
exports.isNull = isNull;
|
|
5922
6013
|
exports.layoutProcessor = layoutProcessor;
|
|
5923
6014
|
exports.maskType = maskType;
|
|
5924
6015
|
exports.naturalBoundsType = naturalBoundsType;
|
|
6016
|
+
exports.needPlugin = needPlugin;
|
|
5925
6017
|
exports.opacityType = opacityType;
|
|
5926
6018
|
exports.pathInputType = pathInputType;
|
|
5927
6019
|
exports.pathType = pathType;
|