@leafer-ui/miniapp 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/dist/miniapp.cjs +73 -75
- package/dist/miniapp.cjs.map +1 -1
- package/dist/miniapp.esm.js +73 -75
- package/dist/miniapp.esm.js.map +1 -1
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +317 -202
- package/dist/miniapp.module.js.map +1 -1
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +12 -11
- package/src/core.ts +143 -0
- package/src/index.ts +2 -2
- package/types/index.d.ts +8 -1
package/dist/miniapp.module.js
CHANGED
|
@@ -45,7 +45,7 @@ const IncrementId = {
|
|
|
45
45
|
};
|
|
46
46
|
const I$2 = IncrementId;
|
|
47
47
|
|
|
48
|
-
const { round, pow: pow$1, PI: PI$4 } = Math;
|
|
48
|
+
const { round: round$3, pow: pow$1, PI: PI$4 } = Math;
|
|
49
49
|
const MathHelper = {
|
|
50
50
|
within(value, min, max) {
|
|
51
51
|
if (typeof min === 'object')
|
|
@@ -109,7 +109,7 @@ const MathHelper = {
|
|
|
109
109
|
},
|
|
110
110
|
float(num, maxLength) {
|
|
111
111
|
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
112
|
-
num = round(num * a) / a;
|
|
112
|
+
num = round$3(num * a) / a;
|
|
113
113
|
return num === -0 ? 0 : num;
|
|
114
114
|
},
|
|
115
115
|
getScaleData(scale, size, originSize, scaleData) {
|
|
@@ -132,8 +132,15 @@ const MathHelper = {
|
|
|
132
132
|
scaleData.scaleX = scale.x;
|
|
133
133
|
scaleData.scaleY = scale.y;
|
|
134
134
|
}
|
|
135
|
+
},
|
|
136
|
+
randInt,
|
|
137
|
+
randColor(opacity) {
|
|
138
|
+
return `rgba(${randInt(255)},${randInt(255)},${randInt(255)},${opacity || 1})`;
|
|
135
139
|
}
|
|
136
140
|
};
|
|
141
|
+
function randInt(num) {
|
|
142
|
+
return Math.round(Math.random() * num);
|
|
143
|
+
}
|
|
137
144
|
const OneRadian = PI$4 / 180;
|
|
138
145
|
const PI2 = PI$4 * 2;
|
|
139
146
|
const PI_2 = PI$4 / 2;
|
|
@@ -431,7 +438,7 @@ const MatrixHelper = {
|
|
|
431
438
|
const M$6 = MatrixHelper;
|
|
432
439
|
|
|
433
440
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
434
|
-
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
441
|
+
const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2, PI: PI$3 } = Math;
|
|
435
442
|
const PointHelper = {
|
|
436
443
|
defaultPoint: getPointData(),
|
|
437
444
|
tempPoint: {},
|
|
@@ -452,6 +459,10 @@ const PointHelper = {
|
|
|
452
459
|
t.x = x;
|
|
453
460
|
t.y = y;
|
|
454
461
|
},
|
|
462
|
+
round(t, halfPixel) {
|
|
463
|
+
t.x = halfPixel ? round$2(t.x - 0.5) + 0.5 : round$2(t.x);
|
|
464
|
+
t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
|
|
465
|
+
},
|
|
455
466
|
move(t, x, y) {
|
|
456
467
|
t.x += x;
|
|
457
468
|
t.y += y;
|
|
@@ -1317,6 +1328,7 @@ const StringNumberMap = {
|
|
|
1317
1328
|
'E': 1
|
|
1318
1329
|
};
|
|
1319
1330
|
|
|
1331
|
+
const { randColor } = MathHelper;
|
|
1320
1332
|
class Debug {
|
|
1321
1333
|
constructor(name) {
|
|
1322
1334
|
this.repeatMap = {};
|
|
@@ -1331,6 +1343,19 @@ class Debug {
|
|
|
1331
1343
|
static set exclude(name) {
|
|
1332
1344
|
this.excludeList = getNameList(name);
|
|
1333
1345
|
}
|
|
1346
|
+
static drawRepaint(canvas, bounds) {
|
|
1347
|
+
const color = randColor();
|
|
1348
|
+
canvas.fillWorld(bounds, color.replace('1)', '.1)'));
|
|
1349
|
+
canvas.strokeWorld(bounds, color);
|
|
1350
|
+
}
|
|
1351
|
+
static drawBounds(leaf, canvas, _options) {
|
|
1352
|
+
const showHit = Debug.showBounds === 'hit', w = leaf.__nowWorld, color = randColor();
|
|
1353
|
+
if (showHit)
|
|
1354
|
+
canvas.setWorld(w), leaf.__drawHitPath(canvas), canvas.fillStyle = color.replace('1)', '.2)'), canvas.fill();
|
|
1355
|
+
canvas.resetTransform();
|
|
1356
|
+
canvas.setStroke(color, 2);
|
|
1357
|
+
showHit ? canvas.stroke() : canvas.strokeWorld(w, color);
|
|
1358
|
+
}
|
|
1334
1359
|
log(...messages) {
|
|
1335
1360
|
if (D$4.enable) {
|
|
1336
1361
|
if (D$4.filterList.length && D$4.filterList.every(name => name !== this.name))
|
|
@@ -1417,7 +1442,7 @@ const Plugin = {
|
|
|
1417
1442
|
return rs;
|
|
1418
1443
|
},
|
|
1419
1444
|
need(name) {
|
|
1420
|
-
console.error('
|
|
1445
|
+
console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1421
1446
|
}
|
|
1422
1447
|
};
|
|
1423
1448
|
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
@@ -2017,7 +2042,7 @@ __decorate([
|
|
|
2017
2042
|
contextMethod()
|
|
2018
2043
|
], Canvas$1.prototype, "strokeText", null);
|
|
2019
2044
|
|
|
2020
|
-
const { copy: copy$9 } = MatrixHelper;
|
|
2045
|
+
const { copy: copy$9, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
|
|
2021
2046
|
const minSize = { width: 1, height: 1, pixelRatio: 1 };
|
|
2022
2047
|
const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
|
|
2023
2048
|
class LeaferCanvasBase extends Canvas$1 {
|
|
@@ -2026,6 +2051,8 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2026
2051
|
get pixelRatio() { return this.size.pixelRatio; }
|
|
2027
2052
|
get pixelWidth() { return this.width * this.pixelRatio; }
|
|
2028
2053
|
get pixelHeight() { return this.height * this.pixelRatio; }
|
|
2054
|
+
get pixelSnap() { return this.config.pixelSnap; }
|
|
2055
|
+
set pixelSnap(value) { this.config.pixelSnap = value; }
|
|
2029
2056
|
get allowBackgroundColor() { return this.view && this.parentView; }
|
|
2030
2057
|
constructor(config, manager) {
|
|
2031
2058
|
super();
|
|
@@ -2086,15 +2113,22 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2086
2113
|
stopAutoLayout() { }
|
|
2087
2114
|
setCursor(_cursor) { }
|
|
2088
2115
|
setWorld(matrix, parentMatrix) {
|
|
2089
|
-
const { pixelRatio } = this;
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2116
|
+
const { pixelRatio, pixelSnap } = this, w = this.worldTransform;
|
|
2117
|
+
if (parentMatrix)
|
|
2118
|
+
multiplyParent$3(matrix, parentMatrix, w);
|
|
2119
|
+
w.a = matrix.a * pixelRatio;
|
|
2120
|
+
w.b = matrix.b * pixelRatio;
|
|
2121
|
+
w.c = matrix.c * pixelRatio;
|
|
2122
|
+
w.d = matrix.d * pixelRatio;
|
|
2123
|
+
w.e = matrix.e * pixelRatio;
|
|
2124
|
+
w.f = matrix.f * pixelRatio;
|
|
2125
|
+
if (pixelSnap) {
|
|
2126
|
+
if (matrix.half && (matrix.half * pixelRatio) % 2)
|
|
2127
|
+
w.e = round$1(w.e - 0.5) + 0.5, w.f = round$1(w.f - 0.5) + 0.5;
|
|
2128
|
+
else
|
|
2129
|
+
w.e = round$1(w.e), w.f = round$1(w.f);
|
|
2097
2130
|
}
|
|
2131
|
+
this.setTransform(w.a, w.b, w.c, w.d, w.e, w.f);
|
|
2098
2132
|
}
|
|
2099
2133
|
useWorldTransform(worldTransform) {
|
|
2100
2134
|
if (worldTransform)
|
|
@@ -2237,12 +2271,13 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2237
2271
|
return this.width === size.width && this.height === size.height && (!size.pixelRatio || this.pixelRatio === size.pixelRatio);
|
|
2238
2272
|
}
|
|
2239
2273
|
getSameCanvas(useSameWorldTransform, useSameSmooth) {
|
|
2240
|
-
const canvas = this.manager ? this.manager.get(
|
|
2274
|
+
const { size, pixelSnap } = this, canvas = this.manager ? this.manager.get(size) : Creator.canvas(Object.assign({}, size));
|
|
2241
2275
|
canvas.save();
|
|
2242
2276
|
if (useSameWorldTransform)
|
|
2243
2277
|
copy$9(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
|
|
2244
2278
|
if (useSameSmooth)
|
|
2245
2279
|
canvas.smooth = this.smooth;
|
|
2280
|
+
canvas.pixelSnap !== pixelSnap && (canvas.pixelSnap = pixelSnap);
|
|
2246
2281
|
return canvas;
|
|
2247
2282
|
}
|
|
2248
2283
|
recycle(clearBounds) {
|
|
@@ -3669,7 +3704,7 @@ const Resource = {
|
|
|
3669
3704
|
const R = Resource;
|
|
3670
3705
|
|
|
3671
3706
|
const ImageManager = {
|
|
3672
|
-
maxRecycled:
|
|
3707
|
+
maxRecycled: 10,
|
|
3673
3708
|
recycledList: [],
|
|
3674
3709
|
patternTasker: new TaskProcessor(),
|
|
3675
3710
|
get(config) {
|
|
@@ -4022,9 +4057,8 @@ function hitType(defaultValue) {
|
|
|
4022
4057
|
set(value) {
|
|
4023
4058
|
if (this.__setAttr(key, value)) {
|
|
4024
4059
|
this.__layout.hitCanvasChanged = true;
|
|
4025
|
-
if (Debug.
|
|
4060
|
+
if (Debug.showBounds === 'hit')
|
|
4026
4061
|
this.__layout.surfaceChanged || this.__layout.surfaceChange();
|
|
4027
|
-
}
|
|
4028
4062
|
if (this.leafer)
|
|
4029
4063
|
this.leafer.updateCursor();
|
|
4030
4064
|
}
|
|
@@ -4185,7 +4219,7 @@ function registerUIEvent() {
|
|
|
4185
4219
|
}
|
|
4186
4220
|
|
|
4187
4221
|
const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4188
|
-
const matrix$1 = {};
|
|
4222
|
+
const matrix$1 = {}, { round } = Math;
|
|
4189
4223
|
const LeafHelper = {
|
|
4190
4224
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
4191
4225
|
if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
|
|
@@ -4259,6 +4293,8 @@ const LeafHelper = {
|
|
|
4259
4293
|
y = x.y, x = x.x;
|
|
4260
4294
|
x += t.x;
|
|
4261
4295
|
y += t.y;
|
|
4296
|
+
if (t.leafer && t.leafer.config.pointSnap)
|
|
4297
|
+
x = round(x), y = round(y);
|
|
4262
4298
|
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4263
4299
|
},
|
|
4264
4300
|
zoomOfWorld(t, origin, scaleX, scaleY, resize, transition) {
|
|
@@ -4497,6 +4533,7 @@ class LeafLayout {
|
|
|
4497
4533
|
set contentBounds(bounds) { this._contentBounds = bounds; }
|
|
4498
4534
|
get strokeBounds() { return this._strokeBounds || this.boxBounds; }
|
|
4499
4535
|
get renderBounds() { return this._renderBounds || this.boxBounds; }
|
|
4536
|
+
set renderBounds(bounds) { this._renderBounds = bounds; }
|
|
4500
4537
|
get localContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {})); return this[localContent]; }
|
|
4501
4538
|
get localStrokeBounds() { return this._localStrokeBounds || this; }
|
|
4502
4539
|
get localRenderBounds() { return this._localRenderBounds || this; }
|
|
@@ -4515,11 +4552,13 @@ class LeafLayout {
|
|
|
4515
4552
|
get height() { return this.boxBounds.height; }
|
|
4516
4553
|
constructor(leaf) {
|
|
4517
4554
|
this.leaf = leaf;
|
|
4518
|
-
this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
|
|
4519
4555
|
if (this.leaf.__local)
|
|
4520
4556
|
this._localRenderBounds = this._localStrokeBounds = this.leaf.__local;
|
|
4521
|
-
|
|
4522
|
-
|
|
4557
|
+
if (leaf.__world) {
|
|
4558
|
+
this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
|
|
4559
|
+
this.boxChange();
|
|
4560
|
+
this.matrixChange();
|
|
4561
|
+
}
|
|
4523
4562
|
}
|
|
4524
4563
|
createLocal() {
|
|
4525
4564
|
const local = this.leaf.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -4851,6 +4890,9 @@ class ResizeEvent extends Event {
|
|
|
4851
4890
|
}
|
|
4852
4891
|
this.old = oldSize;
|
|
4853
4892
|
}
|
|
4893
|
+
static isResizing(leaf) {
|
|
4894
|
+
return this.resizingKeys && this.resizingKeys[leaf.innerId] !== undefined;
|
|
4895
|
+
}
|
|
4854
4896
|
}
|
|
4855
4897
|
ResizeEvent.RESIZE = 'resize';
|
|
4856
4898
|
|
|
@@ -4893,6 +4935,7 @@ class RenderEvent extends Event {
|
|
|
4893
4935
|
}
|
|
4894
4936
|
RenderEvent.REQUEST = 'render.request';
|
|
4895
4937
|
RenderEvent.CHILD_START = 'render.child_start';
|
|
4938
|
+
RenderEvent.CHILD_END = 'render.child_end';
|
|
4896
4939
|
RenderEvent.START = 'render.start';
|
|
4897
4940
|
RenderEvent.BEFORE = 'render.before';
|
|
4898
4941
|
RenderEvent.RENDER = 'render';
|
|
@@ -5272,24 +5315,27 @@ const LeafBounds = {
|
|
|
5272
5315
|
const LeafRender = {
|
|
5273
5316
|
__render(canvas, options) {
|
|
5274
5317
|
if (this.__worldOpacity) {
|
|
5318
|
+
const data = this.__;
|
|
5275
5319
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5276
|
-
canvas.opacity =
|
|
5320
|
+
canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
|
|
5277
5321
|
if (this.__.__single) {
|
|
5278
|
-
if (
|
|
5322
|
+
if (data.eraser === 'path')
|
|
5279
5323
|
return this.__renderEraser(canvas, options);
|
|
5280
5324
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
5281
5325
|
this.__draw(tempCanvas, options, canvas);
|
|
5282
5326
|
if (this.__worldFlipped) {
|
|
5283
|
-
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null,
|
|
5327
|
+
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
|
|
5284
5328
|
}
|
|
5285
5329
|
else {
|
|
5286
|
-
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds,
|
|
5330
|
+
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
|
|
5287
5331
|
}
|
|
5288
5332
|
tempCanvas.recycle(this.__nowWorld);
|
|
5289
5333
|
}
|
|
5290
5334
|
else {
|
|
5291
5335
|
this.__draw(canvas, options);
|
|
5292
5336
|
}
|
|
5337
|
+
if (Debug.showBounds)
|
|
5338
|
+
Debug.drawBounds(this, canvas, options);
|
|
5293
5339
|
}
|
|
5294
5340
|
},
|
|
5295
5341
|
__clip(canvas, options) {
|
|
@@ -5319,14 +5365,19 @@ const BranchRender = {
|
|
|
5319
5365
|
__render(canvas, options) {
|
|
5320
5366
|
this.__nowWorld = this.__getNowWorld(options);
|
|
5321
5367
|
if (this.__worldOpacity) {
|
|
5322
|
-
|
|
5323
|
-
|
|
5368
|
+
const data = this.__;
|
|
5369
|
+
if (data.dim)
|
|
5370
|
+
options.dimOpacity = data.dim === true ? 0.2 : data.dim;
|
|
5371
|
+
else if (data.dimskip)
|
|
5372
|
+
options.dimOpacity && (options.dimOpacity = 0);
|
|
5373
|
+
if (data.__single) {
|
|
5374
|
+
if (data.eraser === 'path')
|
|
5324
5375
|
return this.__renderEraser(canvas, options);
|
|
5325
5376
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
5326
5377
|
this.__renderBranch(tempCanvas, options);
|
|
5327
5378
|
const nowWorld = this.__nowWorld;
|
|
5328
|
-
canvas.opacity =
|
|
5329
|
-
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld,
|
|
5379
|
+
canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
|
|
5380
|
+
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
|
|
5330
5381
|
tempCanvas.recycle(nowWorld);
|
|
5331
5382
|
}
|
|
5332
5383
|
else {
|
|
@@ -5401,9 +5452,11 @@ let Leaf = class Leaf {
|
|
|
5401
5452
|
reset(data) {
|
|
5402
5453
|
if (this.leafer)
|
|
5403
5454
|
this.leafer.forceRender(this.__world);
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5455
|
+
if (data !== 0) {
|
|
5456
|
+
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 };
|
|
5457
|
+
if (data !== null)
|
|
5458
|
+
this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
|
|
5459
|
+
}
|
|
5407
5460
|
this.__worldOpacity = 1;
|
|
5408
5461
|
this.__ = new this.__DataProcessor(this);
|
|
5409
5462
|
this.__layout = new this.__LayoutProcessor(this);
|
|
@@ -5539,9 +5592,10 @@ let Leaf = class Leaf {
|
|
|
5539
5592
|
if (options.matrix) {
|
|
5540
5593
|
if (!this.__cameraWorld)
|
|
5541
5594
|
this.__cameraWorld = {};
|
|
5542
|
-
const cameraWorld = this.__cameraWorld;
|
|
5543
|
-
multiplyParent(
|
|
5595
|
+
const cameraWorld = this.__cameraWorld, world = this.__world;
|
|
5596
|
+
multiplyParent(world, options.matrix, cameraWorld, undefined, world);
|
|
5544
5597
|
toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
|
|
5598
|
+
cameraWorld.half !== world.half && (cameraWorld.half = world.half);
|
|
5545
5599
|
return cameraWorld;
|
|
5546
5600
|
}
|
|
5547
5601
|
else {
|
|
@@ -5701,7 +5755,7 @@ let Leaf = class Leaf {
|
|
|
5701
5755
|
__updateHitCanvas() { }
|
|
5702
5756
|
__render(_canvas, _options) { }
|
|
5703
5757
|
__drawFast(_canvas, _options) { }
|
|
5704
|
-
__draw(_canvas, _options) { }
|
|
5758
|
+
__draw(_canvas, _options, _originCanvas) { }
|
|
5705
5759
|
__clip(_canvas, _options) { }
|
|
5706
5760
|
__renderShape(_canvas, _options, _ignoreFill, _ignoreStroke) { }
|
|
5707
5761
|
__updateWorldOpacity() { }
|
|
@@ -6071,7 +6125,7 @@ class LeafLevelList {
|
|
|
6071
6125
|
}
|
|
6072
6126
|
}
|
|
6073
6127
|
|
|
6074
|
-
const version = "1.
|
|
6128
|
+
const version = "1.6.1";
|
|
6075
6129
|
|
|
6076
6130
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6077
6131
|
get allowBackgroundColor() { return false; }
|
|
@@ -6450,7 +6504,6 @@ function updateChange(updateList) {
|
|
|
6450
6504
|
}
|
|
6451
6505
|
|
|
6452
6506
|
const { worldBounds } = LeafBoundsHelper;
|
|
6453
|
-
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
6454
6507
|
class LayoutBlockData {
|
|
6455
6508
|
constructor(list) {
|
|
6456
6509
|
this.updatedBounds = new Bounds();
|
|
@@ -6464,13 +6517,7 @@ class LayoutBlockData {
|
|
|
6464
6517
|
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
6465
6518
|
}
|
|
6466
6519
|
setAfter() {
|
|
6467
|
-
|
|
6468
|
-
if (list.some(leaf => leaf.noBounds)) {
|
|
6469
|
-
this.afterBounds.set(bigBounds);
|
|
6470
|
-
}
|
|
6471
|
-
else {
|
|
6472
|
-
this.afterBounds.setListWithFn(list, worldBounds);
|
|
6473
|
-
}
|
|
6520
|
+
this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
6474
6521
|
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
6475
6522
|
}
|
|
6476
6523
|
merge(data) {
|
|
@@ -6672,6 +6719,22 @@ class Renderer {
|
|
|
6672
6719
|
requestLayout() {
|
|
6673
6720
|
this.target.emit(LayoutEvent.REQUEST);
|
|
6674
6721
|
}
|
|
6722
|
+
checkRender() {
|
|
6723
|
+
if (this.running) {
|
|
6724
|
+
const { target } = this;
|
|
6725
|
+
if (target.isApp) {
|
|
6726
|
+
target.emit(RenderEvent.CHILD_START, target);
|
|
6727
|
+
target.children.forEach(leafer => {
|
|
6728
|
+
leafer.renderer.FPS = this.FPS;
|
|
6729
|
+
leafer.renderer.checkRender();
|
|
6730
|
+
});
|
|
6731
|
+
target.emit(RenderEvent.CHILD_END, target);
|
|
6732
|
+
}
|
|
6733
|
+
if (this.changed && this.canvas.view)
|
|
6734
|
+
this.render();
|
|
6735
|
+
this.target.emit(RenderEvent.NEXT);
|
|
6736
|
+
}
|
|
6737
|
+
}
|
|
6675
6738
|
render(callback) {
|
|
6676
6739
|
if (!(this.running && this.canvas.view))
|
|
6677
6740
|
return this.update();
|
|
@@ -6680,8 +6743,6 @@ class Renderer {
|
|
|
6680
6743
|
this.totalBounds = new Bounds();
|
|
6681
6744
|
debug$3.log(target.innerName, '--->');
|
|
6682
6745
|
try {
|
|
6683
|
-
if (!target.isApp)
|
|
6684
|
-
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6685
6746
|
this.emitRender(RenderEvent.START);
|
|
6686
6747
|
this.renderOnce(callback);
|
|
6687
6748
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6749,20 +6810,12 @@ class Renderer {
|
|
|
6749
6810
|
}
|
|
6750
6811
|
clipRender(block) {
|
|
6751
6812
|
const t = Run.start('PartRender');
|
|
6752
|
-
const { canvas } = this;
|
|
6753
|
-
const bounds = block.getIntersect(canvas.bounds);
|
|
6754
|
-
const includes = block.includes(this.target.__world);
|
|
6755
|
-
const realBounds = new Bounds(bounds);
|
|
6813
|
+
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
|
|
6756
6814
|
canvas.save();
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
|
|
6762
|
-
canvas.clearWorld(bounds, true);
|
|
6763
|
-
canvas.clipWorld(bounds, true);
|
|
6764
|
-
}
|
|
6765
|
-
this.__render(bounds, includes, realBounds);
|
|
6815
|
+
bounds.spread(Renderer.clipSpread).ceil();
|
|
6816
|
+
canvas.clearWorld(bounds, true);
|
|
6817
|
+
canvas.clipWorld(bounds, true);
|
|
6818
|
+
this.__render(bounds, realBounds);
|
|
6766
6819
|
canvas.restore();
|
|
6767
6820
|
Run.end(t);
|
|
6768
6821
|
}
|
|
@@ -6771,28 +6824,22 @@ class Renderer {
|
|
|
6771
6824
|
const { canvas } = this;
|
|
6772
6825
|
canvas.save();
|
|
6773
6826
|
canvas.clear();
|
|
6774
|
-
this.__render(canvas.bounds
|
|
6827
|
+
this.__render(canvas.bounds);
|
|
6775
6828
|
canvas.restore();
|
|
6776
6829
|
Run.end(t);
|
|
6777
6830
|
}
|
|
6778
|
-
__render(bounds,
|
|
6779
|
-
const
|
|
6831
|
+
__render(bounds, realBounds) {
|
|
6832
|
+
const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
|
|
6780
6833
|
if (this.needFill)
|
|
6781
|
-
|
|
6834
|
+
canvas.fillWorld(bounds, this.config.fill);
|
|
6782
6835
|
if (Debug.showRepaint)
|
|
6783
|
-
|
|
6784
|
-
this.target.__render(
|
|
6836
|
+
Debug.drawRepaint(canvas, bounds);
|
|
6837
|
+
this.target.__render(canvas, options);
|
|
6785
6838
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
6786
6839
|
this.renderOptions = options;
|
|
6787
6840
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
if (Debug.showBoundsView)
|
|
6791
|
-
this.renderBoundsView(options);
|
|
6792
|
-
this.canvas.updateRender(realBounds);
|
|
6793
|
-
}
|
|
6794
|
-
renderHitView(_options) { }
|
|
6795
|
-
renderBoundsView(_options) { }
|
|
6841
|
+
canvas.updateRender(realBounds);
|
|
6842
|
+
}
|
|
6796
6843
|
addBlock(block) {
|
|
6797
6844
|
if (!this.updateBlocks)
|
|
6798
6845
|
this.updateBlocks = [];
|
|
@@ -6808,17 +6855,16 @@ class Renderer {
|
|
|
6808
6855
|
}
|
|
6809
6856
|
}
|
|
6810
6857
|
__requestRender() {
|
|
6811
|
-
|
|
6858
|
+
const target = this.target;
|
|
6859
|
+
if (this.requestTime || !target)
|
|
6812
6860
|
return;
|
|
6861
|
+
if (target.parentApp)
|
|
6862
|
+
return target.parentApp.requestRender(false);
|
|
6813
6863
|
const requestTime = this.requestTime = Date.now();
|
|
6814
6864
|
Platform.requestRender(() => {
|
|
6815
6865
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
6816
6866
|
this.requestTime = 0;
|
|
6817
|
-
|
|
6818
|
-
if (this.changed && this.canvas.view)
|
|
6819
|
-
this.render();
|
|
6820
|
-
this.target.emit(RenderEvent.NEXT);
|
|
6821
|
-
}
|
|
6867
|
+
this.checkRender();
|
|
6822
6868
|
});
|
|
6823
6869
|
}
|
|
6824
6870
|
__onResize(e) {
|
|
@@ -6876,6 +6922,7 @@ class Renderer {
|
|
|
6876
6922
|
}
|
|
6877
6923
|
}
|
|
6878
6924
|
}
|
|
6925
|
+
Renderer.clipSpread = 10;
|
|
6879
6926
|
|
|
6880
6927
|
const { hitRadiusPoint } = BoundsHelper;
|
|
6881
6928
|
class Picker {
|
|
@@ -7121,6 +7168,7 @@ class UIData extends LeafData {
|
|
|
7121
7168
|
return strokeWidth;
|
|
7122
7169
|
}
|
|
7123
7170
|
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7171
|
+
get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
|
|
7124
7172
|
get __hasMultiPaint() {
|
|
7125
7173
|
const t = this;
|
|
7126
7174
|
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
@@ -7165,14 +7213,14 @@ class UIData extends LeafData {
|
|
|
7165
7213
|
this.__removeInput('fill');
|
|
7166
7214
|
PaintImage.recycleImage('fill', this);
|
|
7167
7215
|
this.__isFills = false;
|
|
7168
|
-
|
|
7169
|
-
this.__pixelFill = false;
|
|
7216
|
+
this.__pixelFill && (this.__pixelFill = false);
|
|
7170
7217
|
}
|
|
7171
7218
|
this._fill = value;
|
|
7172
7219
|
}
|
|
7173
7220
|
else if (typeof value === 'object') {
|
|
7174
7221
|
this.__setInput('fill', value);
|
|
7175
|
-
|
|
7222
|
+
const layout = this.__leaf.__layout;
|
|
7223
|
+
layout.boxChanged || layout.boxChange();
|
|
7176
7224
|
this.__isFills = true;
|
|
7177
7225
|
this._fill || (this._fill = emptyPaint);
|
|
7178
7226
|
}
|
|
@@ -7183,14 +7231,14 @@ class UIData extends LeafData {
|
|
|
7183
7231
|
this.__removeInput('stroke');
|
|
7184
7232
|
PaintImage.recycleImage('stroke', this);
|
|
7185
7233
|
this.__isStrokes = false;
|
|
7186
|
-
|
|
7187
|
-
this.__pixelStroke = false;
|
|
7234
|
+
this.__pixelStroke && (this.__pixelStroke = false);
|
|
7188
7235
|
}
|
|
7189
7236
|
this._stroke = value;
|
|
7190
7237
|
}
|
|
7191
7238
|
else if (typeof value === 'object') {
|
|
7192
7239
|
this.__setInput('stroke', value);
|
|
7193
|
-
|
|
7240
|
+
const layout = this.__leaf.__layout;
|
|
7241
|
+
layout.boxChanged || layout.boxChange();
|
|
7194
7242
|
this.__isStrokes = true;
|
|
7195
7243
|
this._stroke || (this._stroke = emptyPaint);
|
|
7196
7244
|
}
|
|
@@ -7305,6 +7353,31 @@ class TextData extends UIData {
|
|
|
7305
7353
|
this._fontWeight = value;
|
|
7306
7354
|
}
|
|
7307
7355
|
}
|
|
7356
|
+
setBoxStyle(value) {
|
|
7357
|
+
let t = this.__leaf, box = t.__box;
|
|
7358
|
+
if (value) {
|
|
7359
|
+
const { boxStyle } = this;
|
|
7360
|
+
if (box)
|
|
7361
|
+
for (let key in boxStyle)
|
|
7362
|
+
box[key] = undefined;
|
|
7363
|
+
else
|
|
7364
|
+
box = t.__box = UICreator.get('Rect', 0);
|
|
7365
|
+
const layout = t.__layout, boxLayout = box.__layout;
|
|
7366
|
+
if (!boxStyle)
|
|
7367
|
+
box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
|
|
7368
|
+
box.set(value);
|
|
7369
|
+
if (boxLayout.strokeChanged)
|
|
7370
|
+
layout.strokeChange();
|
|
7371
|
+
if (boxLayout.renderChanged)
|
|
7372
|
+
layout.renderChange();
|
|
7373
|
+
box.__updateChange();
|
|
7374
|
+
}
|
|
7375
|
+
else if (box) {
|
|
7376
|
+
t.__box = box.parent = null;
|
|
7377
|
+
box.destroy();
|
|
7378
|
+
}
|
|
7379
|
+
this._boxStyle = value;
|
|
7380
|
+
}
|
|
7308
7381
|
}
|
|
7309
7382
|
|
|
7310
7383
|
class ImageData extends RectData {
|
|
@@ -7342,7 +7415,7 @@ class CanvasData extends RectData {
|
|
|
7342
7415
|
const UIBounds = {
|
|
7343
7416
|
__updateStrokeSpread() {
|
|
7344
7417
|
let width = 0, boxWidth = 0;
|
|
7345
|
-
const data = this.__, { strokeAlign, strokeWidth } = data;
|
|
7418
|
+
const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
|
|
7346
7419
|
if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
|
|
7347
7420
|
boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
|
|
7348
7421
|
if (!data.__boxStroke) {
|
|
@@ -7353,6 +7426,10 @@ const UIBounds = {
|
|
|
7353
7426
|
}
|
|
7354
7427
|
if (data.__useArrow)
|
|
7355
7428
|
width += strokeWidth * 5;
|
|
7429
|
+
if (box) {
|
|
7430
|
+
width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
|
|
7431
|
+
boxWidth = box.__layout.strokeBoxSpread;
|
|
7432
|
+
}
|
|
7356
7433
|
this.__layout.strokeBoxSpread = boxWidth;
|
|
7357
7434
|
return width;
|
|
7358
7435
|
},
|
|
@@ -7371,25 +7448,26 @@ const UIBounds = {
|
|
|
7371
7448
|
if (backgroundBlur)
|
|
7372
7449
|
shapeWidth = Math.max(shapeWidth, backgroundBlur);
|
|
7373
7450
|
this.__layout.renderShapeSpread = shapeWidth;
|
|
7374
|
-
|
|
7451
|
+
width += this.__layout.strokeSpread || 0;
|
|
7452
|
+
return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
|
|
7375
7453
|
}
|
|
7376
7454
|
};
|
|
7377
7455
|
|
|
7378
7456
|
const UIRender = {
|
|
7379
7457
|
__updateChange() {
|
|
7380
|
-
const data = this.__;
|
|
7458
|
+
const data = this.__, w = this.__world;
|
|
7381
7459
|
if (data.__useEffect) {
|
|
7382
7460
|
const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
|
|
7383
7461
|
data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
|
|
7384
7462
|
}
|
|
7463
|
+
const half = data.__hasHalf;
|
|
7464
|
+
w.half !== half && (w.half = half);
|
|
7385
7465
|
data.__checkSingle();
|
|
7386
7466
|
const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
|
|
7387
|
-
if (complex)
|
|
7467
|
+
if (complex)
|
|
7388
7468
|
data.__complex = true;
|
|
7389
|
-
|
|
7390
|
-
else {
|
|
7469
|
+
else
|
|
7391
7470
|
data.__complex && (data.__complex = false);
|
|
7392
|
-
}
|
|
7393
7471
|
},
|
|
7394
7472
|
__drawFast(canvas, options) {
|
|
7395
7473
|
drawFast(this, canvas, options);
|
|
@@ -7476,10 +7554,11 @@ function drawFast(ui, canvas, options) {
|
|
|
7476
7554
|
|
|
7477
7555
|
const RectRender = {
|
|
7478
7556
|
__drawFast(canvas, options) {
|
|
7479
|
-
let {
|
|
7557
|
+
let { x, y, width, height } = this.__layout.boxBounds;
|
|
7558
|
+
const { fill, stroke, __drawAfterFill } = this.__;
|
|
7480
7559
|
if (fill) {
|
|
7481
7560
|
canvas.fillStyle = fill;
|
|
7482
|
-
canvas.fillRect(
|
|
7561
|
+
canvas.fillRect(x, y, width, height);
|
|
7483
7562
|
}
|
|
7484
7563
|
if (__drawAfterFill)
|
|
7485
7564
|
this.__drawAfterFill(canvas, options);
|
|
@@ -7498,14 +7577,14 @@ const RectRender = {
|
|
|
7498
7577
|
if (width < 0 || height < 0) {
|
|
7499
7578
|
canvas.save();
|
|
7500
7579
|
this.__clip(canvas, options);
|
|
7501
|
-
canvas.strokeRect(half, half, width, height);
|
|
7580
|
+
canvas.strokeRect(x + half, y + half, width, height);
|
|
7502
7581
|
canvas.restore();
|
|
7503
7582
|
}
|
|
7504
7583
|
else
|
|
7505
|
-
canvas.strokeRect(half, half, width, height);
|
|
7584
|
+
canvas.strokeRect(x + half, y + half, width, height);
|
|
7506
7585
|
break;
|
|
7507
7586
|
case 'outside':
|
|
7508
|
-
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
|
|
7587
|
+
canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
|
|
7509
7588
|
break;
|
|
7510
7589
|
}
|
|
7511
7590
|
}
|
|
@@ -7661,6 +7740,12 @@ __decorate([
|
|
|
7661
7740
|
__decorate([
|
|
7662
7741
|
surfaceType(false)
|
|
7663
7742
|
], UI.prototype, "locked", void 0);
|
|
7743
|
+
__decorate([
|
|
7744
|
+
surfaceType(false)
|
|
7745
|
+
], UI.prototype, "dim", void 0);
|
|
7746
|
+
__decorate([
|
|
7747
|
+
surfaceType(false)
|
|
7748
|
+
], UI.prototype, "dimskip", void 0);
|
|
7664
7749
|
__decorate([
|
|
7665
7750
|
sortType(0)
|
|
7666
7751
|
], UI.prototype, "zIndex", void 0);
|
|
@@ -7922,7 +8007,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7922
8007
|
start: true,
|
|
7923
8008
|
hittable: true,
|
|
7924
8009
|
smooth: true,
|
|
7925
|
-
lazySpeard: 100
|
|
8010
|
+
lazySpeard: 100,
|
|
7926
8011
|
};
|
|
7927
8012
|
this.leafs = 0;
|
|
7928
8013
|
this.__eventIds = [];
|
|
@@ -8346,13 +8431,13 @@ let Box = class Box extends Group {
|
|
|
8346
8431
|
super.__updateRenderBounds();
|
|
8347
8432
|
copy$3(childrenRenderBounds, renderBounds);
|
|
8348
8433
|
this.__updateRectRenderBounds();
|
|
8349
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds);
|
|
8434
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
|
|
8350
8435
|
if (isOverflow && this.__.overflow !== 'hide')
|
|
8351
8436
|
add(renderBounds, childrenRenderBounds);
|
|
8352
8437
|
}
|
|
8353
8438
|
else
|
|
8354
8439
|
this.__updateRectRenderBounds();
|
|
8355
|
-
|
|
8440
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8356
8441
|
}
|
|
8357
8442
|
__updateRectRenderBounds() { }
|
|
8358
8443
|
__updateRectChange() { }
|
|
@@ -8760,33 +8845,13 @@ Canvas = __decorate([
|
|
|
8760
8845
|
registerUI()
|
|
8761
8846
|
], Canvas);
|
|
8762
8847
|
|
|
8763
|
-
const { copyAndSpread, includes,
|
|
8848
|
+
const { copyAndSpread, includes, spread, setList } = BoundsHelper;
|
|
8764
8849
|
let Text = class Text extends UI {
|
|
8765
8850
|
get __tag() { return 'Text'; }
|
|
8766
|
-
get textDrawData() {
|
|
8767
|
-
this.__layout.update();
|
|
8768
|
-
return this.__.__textDrawData;
|
|
8769
|
-
}
|
|
8851
|
+
get textDrawData() { this.updateLayout(); return this.__.__textDrawData; }
|
|
8770
8852
|
constructor(data) {
|
|
8771
8853
|
super(data);
|
|
8772
8854
|
}
|
|
8773
|
-
__drawHitPath(canvas) {
|
|
8774
|
-
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8775
|
-
canvas.beginPath();
|
|
8776
|
-
if (this.__.__letterSpacing < 0) {
|
|
8777
|
-
this.__drawPathByData(canvas);
|
|
8778
|
-
}
|
|
8779
|
-
else {
|
|
8780
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8781
|
-
}
|
|
8782
|
-
}
|
|
8783
|
-
__drawPathByData(drawer, _data) {
|
|
8784
|
-
const { x, y, width, height } = this.__layout.boxBounds;
|
|
8785
|
-
drawer.rect(x, y, width, height);
|
|
8786
|
-
}
|
|
8787
|
-
__drawRenderPath(canvas) {
|
|
8788
|
-
canvas.font = this.__.__font;
|
|
8789
|
-
}
|
|
8790
8855
|
__updateTextDrawData() {
|
|
8791
8856
|
const data = this.__;
|
|
8792
8857
|
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
@@ -8803,15 +8868,16 @@ let Text = class Text extends UI {
|
|
|
8803
8868
|
const layout = this.__layout;
|
|
8804
8869
|
const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data;
|
|
8805
8870
|
this.__updateTextDrawData();
|
|
8806
|
-
const { bounds } = data.__textDrawData;
|
|
8871
|
+
const { bounds: contentBounds } = data.__textDrawData;
|
|
8807
8872
|
const b = layout.boxBounds;
|
|
8873
|
+
layout.contentBounds = contentBounds;
|
|
8808
8874
|
if (data.__lineHeight < fontSize)
|
|
8809
|
-
spread(
|
|
8875
|
+
spread(contentBounds, fontSize / 2);
|
|
8810
8876
|
if (autoWidth || autoHeight) {
|
|
8811
|
-
b.x = autoWidth ?
|
|
8812
|
-
b.y = autoHeight ?
|
|
8813
|
-
b.width = autoWidth ?
|
|
8814
|
-
b.height = autoHeight ?
|
|
8877
|
+
b.x = autoWidth ? contentBounds.x : 0;
|
|
8878
|
+
b.y = autoHeight ? contentBounds.y : 0;
|
|
8879
|
+
b.width = autoWidth ? contentBounds.width : data.width;
|
|
8880
|
+
b.height = autoHeight ? contentBounds.height : data.height;
|
|
8815
8881
|
if (padding) {
|
|
8816
8882
|
const [top, right, bottom, left] = data.__padding;
|
|
8817
8883
|
if (autoWidth)
|
|
@@ -8825,23 +8891,45 @@ let Text = class Text extends UI {
|
|
|
8825
8891
|
super.__updateBoxBounds();
|
|
8826
8892
|
if (italic)
|
|
8827
8893
|
b.width += fontSize * 0.16;
|
|
8828
|
-
const
|
|
8829
|
-
if (
|
|
8830
|
-
|
|
8831
|
-
layout.renderChanged = true;
|
|
8832
|
-
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
8833
|
-
}
|
|
8894
|
+
const isOverflow = !includes(b, contentBounds) || undefined;
|
|
8895
|
+
if (isOverflow)
|
|
8896
|
+
setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
|
|
8834
8897
|
else
|
|
8835
|
-
data.__textBoxBounds =
|
|
8898
|
+
data.__textBoxBounds = b;
|
|
8899
|
+
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8900
|
+
}
|
|
8901
|
+
__onUpdateSize() {
|
|
8902
|
+
if (this.__box)
|
|
8903
|
+
this.__box.__onUpdateSize();
|
|
8904
|
+
super.__onUpdateSize();
|
|
8836
8905
|
}
|
|
8837
8906
|
__updateRenderSpread() {
|
|
8838
8907
|
let width = super.__updateRenderSpread();
|
|
8839
8908
|
if (!width)
|
|
8840
|
-
width = this.
|
|
8909
|
+
width = this.isOverflow ? 1 : 0;
|
|
8841
8910
|
return width;
|
|
8842
8911
|
}
|
|
8843
8912
|
__updateRenderBounds() {
|
|
8844
|
-
|
|
8913
|
+
const { renderBounds, renderSpread } = this.__layout;
|
|
8914
|
+
copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
|
|
8915
|
+
if (this.__box)
|
|
8916
|
+
this.__box.__layout.renderBounds = renderBounds;
|
|
8917
|
+
}
|
|
8918
|
+
__drawRenderPath(canvas) {
|
|
8919
|
+
canvas.font = this.__.__font;
|
|
8920
|
+
}
|
|
8921
|
+
__draw(canvas, options, originCanvas) {
|
|
8922
|
+
const box = this.__box;
|
|
8923
|
+
if (box)
|
|
8924
|
+
box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
|
|
8925
|
+
if (this.textEditing && !Export.running)
|
|
8926
|
+
return;
|
|
8927
|
+
super.__draw(canvas, options, originCanvas);
|
|
8928
|
+
}
|
|
8929
|
+
destroy() {
|
|
8930
|
+
if (this.boxStyle)
|
|
8931
|
+
this.boxStyle = null;
|
|
8932
|
+
super.destroy();
|
|
8845
8933
|
}
|
|
8846
8934
|
};
|
|
8847
8935
|
__decorate([
|
|
@@ -8853,6 +8941,9 @@ __decorate([
|
|
|
8853
8941
|
__decorate([
|
|
8854
8942
|
boundsType(0)
|
|
8855
8943
|
], Text.prototype, "height", void 0);
|
|
8944
|
+
__decorate([
|
|
8945
|
+
surfaceType()
|
|
8946
|
+
], Text.prototype, "boxStyle", void 0);
|
|
8856
8947
|
__decorate([
|
|
8857
8948
|
dataType(false)
|
|
8858
8949
|
], Text.prototype, "resizeFontSize", void 0);
|
|
@@ -9016,26 +9107,25 @@ let App = class App extends Leafer {
|
|
|
9016
9107
|
this.leafer = this;
|
|
9017
9108
|
this.watcher.disable();
|
|
9018
9109
|
this.layouter.disable();
|
|
9019
|
-
this.__eventIds.push(this.on_(PropertyEvent.CHANGE, this.__onPropertyChange, this));
|
|
9020
9110
|
}
|
|
9021
9111
|
start() {
|
|
9022
9112
|
super.start();
|
|
9023
|
-
this.
|
|
9113
|
+
this.forEach(leafer => leafer.start());
|
|
9024
9114
|
}
|
|
9025
9115
|
stop() {
|
|
9026
|
-
this.
|
|
9116
|
+
this.forEach(leafer => leafer.stop());
|
|
9027
9117
|
super.stop();
|
|
9028
9118
|
}
|
|
9029
9119
|
unlockLayout() {
|
|
9030
9120
|
super.unlockLayout();
|
|
9031
|
-
this.
|
|
9121
|
+
this.forEach(leafer => leafer.unlockLayout());
|
|
9032
9122
|
}
|
|
9033
9123
|
lockLayout() {
|
|
9034
9124
|
super.lockLayout();
|
|
9035
|
-
this.
|
|
9125
|
+
this.forEach(leafer => leafer.lockLayout());
|
|
9036
9126
|
}
|
|
9037
9127
|
forceRender(bounds, sync) {
|
|
9038
|
-
this.
|
|
9128
|
+
this.forEach(leafer => leafer.forceRender(bounds, sync));
|
|
9039
9129
|
}
|
|
9040
9130
|
addLeafer(merge) {
|
|
9041
9131
|
const leafer = new Leafer(merge);
|
|
@@ -9055,9 +9145,8 @@ let App = class App extends Leafer {
|
|
|
9055
9145
|
leafer.canvas.childIndex = index;
|
|
9056
9146
|
this.__listenChildEvents(leafer);
|
|
9057
9147
|
}
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
this.children.forEach(leafer => leafer.forceUpdate('surface'));
|
|
9148
|
+
forEach(fn) {
|
|
9149
|
+
this.children.forEach(fn);
|
|
9061
9150
|
}
|
|
9062
9151
|
__onCreated() {
|
|
9063
9152
|
this.created = this.children.every(child => child.created);
|
|
@@ -9080,18 +9169,18 @@ let App = class App extends Leafer {
|
|
|
9080
9169
|
const m = options.matrix;
|
|
9081
9170
|
if (m)
|
|
9082
9171
|
canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
9083
|
-
this.
|
|
9172
|
+
this.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
9084
9173
|
}
|
|
9085
9174
|
}
|
|
9086
9175
|
__onResize(event) {
|
|
9087
|
-
this.
|
|
9176
|
+
this.forEach(leafer => leafer.resize(event));
|
|
9088
9177
|
super.__onResize(event);
|
|
9089
9178
|
}
|
|
9090
9179
|
updateLayout() {
|
|
9091
|
-
this.
|
|
9180
|
+
this.forEach(leafer => leafer.updateLayout());
|
|
9092
9181
|
}
|
|
9093
9182
|
__getChildConfig(userConfig) {
|
|
9094
|
-
|
|
9183
|
+
const config = Object.assign({}, this.config);
|
|
9095
9184
|
config.hittable = config.realCanvas = undefined;
|
|
9096
9185
|
if (userConfig)
|
|
9097
9186
|
DataHelper.assign(config, userConfig);
|
|
@@ -9650,6 +9739,7 @@ const config = {
|
|
|
9650
9739
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9651
9740
|
},
|
|
9652
9741
|
pointer: {
|
|
9742
|
+
snap: true,
|
|
9653
9743
|
hitRadius: 5,
|
|
9654
9744
|
tapTime: 120,
|
|
9655
9745
|
longPressTime: 800,
|
|
@@ -9744,8 +9834,7 @@ class InteractionBase {
|
|
|
9744
9834
|
if (this.downData) {
|
|
9745
9835
|
const canDrag = PointHelper.getDistance(this.downData, data) > this.p.dragDistance;
|
|
9746
9836
|
if (canDrag) {
|
|
9747
|
-
|
|
9748
|
-
this.pointerWaitCancel();
|
|
9837
|
+
this.pointerWaitCancel();
|
|
9749
9838
|
this.waitRightTap = false;
|
|
9750
9839
|
}
|
|
9751
9840
|
this.dragger.checkDrag(data, canDrag);
|
|
@@ -10005,7 +10094,10 @@ class InteractionBase {
|
|
|
10005
10094
|
}
|
|
10006
10095
|
getLocal(clientPoint, updateClient) {
|
|
10007
10096
|
const clientBounds = this.canvas.getClientBounds(updateClient);
|
|
10008
|
-
|
|
10097
|
+
const point = { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y };
|
|
10098
|
+
if (this.p.snap)
|
|
10099
|
+
PointHelper.round(point);
|
|
10100
|
+
return point;
|
|
10009
10101
|
}
|
|
10010
10102
|
emitTap(data) {
|
|
10011
10103
|
this.emit(PointerEvent.TAP, data);
|
|
@@ -10024,9 +10116,11 @@ class InteractionBase {
|
|
|
10024
10116
|
this.waitTap = true;
|
|
10025
10117
|
}
|
|
10026
10118
|
tapWaitCancel() {
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10119
|
+
if (this.waitTap) {
|
|
10120
|
+
clearTimeout(this.tapTimer);
|
|
10121
|
+
this.waitTap = false;
|
|
10122
|
+
this.tapCount = 0;
|
|
10123
|
+
}
|
|
10030
10124
|
}
|
|
10031
10125
|
longPressWait(data) {
|
|
10032
10126
|
clearTimeout(this.longPressTimer);
|
|
@@ -10046,8 +10140,10 @@ class InteractionBase {
|
|
|
10046
10140
|
return hasLong;
|
|
10047
10141
|
}
|
|
10048
10142
|
longPressWaitCancel() {
|
|
10049
|
-
|
|
10050
|
-
|
|
10143
|
+
if (this.longPressTimer) {
|
|
10144
|
+
clearTimeout(this.longPressTimer);
|
|
10145
|
+
this.longPressed = false;
|
|
10146
|
+
}
|
|
10051
10147
|
}
|
|
10052
10148
|
__onResize() {
|
|
10053
10149
|
const { dragOut } = this.m;
|
|
@@ -10137,25 +10233,26 @@ const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
|
|
|
10137
10233
|
const inner = {};
|
|
10138
10234
|
const leaf = Leaf.prototype;
|
|
10139
10235
|
leaf.__hitWorld = function (point) {
|
|
10140
|
-
|
|
10236
|
+
const data = this.__;
|
|
10237
|
+
if (!data.hitSelf)
|
|
10141
10238
|
return false;
|
|
10142
|
-
|
|
10239
|
+
const world = this.__world, layout = this.__layout;
|
|
10240
|
+
const isSmall = world.width < 10 && world.height < 10;
|
|
10241
|
+
if (data.hitRadius) {
|
|
10143
10242
|
copy$2(inner, point), point = inner;
|
|
10144
|
-
setRadius(point,
|
|
10243
|
+
setRadius(point, data.hitRadius);
|
|
10145
10244
|
}
|
|
10146
|
-
toInnerRadiusPointOf(point,
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
if (this.__.hitBox || isSmall) {
|
|
10150
|
-
if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
|
|
10245
|
+
toInnerRadiusPointOf(point, world, inner);
|
|
10246
|
+
if (data.hitBox || isSmall) {
|
|
10247
|
+
if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
|
|
10151
10248
|
return true;
|
|
10152
10249
|
if (isSmall)
|
|
10153
10250
|
return false;
|
|
10154
10251
|
}
|
|
10155
|
-
if (
|
|
10252
|
+
if (layout.hitCanvasChanged || !this.__hitCanvas) {
|
|
10156
10253
|
this.__updateHitCanvas();
|
|
10157
|
-
if (!
|
|
10158
|
-
|
|
10254
|
+
if (!layout.boundsChanged)
|
|
10255
|
+
layout.hitCanvasChanged = false;
|
|
10159
10256
|
}
|
|
10160
10257
|
return this.__hit(inner);
|
|
10161
10258
|
};
|
|
@@ -10168,7 +10265,9 @@ leaf.__drawHitPath = function (canvas) { if (canvas)
|
|
|
10168
10265
|
const matrix = new Matrix();
|
|
10169
10266
|
const ui$1 = UI.prototype;
|
|
10170
10267
|
ui$1.__updateHitCanvas = function () {
|
|
10171
|
-
|
|
10268
|
+
if (this.__box)
|
|
10269
|
+
this.__box.__updateHitCanvas();
|
|
10270
|
+
const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
|
|
10172
10271
|
const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
10173
10272
|
const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
|
|
10174
10273
|
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
@@ -10195,6 +10294,8 @@ ui$1.__updateHitCanvas = function () {
|
|
|
10195
10294
|
h.setStrokeOptions(data);
|
|
10196
10295
|
};
|
|
10197
10296
|
ui$1.__hit = function (inner) {
|
|
10297
|
+
if (this.__box && this.__box.__hit(inner))
|
|
10298
|
+
return true;
|
|
10198
10299
|
const data = this.__;
|
|
10199
10300
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
10200
10301
|
return true;
|
|
@@ -10243,6 +10344,15 @@ rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
|
10243
10344
|
return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10244
10345
|
};
|
|
10245
10346
|
|
|
10347
|
+
Text.prototype.__drawHitPath = function (canvas) {
|
|
10348
|
+
const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
|
|
10349
|
+
canvas.beginPath();
|
|
10350
|
+
if (__letterSpacing < 0)
|
|
10351
|
+
this.__drawPathByBox(canvas);
|
|
10352
|
+
else
|
|
10353
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
10354
|
+
};
|
|
10355
|
+
|
|
10246
10356
|
function getSelector(ui) {
|
|
10247
10357
|
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
10248
10358
|
}
|
|
@@ -10730,9 +10840,11 @@ const tempBox = new Bounds();
|
|
|
10730
10840
|
const tempPoint = {};
|
|
10731
10841
|
const tempScaleData = {};
|
|
10732
10842
|
function createData(leafPaint, image, paint, box) {
|
|
10733
|
-
const { blendMode, sync } = paint;
|
|
10843
|
+
const { blendMode, changeful, sync } = paint;
|
|
10734
10844
|
if (blendMode)
|
|
10735
10845
|
leafPaint.blendMode = blendMode;
|
|
10846
|
+
if (changeful)
|
|
10847
|
+
leafPaint.changeful = changeful;
|
|
10736
10848
|
if (sync)
|
|
10737
10849
|
leafPaint.sync = sync;
|
|
10738
10850
|
leafPaint.data = getPatternData(paint, box, image);
|
|
@@ -10965,40 +11077,32 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
10965
11077
|
}
|
|
10966
11078
|
|
|
10967
11079
|
const { abs } = Math;
|
|
10968
|
-
function checkImage(ui, canvas, paint,
|
|
11080
|
+
function checkImage(ui, canvas, paint, allowDraw) {
|
|
10969
11081
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
10970
|
-
const { pixelRatio } = canvas;
|
|
10971
|
-
if (!
|
|
11082
|
+
const { pixelRatio } = canvas, { data } = paint;
|
|
11083
|
+
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
10972
11084
|
return false;
|
|
10973
11085
|
}
|
|
10974
11086
|
else {
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
let { width, height } = data;
|
|
10979
|
-
width *= abs(scaleX) * pixelRatio;
|
|
10980
|
-
height *= abs(scaleY) * pixelRatio;
|
|
10981
|
-
if (data.scaleX) {
|
|
10982
|
-
width *= data.scaleX;
|
|
10983
|
-
height *= data.scaleY;
|
|
10984
|
-
}
|
|
10985
|
-
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
11087
|
+
if (allowDraw) {
|
|
11088
|
+
if (data.repeat) {
|
|
11089
|
+
allowDraw = false;
|
|
10986
11090
|
}
|
|
10987
11091
|
else {
|
|
10988
|
-
|
|
11092
|
+
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
11093
|
+
let { width, height } = data;
|
|
11094
|
+
width *= abs(scaleX) * pixelRatio;
|
|
11095
|
+
height *= abs(scaleY) * pixelRatio;
|
|
11096
|
+
if (data.scaleX) {
|
|
11097
|
+
width *= data.scaleX;
|
|
11098
|
+
height *= data.scaleY;
|
|
11099
|
+
}
|
|
11100
|
+
allowDraw = (width * height > Platform.image.maxCacheSize);
|
|
11101
|
+
}
|
|
10989
11102
|
}
|
|
10990
11103
|
}
|
|
10991
|
-
if (
|
|
10992
|
-
canvas
|
|
10993
|
-
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
10994
|
-
if (paint.blendMode)
|
|
10995
|
-
canvas.blendMode = paint.blendMode;
|
|
10996
|
-
if (data.opacity)
|
|
10997
|
-
canvas.opacity *= data.opacity;
|
|
10998
|
-
if (data.transform)
|
|
10999
|
-
canvas.transform(data.transform);
|
|
11000
|
-
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
11001
|
-
canvas.restore();
|
|
11104
|
+
if (allowDraw) {
|
|
11105
|
+
drawImage(ui, canvas, paint, data);
|
|
11002
11106
|
return true;
|
|
11003
11107
|
}
|
|
11004
11108
|
else {
|
|
@@ -11019,13 +11123,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
11019
11123
|
}
|
|
11020
11124
|
}
|
|
11021
11125
|
}
|
|
11126
|
+
function drawImage(ui, canvas, paint, data) {
|
|
11127
|
+
canvas.save();
|
|
11128
|
+
ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
|
|
11129
|
+
if (paint.blendMode)
|
|
11130
|
+
canvas.blendMode = paint.blendMode;
|
|
11131
|
+
if (data.opacity)
|
|
11132
|
+
canvas.opacity *= data.opacity;
|
|
11133
|
+
if (data.transform)
|
|
11134
|
+
canvas.transform(data.transform);
|
|
11135
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
11136
|
+
canvas.restore();
|
|
11137
|
+
}
|
|
11022
11138
|
|
|
11023
11139
|
function recycleImage(attrName, data) {
|
|
11024
11140
|
const paints = data['_' + attrName];
|
|
11025
11141
|
if (paints instanceof Array) {
|
|
11026
|
-
let image, recycleMap, input, url;
|
|
11142
|
+
let paint, image, recycleMap, input, url;
|
|
11027
11143
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
11028
|
-
|
|
11144
|
+
paint = paints[i];
|
|
11145
|
+
image = paint.image;
|
|
11029
11146
|
url = image && image.url;
|
|
11030
11147
|
if (url) {
|
|
11031
11148
|
if (!recycleMap)
|
|
@@ -11040,8 +11157,6 @@ function recycleImage(attrName, data) {
|
|
|
11040
11157
|
}
|
|
11041
11158
|
image.unload(paints[i].loadId, !input.some((item) => item.url === url));
|
|
11042
11159
|
}
|
|
11043
|
-
else
|
|
11044
|
-
paints[i].style = null;
|
|
11045
11160
|
}
|
|
11046
11161
|
}
|
|
11047
11162
|
return recycleMap;
|
|
@@ -11220,7 +11335,7 @@ const { toOffsetOutBounds } = BoundsHelper;
|
|
|
11220
11335
|
const offsetOutBounds = {};
|
|
11221
11336
|
function innerShadow(ui, current, shape) {
|
|
11222
11337
|
let copyBounds, spreadScale;
|
|
11223
|
-
const { __nowWorld: nowWorld, __layout
|
|
11338
|
+
const { __nowWorld: nowWorld, __layout } = ui;
|
|
11224
11339
|
const { innerShadow } = ui.__;
|
|
11225
11340
|
const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
|
|
11226
11341
|
const other = current.getSameCanvas();
|