leafer-ui 1.5.3 → 1.6.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/README.md +1 -1
- package/dist/web.cjs +73 -75
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +73 -75
- package/dist/web.esm.js.map +1 -1
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +317 -202
- package/dist/web.js.map +1 -1
- 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 +317 -202
- package/dist/web.module.js.map +1 -1
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +11 -12
package/README.md
CHANGED
|
@@ -296,7 +296,7 @@ LeaferJS 致力于实现一套简洁、开放、现代化的 UI 绘图语言标
|
|
|
296
296
|
</p>
|
|
297
297
|
<p><h3 align="center">铜牌赞助</h3></p>
|
|
298
298
|
<p style="display: flex;flex-wrap: wrap;justify-content: center;gap: 15px;">
|
|
299
|
-
|
|
299
|
+
Lauginwing 江万江 在路上 张余🌈 Jerry 李狗嗨。💢 李维亮 朝夕 SaltedFish zhk 格子 等等 goosen 建伟F4nniu 梁福斌 江万江 杨超 ToB Dev 前端之虎陈随易 A☀️云☀️A ʚ LMT ɞ 爱发电用户_c9c82 轻简历 爱发电用户_0fac0 wangyesheji.cn 风间 爱发电用户_Tqsm 爱发电用户_6KpE dongdong zwm 爱发电用户_3725c Noth1ng 纳西妲の√ 爱发电用户_Ahb9 爱发电用户_7617d 冷漠 爱发电用户_9RXB 今日值得读 爱发电用户_49sT 爱发电用户_NFCS 爱发电用户_43ad8 爱发电用户_30455 xiaozhang 砖吐筷筷 爱发电用户_b47b3 longbow1998 爱发电用户_5d755 爱发电用户_b76b8 爱发电用户_e70c2 爱发电用户_039dc 花祁 爱发电用户_99f39 坤坤 爱发电用户_X6hp 爱发电用户_s5u9 曹吉美爸爸 啸沧海 Ronny Biu 王志强 PD.新城คิดถึง 糖颂缘冥倾 ALBERT. 爱发电用户_UXEV SaltedFish 爱发电用户_76f9d Leafer 爱发电用户_Pbm7 </p>
|
|
300
300
|
|
|
301
301
|
## License
|
|
302
302
|
|
package/dist/web.cjs
CHANGED
|
@@ -423,7 +423,6 @@ function updateChange(updateList) {
|
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
const { worldBounds } = core.LeafBoundsHelper;
|
|
426
|
-
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
427
426
|
class LayoutBlockData {
|
|
428
427
|
constructor(list) {
|
|
429
428
|
this.updatedBounds = new core.Bounds();
|
|
@@ -437,13 +436,7 @@ class LayoutBlockData {
|
|
|
437
436
|
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
438
437
|
}
|
|
439
438
|
setAfter() {
|
|
440
|
-
|
|
441
|
-
if (list.some(leaf => leaf.noBounds)) {
|
|
442
|
-
this.afterBounds.set(bigBounds);
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
this.afterBounds.setListWithFn(list, worldBounds);
|
|
446
|
-
}
|
|
439
|
+
this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
447
440
|
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
448
441
|
}
|
|
449
442
|
merge(data) {
|
|
@@ -645,6 +638,22 @@ class Renderer {
|
|
|
645
638
|
requestLayout() {
|
|
646
639
|
this.target.emit(core.LayoutEvent.REQUEST);
|
|
647
640
|
}
|
|
641
|
+
checkRender() {
|
|
642
|
+
if (this.running) {
|
|
643
|
+
const { target } = this;
|
|
644
|
+
if (target.isApp) {
|
|
645
|
+
target.emit(core.RenderEvent.CHILD_START, target);
|
|
646
|
+
target.children.forEach(leafer => {
|
|
647
|
+
leafer.renderer.FPS = this.FPS;
|
|
648
|
+
leafer.renderer.checkRender();
|
|
649
|
+
});
|
|
650
|
+
target.emit(core.RenderEvent.CHILD_END, target);
|
|
651
|
+
}
|
|
652
|
+
if (this.changed && this.canvas.view)
|
|
653
|
+
this.render();
|
|
654
|
+
this.target.emit(core.RenderEvent.NEXT);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
648
657
|
render(callback) {
|
|
649
658
|
if (!(this.running && this.canvas.view))
|
|
650
659
|
return this.update();
|
|
@@ -653,8 +662,6 @@ class Renderer {
|
|
|
653
662
|
this.totalBounds = new core.Bounds();
|
|
654
663
|
debug.log(target.innerName, '--->');
|
|
655
664
|
try {
|
|
656
|
-
if (!target.isApp)
|
|
657
|
-
target.app.emit(core.RenderEvent.CHILD_START, target);
|
|
658
665
|
this.emitRender(core.RenderEvent.START);
|
|
659
666
|
this.renderOnce(callback);
|
|
660
667
|
this.emitRender(core.RenderEvent.END, this.totalBounds);
|
|
@@ -722,20 +729,12 @@ class Renderer {
|
|
|
722
729
|
}
|
|
723
730
|
clipRender(block) {
|
|
724
731
|
const t = core.Run.start('PartRender');
|
|
725
|
-
const { canvas } = this;
|
|
726
|
-
const bounds = block.getIntersect(canvas.bounds);
|
|
727
|
-
const includes = block.includes(this.target.__world);
|
|
728
|
-
const realBounds = new core.Bounds(bounds);
|
|
732
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new core.Bounds(bounds);
|
|
729
733
|
canvas.save();
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
|
|
735
|
-
canvas.clearWorld(bounds, true);
|
|
736
|
-
canvas.clipWorld(bounds, true);
|
|
737
|
-
}
|
|
738
|
-
this.__render(bounds, includes, realBounds);
|
|
734
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
735
|
+
canvas.clearWorld(bounds, true);
|
|
736
|
+
canvas.clipWorld(bounds, true);
|
|
737
|
+
this.__render(bounds, realBounds);
|
|
739
738
|
canvas.restore();
|
|
740
739
|
core.Run.end(t);
|
|
741
740
|
}
|
|
@@ -744,28 +743,22 @@ class Renderer {
|
|
|
744
743
|
const { canvas } = this;
|
|
745
744
|
canvas.save();
|
|
746
745
|
canvas.clear();
|
|
747
|
-
this.__render(canvas.bounds
|
|
746
|
+
this.__render(canvas.bounds);
|
|
748
747
|
canvas.restore();
|
|
749
748
|
core.Run.end(t);
|
|
750
749
|
}
|
|
751
|
-
__render(bounds,
|
|
752
|
-
const
|
|
750
|
+
__render(bounds, realBounds) {
|
|
751
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
753
752
|
if (this.needFill)
|
|
754
|
-
|
|
753
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
755
754
|
if (core.Debug.showRepaint)
|
|
756
|
-
|
|
757
|
-
this.target.__render(
|
|
755
|
+
core.Debug.drawRepaint(canvas, bounds);
|
|
756
|
+
this.target.__render(canvas, options);
|
|
758
757
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
759
758
|
this.renderOptions = options;
|
|
760
759
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
if (core.Debug.showBoundsView)
|
|
764
|
-
this.renderBoundsView(options);
|
|
765
|
-
this.canvas.updateRender(realBounds);
|
|
766
|
-
}
|
|
767
|
-
renderHitView(_options) { }
|
|
768
|
-
renderBoundsView(_options) { }
|
|
760
|
+
canvas.updateRender(realBounds);
|
|
761
|
+
}
|
|
769
762
|
addBlock(block) {
|
|
770
763
|
if (!this.updateBlocks)
|
|
771
764
|
this.updateBlocks = [];
|
|
@@ -781,17 +774,16 @@ class Renderer {
|
|
|
781
774
|
}
|
|
782
775
|
}
|
|
783
776
|
__requestRender() {
|
|
784
|
-
|
|
777
|
+
const target = this.target;
|
|
778
|
+
if (this.requestTime || !target)
|
|
785
779
|
return;
|
|
780
|
+
if (target.parentApp)
|
|
781
|
+
return target.parentApp.requestRender(false);
|
|
786
782
|
const requestTime = this.requestTime = Date.now();
|
|
787
783
|
core.Platform.requestRender(() => {
|
|
788
784
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
789
785
|
this.requestTime = 0;
|
|
790
|
-
|
|
791
|
-
if (this.changed && this.canvas.view)
|
|
792
|
-
this.render();
|
|
793
|
-
this.target.emit(core.RenderEvent.NEXT);
|
|
794
|
-
}
|
|
786
|
+
this.checkRender();
|
|
795
787
|
});
|
|
796
788
|
}
|
|
797
789
|
__onResize(e) {
|
|
@@ -849,6 +841,7 @@ class Renderer {
|
|
|
849
841
|
}
|
|
850
842
|
}
|
|
851
843
|
}
|
|
844
|
+
Renderer.clipSpread = 10;
|
|
852
845
|
|
|
853
846
|
const { hitRadiusPoint } = core.BoundsHelper;
|
|
854
847
|
class Picker {
|
|
@@ -1677,9 +1670,11 @@ const tempBox = new core.Bounds();
|
|
|
1677
1670
|
const tempPoint = {};
|
|
1678
1671
|
const tempScaleData = {};
|
|
1679
1672
|
function createData(leafPaint, image, paint, box) {
|
|
1680
|
-
const { blendMode, sync } = paint;
|
|
1673
|
+
const { blendMode, changeful, sync } = paint;
|
|
1681
1674
|
if (blendMode)
|
|
1682
1675
|
leafPaint.blendMode = blendMode;
|
|
1676
|
+
if (changeful)
|
|
1677
|
+
leafPaint.changeful = changeful;
|
|
1683
1678
|
if (sync)
|
|
1684
1679
|
leafPaint.sync = sync;
|
|
1685
1680
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -1944,40 +1939,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1944
1939
|
};
|
|
1945
1940
|
|
|
1946
1941
|
const { abs } = Math;
|
|
1947
|
-
function checkImage(ui, canvas, paint,
|
|
1942
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1948
1943
|
const { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1949
|
-
const { pixelRatio } = canvas;
|
|
1950
|
-
if (!
|
|
1944
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
1945
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
|
|
1951
1946
|
return false;
|
|
1952
1947
|
}
|
|
1953
1948
|
else {
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
let { width, height } = data;
|
|
1958
|
-
width *= abs(scaleX) * pixelRatio;
|
|
1959
|
-
height *= abs(scaleY) * pixelRatio;
|
|
1960
|
-
if (data.scaleX) {
|
|
1961
|
-
width *= data.scaleX;
|
|
1962
|
-
height *= data.scaleY;
|
|
1963
|
-
}
|
|
1964
|
-
allowPaint = (width * height > core.Platform.image.maxCacheSize) || draw.Export.running;
|
|
1949
|
+
if (allowDraw) {
|
|
1950
|
+
if (data.repeat) {
|
|
1951
|
+
allowDraw = false;
|
|
1965
1952
|
}
|
|
1966
1953
|
else {
|
|
1967
|
-
|
|
1954
|
+
if (!(paint.changeful || core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
|
|
1955
|
+
let { width, height } = data;
|
|
1956
|
+
width *= abs(scaleX) * pixelRatio;
|
|
1957
|
+
height *= abs(scaleY) * pixelRatio;
|
|
1958
|
+
if (data.scaleX) {
|
|
1959
|
+
width *= data.scaleX;
|
|
1960
|
+
height *= data.scaleY;
|
|
1961
|
+
}
|
|
1962
|
+
allowDraw = (width * height > core.Platform.image.maxCacheSize);
|
|
1963
|
+
}
|
|
1968
1964
|
}
|
|
1969
1965
|
}
|
|
1970
|
-
if (
|
|
1971
|
-
canvas
|
|
1972
|
-
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1973
|
-
if (paint.blendMode)
|
|
1974
|
-
canvas.blendMode = paint.blendMode;
|
|
1975
|
-
if (data.opacity)
|
|
1976
|
-
canvas.opacity *= data.opacity;
|
|
1977
|
-
if (data.transform)
|
|
1978
|
-
canvas.transform(data.transform);
|
|
1979
|
-
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1980
|
-
canvas.restore();
|
|
1966
|
+
if (allowDraw) {
|
|
1967
|
+
drawImage(ui, canvas, paint, data);
|
|
1981
1968
|
return true;
|
|
1982
1969
|
}
|
|
1983
1970
|
else {
|
|
@@ -1998,13 +1985,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1998
1985
|
}
|
|
1999
1986
|
}
|
|
2000
1987
|
}
|
|
1988
|
+
function drawImage(ui, canvas, paint, data) {
|
|
1989
|
+
canvas.save();
|
|
1990
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1991
|
+
if (paint.blendMode)
|
|
1992
|
+
canvas.blendMode = paint.blendMode;
|
|
1993
|
+
if (data.opacity)
|
|
1994
|
+
canvas.opacity *= data.opacity;
|
|
1995
|
+
if (data.transform)
|
|
1996
|
+
canvas.transform(data.transform);
|
|
1997
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1998
|
+
canvas.restore();
|
|
1999
|
+
}
|
|
2001
2000
|
|
|
2002
2001
|
function recycleImage(attrName, data) {
|
|
2003
2002
|
const paints = data['_' + attrName];
|
|
2004
2003
|
if (paints instanceof Array) {
|
|
2005
|
-
let image, recycleMap, input, url;
|
|
2004
|
+
let paint, image, recycleMap, input, url;
|
|
2006
2005
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
2007
|
-
|
|
2006
|
+
paint = paints[i];
|
|
2007
|
+
image = paint.image;
|
|
2008
2008
|
url = image && image.url;
|
|
2009
2009
|
if (url) {
|
|
2010
2010
|
if (!recycleMap)
|
|
@@ -2019,8 +2019,6 @@ function recycleImage(attrName, data) {
|
|
|
2019
2019
|
}
|
|
2020
2020
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
2021
2021
|
}
|
|
2022
|
-
else
|
|
2023
|
-
paints[i].style = null;
|
|
2024
2022
|
}
|
|
2025
2023
|
}
|
|
2026
2024
|
return recycleMap;
|
|
@@ -2199,7 +2197,7 @@ const { toOffsetOutBounds } = core.BoundsHelper;
|
|
|
2199
2197
|
const offsetOutBounds = {};
|
|
2200
2198
|
function innerShadow(ui, current, shape) {
|
|
2201
2199
|
let copyBounds, spreadScale;
|
|
2202
|
-
const { __nowWorld: nowWorld, __layout
|
|
2200
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
2203
2201
|
const { innerShadow } = ui.__;
|
|
2204
2202
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
2205
2203
|
const other = current.getSameCanvas();
|