leafer-ui 1.5.3 → 1.6.0
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 +68 -71
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +68 -71
- 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 +303 -192
- 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 +303 -192
- 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/dist/web.esm.js
CHANGED
|
@@ -424,7 +424,6 @@ function updateChange(updateList) {
|
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
const { worldBounds } = LeafBoundsHelper;
|
|
427
|
-
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
428
427
|
class LayoutBlockData {
|
|
429
428
|
constructor(list) {
|
|
430
429
|
this.updatedBounds = new Bounds();
|
|
@@ -438,13 +437,7 @@ class LayoutBlockData {
|
|
|
438
437
|
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
439
438
|
}
|
|
440
439
|
setAfter() {
|
|
441
|
-
|
|
442
|
-
if (list.some(leaf => leaf.noBounds)) {
|
|
443
|
-
this.afterBounds.set(bigBounds);
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
this.afterBounds.setListWithFn(list, worldBounds);
|
|
447
|
-
}
|
|
440
|
+
this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
448
441
|
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
449
442
|
}
|
|
450
443
|
merge(data) {
|
|
@@ -646,6 +639,13 @@ class Renderer {
|
|
|
646
639
|
requestLayout() {
|
|
647
640
|
this.target.emit(LayoutEvent.REQUEST);
|
|
648
641
|
}
|
|
642
|
+
checkRender() {
|
|
643
|
+
if (this.running) {
|
|
644
|
+
if (this.changed && this.canvas.view)
|
|
645
|
+
this.render();
|
|
646
|
+
this.target.emit(RenderEvent.NEXT);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
649
|
render(callback) {
|
|
650
650
|
if (!(this.running && this.canvas.view))
|
|
651
651
|
return this.update();
|
|
@@ -654,8 +654,6 @@ class Renderer {
|
|
|
654
654
|
this.totalBounds = new Bounds();
|
|
655
655
|
debug.log(target.innerName, '--->');
|
|
656
656
|
try {
|
|
657
|
-
if (!target.isApp)
|
|
658
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
659
657
|
this.emitRender(RenderEvent.START);
|
|
660
658
|
this.renderOnce(callback);
|
|
661
659
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -723,20 +721,12 @@ class Renderer {
|
|
|
723
721
|
}
|
|
724
722
|
clipRender(block) {
|
|
725
723
|
const t = Run.start('PartRender');
|
|
726
|
-
const { canvas } = this;
|
|
727
|
-
const bounds = block.getIntersect(canvas.bounds);
|
|
728
|
-
const includes = block.includes(this.target.__world);
|
|
729
|
-
const realBounds = new Bounds(bounds);
|
|
724
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
730
725
|
canvas.save();
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
|
|
736
|
-
canvas.clearWorld(bounds, true);
|
|
737
|
-
canvas.clipWorld(bounds, true);
|
|
738
|
-
}
|
|
739
|
-
this.__render(bounds, includes, realBounds);
|
|
726
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
727
|
+
canvas.clearWorld(bounds, true);
|
|
728
|
+
canvas.clipWorld(bounds, true);
|
|
729
|
+
this.__render(bounds, block.includes(this.target.__world), realBounds);
|
|
740
730
|
canvas.restore();
|
|
741
731
|
Run.end(t);
|
|
742
732
|
}
|
|
@@ -750,23 +740,17 @@ class Renderer {
|
|
|
750
740
|
Run.end(t);
|
|
751
741
|
}
|
|
752
742
|
__render(bounds, includes, realBounds) {
|
|
753
|
-
const options =
|
|
743
|
+
const { canvas } = this, options = includes ? { includes } : { bounds, includes };
|
|
754
744
|
if (this.needFill)
|
|
755
|
-
|
|
745
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
756
746
|
if (Debug.showRepaint)
|
|
757
|
-
|
|
758
|
-
this.target.__render(
|
|
747
|
+
Debug.drawRepaint(canvas, bounds);
|
|
748
|
+
this.target.__render(canvas, options);
|
|
759
749
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
760
750
|
this.renderOptions = options;
|
|
761
751
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
if (Debug.showBoundsView)
|
|
765
|
-
this.renderBoundsView(options);
|
|
766
|
-
this.canvas.updateRender(realBounds);
|
|
767
|
-
}
|
|
768
|
-
renderHitView(_options) { }
|
|
769
|
-
renderBoundsView(_options) { }
|
|
752
|
+
canvas.updateRender(realBounds);
|
|
753
|
+
}
|
|
770
754
|
addBlock(block) {
|
|
771
755
|
if (!this.updateBlocks)
|
|
772
756
|
this.updateBlocks = [];
|
|
@@ -782,17 +766,24 @@ class Renderer {
|
|
|
782
766
|
}
|
|
783
767
|
}
|
|
784
768
|
__requestRender() {
|
|
769
|
+
const target = this.target;
|
|
770
|
+
if (target.parentApp)
|
|
771
|
+
return target.parentApp.renderer.update(false);
|
|
785
772
|
if (this.requestTime)
|
|
786
773
|
return;
|
|
787
774
|
const requestTime = this.requestTime = Date.now();
|
|
788
775
|
Platform.requestRender(() => {
|
|
789
776
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
790
777
|
this.requestTime = 0;
|
|
791
|
-
if (
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
778
|
+
if (target.isApp) {
|
|
779
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
780
|
+
target.children.forEach(leafer => {
|
|
781
|
+
leafer.renderer.FPS = this.FPS;
|
|
782
|
+
leafer.renderer.checkRender();
|
|
783
|
+
});
|
|
784
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
795
785
|
}
|
|
786
|
+
this.checkRender();
|
|
796
787
|
});
|
|
797
788
|
}
|
|
798
789
|
__onResize(e) {
|
|
@@ -850,6 +841,7 @@ class Renderer {
|
|
|
850
841
|
}
|
|
851
842
|
}
|
|
852
843
|
}
|
|
844
|
+
Renderer.clipSpread = 10;
|
|
853
845
|
|
|
854
846
|
const { hitRadiusPoint } = BoundsHelper;
|
|
855
847
|
class Picker {
|
|
@@ -1678,9 +1670,11 @@ const tempBox = new Bounds();
|
|
|
1678
1670
|
const tempPoint = {};
|
|
1679
1671
|
const tempScaleData = {};
|
|
1680
1672
|
function createData(leafPaint, image, paint, box) {
|
|
1681
|
-
const { blendMode, sync } = paint;
|
|
1673
|
+
const { blendMode, changeful, sync } = paint;
|
|
1682
1674
|
if (blendMode)
|
|
1683
1675
|
leafPaint.blendMode = blendMode;
|
|
1676
|
+
if (changeful)
|
|
1677
|
+
leafPaint.changeful = changeful;
|
|
1684
1678
|
if (sync)
|
|
1685
1679
|
leafPaint.sync = sync;
|
|
1686
1680
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -1945,40 +1939,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1945
1939
|
};
|
|
1946
1940
|
|
|
1947
1941
|
const { abs } = Math;
|
|
1948
|
-
function checkImage(ui, canvas, paint,
|
|
1942
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
1949
1943
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
1950
|
-
const { pixelRatio } = canvas;
|
|
1951
|
-
if (!
|
|
1944
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
1945
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
1952
1946
|
return false;
|
|
1953
1947
|
}
|
|
1954
1948
|
else {
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
let { width, height } = data;
|
|
1959
|
-
width *= abs(scaleX) * pixelRatio;
|
|
1960
|
-
height *= abs(scaleY) * pixelRatio;
|
|
1961
|
-
if (data.scaleX) {
|
|
1962
|
-
width *= data.scaleX;
|
|
1963
|
-
height *= data.scaleY;
|
|
1964
|
-
}
|
|
1965
|
-
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
1949
|
+
if (allowDraw) {
|
|
1950
|
+
if (data.repeat) {
|
|
1951
|
+
allowDraw = false;
|
|
1966
1952
|
}
|
|
1967
1953
|
else {
|
|
1968
|
-
|
|
1954
|
+
if (!(paint.changeful || ResizeEvent.isResizing(ui) || 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 > Platform.image.maxCacheSize);
|
|
1963
|
+
}
|
|
1969
1964
|
}
|
|
1970
1965
|
}
|
|
1971
|
-
if (
|
|
1972
|
-
canvas
|
|
1973
|
-
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
1974
|
-
if (paint.blendMode)
|
|
1975
|
-
canvas.blendMode = paint.blendMode;
|
|
1976
|
-
if (data.opacity)
|
|
1977
|
-
canvas.opacity *= data.opacity;
|
|
1978
|
-
if (data.transform)
|
|
1979
|
-
canvas.transform(data.transform);
|
|
1980
|
-
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1981
|
-
canvas.restore();
|
|
1966
|
+
if (allowDraw) {
|
|
1967
|
+
drawImage(ui, canvas, paint, data);
|
|
1982
1968
|
return true;
|
|
1983
1969
|
}
|
|
1984
1970
|
else {
|
|
@@ -1999,13 +1985,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1999
1985
|
}
|
|
2000
1986
|
}
|
|
2001
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
|
+
}
|
|
2002
2000
|
|
|
2003
2001
|
function recycleImage(attrName, data) {
|
|
2004
2002
|
const paints = data['_' + attrName];
|
|
2005
2003
|
if (paints instanceof Array) {
|
|
2006
|
-
let image, recycleMap, input, url;
|
|
2004
|
+
let paint, image, recycleMap, input, url;
|
|
2007
2005
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
2008
|
-
|
|
2006
|
+
paint = paints[i];
|
|
2007
|
+
image = paint.image;
|
|
2009
2008
|
url = image && image.url;
|
|
2010
2009
|
if (url) {
|
|
2011
2010
|
if (!recycleMap)
|
|
@@ -2020,8 +2019,6 @@ function recycleImage(attrName, data) {
|
|
|
2020
2019
|
}
|
|
2021
2020
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
2022
2021
|
}
|
|
2023
|
-
else
|
|
2024
|
-
paints[i].style = null;
|
|
2025
2022
|
}
|
|
2026
2023
|
}
|
|
2027
2024
|
return recycleMap;
|
|
@@ -2200,7 +2197,7 @@ const { toOffsetOutBounds } = BoundsHelper;
|
|
|
2200
2197
|
const offsetOutBounds = {};
|
|
2201
2198
|
function innerShadow(ui, current, shape) {
|
|
2202
2199
|
let copyBounds, spreadScale;
|
|
2203
|
-
const { __nowWorld: nowWorld, __layout
|
|
2200
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
2204
2201
|
const { innerShadow } = ui.__;
|
|
2205
2202
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
2206
2203
|
const other = current.getSameCanvas();
|