leafer-ui 2.2.6 → 2.2.7
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/web.cjs +72 -48
- package/dist/web.esm.js +71 -49
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +100 -68
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +100 -70
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -11
package/dist/web.cjs
CHANGED
|
@@ -374,6 +374,7 @@ class Watcher {
|
|
|
374
374
|
}
|
|
375
375
|
constructor(target, userConfig) {
|
|
376
376
|
this.totalTimes = 0;
|
|
377
|
+
this.changed = 0;
|
|
377
378
|
this.config = {};
|
|
378
379
|
this.__updatedList = new core.LeafList;
|
|
379
380
|
this.target = target;
|
|
@@ -393,8 +394,10 @@ class Watcher {
|
|
|
393
394
|
this.disabled = true;
|
|
394
395
|
}
|
|
395
396
|
update() {
|
|
396
|
-
this.changed
|
|
397
|
-
|
|
397
|
+
if (this.changed < 100) {
|
|
398
|
+
this.changed++;
|
|
399
|
+
if (this.running) this.target.emit(core.RenderEvent.REQUEST);
|
|
400
|
+
}
|
|
398
401
|
}
|
|
399
402
|
__onAttrChange(event) {
|
|
400
403
|
this.add(event.target);
|
|
@@ -403,18 +406,21 @@ class Watcher {
|
|
|
403
406
|
if (this.config.usePartLayout) this.__updatedList.add(leaf);
|
|
404
407
|
this.update();
|
|
405
408
|
}
|
|
406
|
-
|
|
409
|
+
addChild(child, parent, eventType) {
|
|
407
410
|
if (this.config.usePartLayout) {
|
|
408
|
-
if (
|
|
411
|
+
if (eventType === core.ChildEvent.ADD) {
|
|
409
412
|
this.hasAdd = true;
|
|
410
|
-
this.__pushChild(
|
|
413
|
+
this.__pushChild(child);
|
|
411
414
|
} else {
|
|
412
415
|
this.hasRemove = true;
|
|
413
|
-
this.__updatedList.add(
|
|
416
|
+
this.__updatedList.add(parent);
|
|
414
417
|
}
|
|
415
418
|
}
|
|
416
419
|
this.update();
|
|
417
420
|
}
|
|
421
|
+
__onChildEvent(event) {
|
|
422
|
+
this.addChild(event.child, event.parent, event.type);
|
|
423
|
+
}
|
|
418
424
|
__pushChild(child) {
|
|
419
425
|
this.__updatedList.add(child);
|
|
420
426
|
if (child.isBranch) this.__loopChildren(child);
|
|
@@ -429,7 +435,8 @@ class Watcher {
|
|
|
429
435
|
}));
|
|
430
436
|
this.__updatedList = new core.LeafList;
|
|
431
437
|
this.totalTimes++;
|
|
432
|
-
this.
|
|
438
|
+
this.hasVisible = this.hasRemove = this.hasAdd = false;
|
|
439
|
+
this.changed = 0;
|
|
433
440
|
}
|
|
434
441
|
__listenEvents() {
|
|
435
442
|
this.__eventIds = [ this.target.on_([ [ core.PropertyEvent.CHANGE, this.__onAttrChange, this ], [ [ core.ChildEvent.ADD, core.ChildEvent.REMOVE ], this.__onChildEvent, this ], [ core.WatchEvent.REQUEST, this.__onRquestData, this ] ]) ];
|
|
@@ -450,47 +457,57 @@ const {updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, update
|
|
|
450
457
|
|
|
451
458
|
const {pushAllChildBranch: pushAllChildBranch, pushAllParent: pushAllParent} = core.BranchHelper;
|
|
452
459
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if (
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
if (
|
|
466
|
-
|
|
460
|
+
const LayouterHelper = {
|
|
461
|
+
updateMatrix(updateList, levelList) {
|
|
462
|
+
let index = 0, leaf, layout;
|
|
463
|
+
const {list: list} = updateList;
|
|
464
|
+
while (index < list.length) {
|
|
465
|
+
leaf = list[index];
|
|
466
|
+
layout = leaf.__layout;
|
|
467
|
+
if (levelList.without(leaf) && !layout.proxyZoom) {
|
|
468
|
+
if (layout.matrixChanged) {
|
|
469
|
+
updateAllMatrix$1(leaf, true);
|
|
470
|
+
if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
|
|
471
|
+
push(leaf, levelList);
|
|
472
|
+
} else if (layout.boundsChanged) {
|
|
473
|
+
if (leaf.isBranch) leaf.__tempNumber = 0;
|
|
474
|
+
push(leaf, levelList);
|
|
475
|
+
}
|
|
467
476
|
}
|
|
477
|
+
index++;
|
|
468
478
|
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
479
|
+
},
|
|
480
|
+
updateBounds(boundsList) {
|
|
481
|
+
let index = 0, level, list, branch, children;
|
|
482
|
+
const {levels: levels, levelMap: levelMap} = boundsList;
|
|
483
|
+
boundsList.sort(true);
|
|
484
|
+
while (index < levels.length) {
|
|
485
|
+
level = levels[index];
|
|
486
|
+
list = levelMap[level];
|
|
487
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
488
|
+
branch = list[i];
|
|
489
|
+
if (branch.isBranch && branch.__tempNumber) {
|
|
490
|
+
children = branch.children;
|
|
491
|
+
for (let j = 0, jLen = children.length; j < jLen; j++) {
|
|
492
|
+
if (!children[j].isBranch) {
|
|
493
|
+
updateOneBounds(children[j]);
|
|
494
|
+
}
|
|
484
495
|
}
|
|
485
496
|
}
|
|
497
|
+
updateOneBounds(branch);
|
|
486
498
|
}
|
|
487
|
-
|
|
499
|
+
index++;
|
|
488
500
|
}
|
|
489
|
-
}
|
|
490
|
-
|
|
501
|
+
},
|
|
502
|
+
updateChange(updateList) {
|
|
503
|
+
updateList.list.forEach(updateOneChange);
|
|
504
|
+
},
|
|
505
|
+
push: push
|
|
506
|
+
};
|
|
491
507
|
|
|
492
|
-
function
|
|
493
|
-
|
|
508
|
+
function push(leaf, levelList) {
|
|
509
|
+
levelList.add(leaf);
|
|
510
|
+
pushAllParent(leaf, levelList);
|
|
494
511
|
}
|
|
495
512
|
|
|
496
513
|
const {worldBounds: worldBounds} = core.LeafBoundsHelper;
|
|
@@ -597,9 +614,9 @@ class Layouter {
|
|
|
597
614
|
target.emitEvent(new core.LayoutEvent(BEFORE, blocks, this.times));
|
|
598
615
|
this.extraBlock = null;
|
|
599
616
|
updateList.sort();
|
|
600
|
-
updateMatrix(updateList, this.__levelList);
|
|
601
|
-
updateBounds(this.__levelList);
|
|
602
|
-
updateChange(updateList);
|
|
617
|
+
LayouterHelper.updateMatrix(updateList, this.__levelList);
|
|
618
|
+
LayouterHelper.updateBounds(this.__levelList);
|
|
619
|
+
LayouterHelper.updateChange(updateList);
|
|
603
620
|
if (this.extraBlock) blocks.push(this.extraBlock);
|
|
604
621
|
blocks.forEach(item => item.setAfter());
|
|
605
622
|
target.emitEvent(new core.LayoutEvent(LAYOUT, blocks, this.times));
|
|
@@ -629,11 +646,16 @@ class Layouter {
|
|
|
629
646
|
if (target.isBranch) core.BranchHelper.updateBounds(target); else core.LeafHelper.updateBounds(target);
|
|
630
647
|
updateAllChange(target);
|
|
631
648
|
}
|
|
632
|
-
addExtra(leaf) {
|
|
649
|
+
addExtra(leaf, updateBounds) {
|
|
633
650
|
if (!this.__updatedList.has(leaf)) {
|
|
634
651
|
const {updatedList: updatedList, beforeBounds: beforeBounds} = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
|
|
635
652
|
updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
|
|
636
653
|
updatedList.add(leaf);
|
|
654
|
+
if (updateBounds) {
|
|
655
|
+
const list = this.__levelList;
|
|
656
|
+
LayouterHelper.push(leaf, list);
|
|
657
|
+
list.sort(true);
|
|
658
|
+
}
|
|
637
659
|
}
|
|
638
660
|
}
|
|
639
661
|
createBlock(data) {
|
|
@@ -958,7 +980,7 @@ class Picker {
|
|
|
958
980
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
959
981
|
find = list[i];
|
|
960
982
|
if (ignoreHittable || core.LeafHelper.worldHittable(find)) {
|
|
961
|
-
this.hitChild(find, find.hitThrough ? this.point : point);
|
|
983
|
+
this.hitChild(find, find.hitThrough ? this.point : point, find.mask && find.parent && find.parent.__onlyHitMask);
|
|
962
984
|
if (findList.length) {
|
|
963
985
|
if (find.isBranchLeaf && list.some(item => item !== find && core.LeafHelper.hasParent(item, find))) {
|
|
964
986
|
findList.reset();
|
|
@@ -1057,7 +1079,7 @@ class Picker {
|
|
|
1057
1079
|
}
|
|
1058
1080
|
const leaf = proxy || child, {hitThrough: hitThrough} = child, {findList: findList} = this;
|
|
1059
1081
|
if (hitThrough) {
|
|
1060
|
-
const index = findList.list.findIndex(item => item[hitThrough] === child[hitThrough]);
|
|
1082
|
+
const index = findList.list.findIndex(item => hitThrough === "parent" ? core.LeafHelper.hasParent(item.parent, child.parent) : item[hitThrough] === child[hitThrough]);
|
|
1061
1083
|
if (index > 0) return findList.addAt(leaf, index);
|
|
1062
1084
|
}
|
|
1063
1085
|
findList.add(leaf);
|
|
@@ -1892,7 +1914,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
1892
1914
|
data.__naturalHeight = image.height / data.pixelRatio;
|
|
1893
1915
|
if (data.__autoSide) {
|
|
1894
1916
|
ui.forceUpdate();
|
|
1895
|
-
core.LeafHelper.updateBounds(ui);
|
|
1917
|
+
core.LeafHelper.updateBounds(ui, true);
|
|
1896
1918
|
ui.__layout.boundsChanged = true;
|
|
1897
1919
|
if (ui.__proxyData) {
|
|
1898
1920
|
ui.setProxyAttr("width", data.width);
|
|
@@ -3196,6 +3218,8 @@ exports.Interaction = Interaction;
|
|
|
3196
3218
|
|
|
3197
3219
|
exports.Layouter = Layouter;
|
|
3198
3220
|
|
|
3221
|
+
exports.LayouterHelper = LayouterHelper;
|
|
3222
|
+
|
|
3199
3223
|
exports.LeaferCanvas = LeaferCanvas;
|
|
3200
3224
|
|
|
3201
3225
|
exports.Picker = Picker;
|
package/dist/web.esm.js
CHANGED
|
@@ -378,6 +378,7 @@ class Watcher {
|
|
|
378
378
|
}
|
|
379
379
|
constructor(target, userConfig) {
|
|
380
380
|
this.totalTimes = 0;
|
|
381
|
+
this.changed = 0;
|
|
381
382
|
this.config = {};
|
|
382
383
|
this.__updatedList = new LeafList;
|
|
383
384
|
this.target = target;
|
|
@@ -397,8 +398,10 @@ class Watcher {
|
|
|
397
398
|
this.disabled = true;
|
|
398
399
|
}
|
|
399
400
|
update() {
|
|
400
|
-
this.changed
|
|
401
|
-
|
|
401
|
+
if (this.changed < 100) {
|
|
402
|
+
this.changed++;
|
|
403
|
+
if (this.running) this.target.emit(RenderEvent.REQUEST);
|
|
404
|
+
}
|
|
402
405
|
}
|
|
403
406
|
__onAttrChange(event) {
|
|
404
407
|
this.add(event.target);
|
|
@@ -407,18 +410,21 @@ class Watcher {
|
|
|
407
410
|
if (this.config.usePartLayout) this.__updatedList.add(leaf);
|
|
408
411
|
this.update();
|
|
409
412
|
}
|
|
410
|
-
|
|
413
|
+
addChild(child, parent, eventType) {
|
|
411
414
|
if (this.config.usePartLayout) {
|
|
412
|
-
if (
|
|
415
|
+
if (eventType === ChildEvent.ADD) {
|
|
413
416
|
this.hasAdd = true;
|
|
414
|
-
this.__pushChild(
|
|
417
|
+
this.__pushChild(child);
|
|
415
418
|
} else {
|
|
416
419
|
this.hasRemove = true;
|
|
417
|
-
this.__updatedList.add(
|
|
420
|
+
this.__updatedList.add(parent);
|
|
418
421
|
}
|
|
419
422
|
}
|
|
420
423
|
this.update();
|
|
421
424
|
}
|
|
425
|
+
__onChildEvent(event) {
|
|
426
|
+
this.addChild(event.child, event.parent, event.type);
|
|
427
|
+
}
|
|
422
428
|
__pushChild(child) {
|
|
423
429
|
this.__updatedList.add(child);
|
|
424
430
|
if (child.isBranch) this.__loopChildren(child);
|
|
@@ -433,7 +439,8 @@ class Watcher {
|
|
|
433
439
|
}));
|
|
434
440
|
this.__updatedList = new LeafList;
|
|
435
441
|
this.totalTimes++;
|
|
436
|
-
this.
|
|
442
|
+
this.hasVisible = this.hasRemove = this.hasAdd = false;
|
|
443
|
+
this.changed = 0;
|
|
437
444
|
}
|
|
438
445
|
__listenEvents() {
|
|
439
446
|
this.__eventIds = [ this.target.on_([ [ PropertyEvent.CHANGE, this.__onAttrChange, this ], [ [ ChildEvent.ADD, ChildEvent.REMOVE ], this.__onChildEvent, this ], [ WatchEvent.REQUEST, this.__onRquestData, this ] ]) ];
|
|
@@ -454,47 +461,57 @@ const {updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, update
|
|
|
454
461
|
|
|
455
462
|
const {pushAllChildBranch: pushAllChildBranch, pushAllParent: pushAllParent} = BranchHelper;
|
|
456
463
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
if (
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (
|
|
470
|
-
|
|
464
|
+
const LayouterHelper = {
|
|
465
|
+
updateMatrix(updateList, levelList) {
|
|
466
|
+
let index = 0, leaf, layout;
|
|
467
|
+
const {list: list} = updateList;
|
|
468
|
+
while (index < list.length) {
|
|
469
|
+
leaf = list[index];
|
|
470
|
+
layout = leaf.__layout;
|
|
471
|
+
if (levelList.without(leaf) && !layout.proxyZoom) {
|
|
472
|
+
if (layout.matrixChanged) {
|
|
473
|
+
updateAllMatrix$1(leaf, true);
|
|
474
|
+
if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
|
|
475
|
+
push(leaf, levelList);
|
|
476
|
+
} else if (layout.boundsChanged) {
|
|
477
|
+
if (leaf.isBranch) leaf.__tempNumber = 0;
|
|
478
|
+
push(leaf, levelList);
|
|
479
|
+
}
|
|
471
480
|
}
|
|
481
|
+
index++;
|
|
472
482
|
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
483
|
+
},
|
|
484
|
+
updateBounds(boundsList) {
|
|
485
|
+
let index = 0, level, list, branch, children;
|
|
486
|
+
const {levels: levels, levelMap: levelMap} = boundsList;
|
|
487
|
+
boundsList.sort(true);
|
|
488
|
+
while (index < levels.length) {
|
|
489
|
+
level = levels[index];
|
|
490
|
+
list = levelMap[level];
|
|
491
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
492
|
+
branch = list[i];
|
|
493
|
+
if (branch.isBranch && branch.__tempNumber) {
|
|
494
|
+
children = branch.children;
|
|
495
|
+
for (let j = 0, jLen = children.length; j < jLen; j++) {
|
|
496
|
+
if (!children[j].isBranch) {
|
|
497
|
+
updateOneBounds(children[j]);
|
|
498
|
+
}
|
|
488
499
|
}
|
|
489
500
|
}
|
|
501
|
+
updateOneBounds(branch);
|
|
490
502
|
}
|
|
491
|
-
|
|
503
|
+
index++;
|
|
492
504
|
}
|
|
493
|
-
}
|
|
494
|
-
|
|
505
|
+
},
|
|
506
|
+
updateChange(updateList) {
|
|
507
|
+
updateList.list.forEach(updateOneChange);
|
|
508
|
+
},
|
|
509
|
+
push: push
|
|
510
|
+
};
|
|
495
511
|
|
|
496
|
-
function
|
|
497
|
-
|
|
512
|
+
function push(leaf, levelList) {
|
|
513
|
+
levelList.add(leaf);
|
|
514
|
+
pushAllParent(leaf, levelList);
|
|
498
515
|
}
|
|
499
516
|
|
|
500
517
|
const {worldBounds: worldBounds} = LeafBoundsHelper;
|
|
@@ -601,9 +618,9 @@ class Layouter {
|
|
|
601
618
|
target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
|
|
602
619
|
this.extraBlock = null;
|
|
603
620
|
updateList.sort();
|
|
604
|
-
updateMatrix(updateList, this.__levelList);
|
|
605
|
-
updateBounds(this.__levelList);
|
|
606
|
-
updateChange(updateList);
|
|
621
|
+
LayouterHelper.updateMatrix(updateList, this.__levelList);
|
|
622
|
+
LayouterHelper.updateBounds(this.__levelList);
|
|
623
|
+
LayouterHelper.updateChange(updateList);
|
|
607
624
|
if (this.extraBlock) blocks.push(this.extraBlock);
|
|
608
625
|
blocks.forEach(item => item.setAfter());
|
|
609
626
|
target.emitEvent(new LayoutEvent(LAYOUT, blocks, this.times));
|
|
@@ -633,11 +650,16 @@ class Layouter {
|
|
|
633
650
|
if (target.isBranch) BranchHelper.updateBounds(target); else LeafHelper.updateBounds(target);
|
|
634
651
|
updateAllChange(target);
|
|
635
652
|
}
|
|
636
|
-
addExtra(leaf) {
|
|
653
|
+
addExtra(leaf, updateBounds) {
|
|
637
654
|
if (!this.__updatedList.has(leaf)) {
|
|
638
655
|
const {updatedList: updatedList, beforeBounds: beforeBounds} = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
|
|
639
656
|
updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
|
|
640
657
|
updatedList.add(leaf);
|
|
658
|
+
if (updateBounds) {
|
|
659
|
+
const list = this.__levelList;
|
|
660
|
+
LayouterHelper.push(leaf, list);
|
|
661
|
+
list.sort(true);
|
|
662
|
+
}
|
|
641
663
|
}
|
|
642
664
|
}
|
|
643
665
|
createBlock(data) {
|
|
@@ -962,7 +984,7 @@ class Picker {
|
|
|
962
984
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
963
985
|
find = list[i];
|
|
964
986
|
if (ignoreHittable || LeafHelper.worldHittable(find)) {
|
|
965
|
-
this.hitChild(find, find.hitThrough ? this.point : point);
|
|
987
|
+
this.hitChild(find, find.hitThrough ? this.point : point, find.mask && find.parent && find.parent.__onlyHitMask);
|
|
966
988
|
if (findList.length) {
|
|
967
989
|
if (find.isBranchLeaf && list.some(item => item !== find && LeafHelper.hasParent(item, find))) {
|
|
968
990
|
findList.reset();
|
|
@@ -1061,7 +1083,7 @@ class Picker {
|
|
|
1061
1083
|
}
|
|
1062
1084
|
const leaf = proxy || child, {hitThrough: hitThrough} = child, {findList: findList} = this;
|
|
1063
1085
|
if (hitThrough) {
|
|
1064
|
-
const index = findList.list.findIndex(item => item[hitThrough] === child[hitThrough]);
|
|
1086
|
+
const index = findList.list.findIndex(item => hitThrough === "parent" ? LeafHelper.hasParent(item.parent, child.parent) : item[hitThrough] === child[hitThrough]);
|
|
1065
1087
|
if (index > 0) return findList.addAt(leaf, index);
|
|
1066
1088
|
}
|
|
1067
1089
|
findList.add(leaf);
|
|
@@ -1896,7 +1918,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
1896
1918
|
data.__naturalHeight = image.height / data.pixelRatio;
|
|
1897
1919
|
if (data.__autoSide) {
|
|
1898
1920
|
ui.forceUpdate();
|
|
1899
|
-
LeafHelper.updateBounds(ui);
|
|
1921
|
+
LeafHelper.updateBounds(ui, true);
|
|
1900
1922
|
ui.__layout.boundsChanged = true;
|
|
1901
1923
|
if (ui.__proxyData) {
|
|
1902
1924
|
ui.setProxyAttr("width", data.width);
|
|
@@ -3175,4 +3197,4 @@ Object.assign(Creator, {
|
|
|
3175
3197
|
|
|
3176
3198
|
useCanvas();
|
|
3177
3199
|
|
|
3178
|
-
export { Interaction, Layouter, LeaferCanvas, PathNodeHandleType, Picker, Renderer, Selector, Watcher, useCanvas };
|
|
3200
|
+
export { Interaction, Layouter, LayouterHelper, LeaferCanvas, PathNodeHandleType, Picker, Renderer, Selector, Watcher, useCanvas };
|