leafer-ui 1.0.0 → 1.0.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 +8 -2
- package/dist/web.esm.js +58 -39
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +142 -81
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +142 -81
- package/dist/web.module.min.js +1 -1
- package/package.json +11 -11
package/dist/web.module.js
CHANGED
|
@@ -48,6 +48,8 @@ const I$2 = IncrementId;
|
|
|
48
48
|
const { round, pow: pow$1, PI: PI$4 } = Math;
|
|
49
49
|
const MathHelper = {
|
|
50
50
|
within(value, min, max) {
|
|
51
|
+
if (typeof min === 'object')
|
|
52
|
+
max = min.max, min = min.min;
|
|
51
53
|
if (min !== undefined && value < min)
|
|
52
54
|
value = min;
|
|
53
55
|
if (max !== undefined && value > max)
|
|
@@ -150,10 +152,10 @@ const MatrixHelper = {
|
|
|
150
152
|
t.e += x;
|
|
151
153
|
t.f += y;
|
|
152
154
|
},
|
|
153
|
-
translateInner(t, x, y,
|
|
155
|
+
translateInner(t, x, y, hasOrigin) {
|
|
154
156
|
t.e += t.a * x + t.c * y;
|
|
155
157
|
t.f += t.b * x + t.d * y;
|
|
156
|
-
if (
|
|
158
|
+
if (hasOrigin)
|
|
157
159
|
t.e -= x, t.f -= y;
|
|
158
160
|
},
|
|
159
161
|
scale(t, scaleX, scaleY = scaleX) {
|
|
@@ -312,7 +314,7 @@ const MatrixHelper = {
|
|
|
312
314
|
to.y -= (f * a - e * b) * s;
|
|
313
315
|
}
|
|
314
316
|
},
|
|
315
|
-
setLayout(t, layout, origin, bcChanged) {
|
|
317
|
+
setLayout(t, layout, origin, around, bcChanged) {
|
|
316
318
|
const { x, y, scaleX, scaleY } = layout;
|
|
317
319
|
if (bcChanged === undefined)
|
|
318
320
|
bcChanged = layout.rotation || layout.skewX || layout.skewY;
|
|
@@ -344,10 +346,10 @@ const MatrixHelper = {
|
|
|
344
346
|
}
|
|
345
347
|
t.e = x;
|
|
346
348
|
t.f = y;
|
|
347
|
-
if (origin)
|
|
348
|
-
M$6.translateInner(t, -origin.x, -origin.y,
|
|
349
|
+
if (origin = origin || around)
|
|
350
|
+
M$6.translateInner(t, -origin.x, -origin.y, !around);
|
|
349
351
|
},
|
|
350
|
-
getLayout(t, origin, firstSkewY) {
|
|
352
|
+
getLayout(t, origin, around, firstSkewY) {
|
|
351
353
|
const { a, b, c, d, e, f } = t;
|
|
352
354
|
let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
|
|
353
355
|
if (b || c) {
|
|
@@ -376,9 +378,11 @@ const MatrixHelper = {
|
|
|
376
378
|
scaleY = d;
|
|
377
379
|
rotation = skewX = skewY = 0;
|
|
378
380
|
}
|
|
379
|
-
if (origin) {
|
|
381
|
+
if (origin = around || origin) {
|
|
380
382
|
x += origin.x * a + origin.y * c;
|
|
381
383
|
y += origin.x * b + origin.y * d;
|
|
384
|
+
if (!around)
|
|
385
|
+
x -= origin.x, y -= origin.y;
|
|
382
386
|
}
|
|
383
387
|
return { x, y, scaleX, scaleY, rotation, skewX, skewY };
|
|
384
388
|
},
|
|
@@ -706,12 +710,12 @@ class Matrix {
|
|
|
706
710
|
toInnerPoint(outer, to, distance) {
|
|
707
711
|
MatrixHelper.toInnerPoint(this, outer, to, distance);
|
|
708
712
|
}
|
|
709
|
-
setLayout(data, origin) {
|
|
710
|
-
MatrixHelper.setLayout(this, data, origin);
|
|
713
|
+
setLayout(data, origin, around) {
|
|
714
|
+
MatrixHelper.setLayout(this, data, origin, around);
|
|
711
715
|
return this;
|
|
712
716
|
}
|
|
713
|
-
getLayout(origin, firstSkewY) {
|
|
714
|
-
return MatrixHelper.getLayout(this, origin, firstSkewY);
|
|
717
|
+
getLayout(origin, around, firstSkewY) {
|
|
718
|
+
return MatrixHelper.getLayout(this, origin, around, firstSkewY);
|
|
715
719
|
}
|
|
716
720
|
withScale(scaleX, scaleY) {
|
|
717
721
|
return MatrixHelper.withScale(this, scaleX, scaleY);
|
|
@@ -1999,7 +2003,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
1999
2003
|
DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
|
|
2000
2004
|
this.size.pixelRatio || (this.size.pixelRatio = 1);
|
|
2001
2005
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2002
|
-
if (!this.unreal) {
|
|
2006
|
+
if (this.context && !this.unreal) {
|
|
2003
2007
|
this.updateViewSize();
|
|
2004
2008
|
this.smooth = this.config.smooth;
|
|
2005
2009
|
}
|
|
@@ -2172,7 +2176,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2172
2176
|
this.manager ? this.manager.recycle(this) : this.destroy();
|
|
2173
2177
|
}
|
|
2174
2178
|
}
|
|
2175
|
-
updateRender() { }
|
|
2179
|
+
updateRender(_bounds) { }
|
|
2176
2180
|
unrealCanvas() { }
|
|
2177
2181
|
destroy() {
|
|
2178
2182
|
this.manager = this.view = this.parentView = null;
|
|
@@ -4066,8 +4070,13 @@ const LeafHelper = {
|
|
|
4066
4070
|
zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
|
|
4067
4071
|
copy$7(matrix$1, t.__localMatrix);
|
|
4068
4072
|
scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
|
|
4069
|
-
|
|
4070
|
-
|
|
4073
|
+
if (t.origin || t.around) {
|
|
4074
|
+
L.setTransform(t, matrix$1, resize);
|
|
4075
|
+
}
|
|
4076
|
+
else {
|
|
4077
|
+
moveByMatrix(t, matrix$1);
|
|
4078
|
+
t.scaleResize(scaleX, scaleY, resize !== true);
|
|
4079
|
+
}
|
|
4071
4080
|
},
|
|
4072
4081
|
rotateOfWorld(t, origin, angle) {
|
|
4073
4082
|
L.rotateOfLocal(t, getTempLocal(t, origin), angle);
|
|
@@ -4075,8 +4084,13 @@ const LeafHelper = {
|
|
|
4075
4084
|
rotateOfLocal(t, origin, angle) {
|
|
4076
4085
|
copy$7(matrix$1, t.__localMatrix);
|
|
4077
4086
|
rotateOfOuter$2(matrix$1, origin, angle);
|
|
4078
|
-
|
|
4079
|
-
|
|
4087
|
+
if (t.origin || t.around) {
|
|
4088
|
+
L.setTransform(t, matrix$1);
|
|
4089
|
+
}
|
|
4090
|
+
else {
|
|
4091
|
+
moveByMatrix(t, matrix$1);
|
|
4092
|
+
t.rotation = MathHelper.formatRotation(t.rotation + angle);
|
|
4093
|
+
}
|
|
4080
4094
|
},
|
|
4081
4095
|
skewOfWorld(t, origin, skewX, skewY, resize) {
|
|
4082
4096
|
L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
|
|
@@ -4099,7 +4113,7 @@ const LeafHelper = {
|
|
|
4099
4113
|
L.setTransform(t, matrix$1, resize);
|
|
4100
4114
|
},
|
|
4101
4115
|
setTransform(t, transform, resize) {
|
|
4102
|
-
const layout = getLayout(transform);
|
|
4116
|
+
const layout = getLayout(transform, t.origin && L.getInnerOrigin(t, t.origin), t.around && L.getInnerOrigin(t, t.around));
|
|
4103
4117
|
if (resize) {
|
|
4104
4118
|
const scaleX = layout.scaleX / t.scaleX;
|
|
4105
4119
|
const scaleY = layout.scaleY / t.scaleY;
|
|
@@ -4112,13 +4126,19 @@ const LeafHelper = {
|
|
|
4112
4126
|
t.set(layout);
|
|
4113
4127
|
}
|
|
4114
4128
|
},
|
|
4129
|
+
getFlipTransform(t, axis) {
|
|
4130
|
+
const m = getMatrixData();
|
|
4131
|
+
const sign = axis === 'x' ? 1 : -1;
|
|
4132
|
+
scaleOfOuter$2(m, L.getLocalOrigin(t, 'center'), -1 * sign, 1 * sign);
|
|
4133
|
+
return m;
|
|
4134
|
+
},
|
|
4115
4135
|
getLocalOrigin(t, origin) {
|
|
4116
4136
|
return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
|
|
4117
4137
|
},
|
|
4118
4138
|
getInnerOrigin(t, origin) {
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
return
|
|
4139
|
+
const innerOrigin = {};
|
|
4140
|
+
AroundHelper.toPoint(origin, t.boxBounds, innerOrigin);
|
|
4141
|
+
return innerOrigin;
|
|
4122
4142
|
},
|
|
4123
4143
|
getRelativeWorld(t, relative, temp) {
|
|
4124
4144
|
copy$7(matrix$1, t.worldTransform);
|
|
@@ -4545,7 +4565,10 @@ const LeafEventer = {
|
|
|
4545
4565
|
on(type, listener, options) {
|
|
4546
4566
|
let capture, once;
|
|
4547
4567
|
if (options) {
|
|
4548
|
-
if (
|
|
4568
|
+
if (options === 'once') {
|
|
4569
|
+
once = true;
|
|
4570
|
+
}
|
|
4571
|
+
else if (typeof options === 'boolean') {
|
|
4549
4572
|
capture = options;
|
|
4550
4573
|
}
|
|
4551
4574
|
else {
|
|
@@ -4576,7 +4599,7 @@ const LeafEventer = {
|
|
|
4576
4599
|
if (listener) {
|
|
4577
4600
|
let capture;
|
|
4578
4601
|
if (options)
|
|
4579
|
-
capture = typeof options === 'boolean' ? options : options.capture;
|
|
4602
|
+
capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
|
|
4580
4603
|
let events, index;
|
|
4581
4604
|
const map = __getListenerMap(this, capture);
|
|
4582
4605
|
typeList.forEach(type => {
|
|
@@ -4878,7 +4901,7 @@ const LeafMatrix = {
|
|
|
4878
4901
|
const layout = this.__layout, local = this.__local, data = this.__;
|
|
4879
4902
|
if (layout.affectScaleOrRotation) {
|
|
4880
4903
|
if (layout.scaleChanged || layout.rotationChanged) {
|
|
4881
|
-
setLayout(local, data, null, layout.affectRotation);
|
|
4904
|
+
setLayout(local, data, null, null, layout.affectRotation);
|
|
4882
4905
|
layout.scaleChanged = layout.rotationChanged = false;
|
|
4883
4906
|
}
|
|
4884
4907
|
}
|
|
@@ -4886,7 +4909,7 @@ const LeafMatrix = {
|
|
|
4886
4909
|
local.f = data.y + data.offsetY;
|
|
4887
4910
|
if (data.around || data.origin) {
|
|
4888
4911
|
toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
|
|
4889
|
-
translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.
|
|
4912
|
+
translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
|
|
4890
4913
|
}
|
|
4891
4914
|
}
|
|
4892
4915
|
this.__layout.matrixChanged = false;
|
|
@@ -5115,7 +5138,7 @@ const { LEAF, create } = IncrementId;
|
|
|
5115
5138
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5116
5139
|
const { toOuterOf } = BoundsHelper;
|
|
5117
5140
|
const { copy: copy$4 } = PointHelper;
|
|
5118
|
-
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5141
|
+
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5119
5142
|
let Leaf = class Leaf {
|
|
5120
5143
|
get tag() { return this.__tag; }
|
|
5121
5144
|
set tag(_value) { }
|
|
@@ -5141,6 +5164,8 @@ let Leaf = class Leaf {
|
|
|
5141
5164
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5142
5165
|
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5143
5166
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5167
|
+
set event(map) { let event; for (let key in map)
|
|
5168
|
+
event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
|
|
5144
5169
|
constructor(data) {
|
|
5145
5170
|
this.innerId = create(LEAF);
|
|
5146
5171
|
this.reset(data);
|
|
@@ -5400,6 +5425,9 @@ let Leaf = class Leaf {
|
|
|
5400
5425
|
skewOfWorld(worldOrigin, skewX, skewY, resize) {
|
|
5401
5426
|
skewOfWorld(this, worldOrigin, skewX, skewY, resize);
|
|
5402
5427
|
}
|
|
5428
|
+
flip(axis) {
|
|
5429
|
+
transform(this, getFlipTransform(this, axis));
|
|
5430
|
+
}
|
|
5403
5431
|
scaleResize(scaleX, scaleY = scaleX, _noResize) {
|
|
5404
5432
|
this.scaleX *= scaleX;
|
|
5405
5433
|
this.scaleY *= scaleY;
|
|
@@ -5757,7 +5785,7 @@ class LeafLevelList {
|
|
|
5757
5785
|
}
|
|
5758
5786
|
}
|
|
5759
5787
|
|
|
5760
|
-
const version = "1.0.
|
|
5788
|
+
const version = "1.0.1";
|
|
5761
5789
|
const inviteCode = {};
|
|
5762
5790
|
|
|
5763
5791
|
const debug$7 = Debug.get('LeaferCanvas');
|
|
@@ -5781,7 +5809,8 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5781
5809
|
}
|
|
5782
5810
|
}
|
|
5783
5811
|
init() {
|
|
5784
|
-
const {
|
|
5812
|
+
const { config } = this;
|
|
5813
|
+
const view = config.view || config.canvas;
|
|
5785
5814
|
view ? this.__createViewFrom(view) : this.__createView();
|
|
5786
5815
|
const { style } = this.view;
|
|
5787
5816
|
style.display || (style.display = 'block');
|
|
@@ -5796,7 +5825,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5796
5825
|
}
|
|
5797
5826
|
this.__createContext();
|
|
5798
5827
|
if (!this.autoLayout)
|
|
5799
|
-
this.resize(
|
|
5828
|
+
this.resize(config);
|
|
5800
5829
|
}
|
|
5801
5830
|
set backgroundColor(color) { this.view.style.backgroundColor = color; }
|
|
5802
5831
|
get backgroundColor() { return this.view.style.backgroundColor; }
|
|
@@ -5852,26 +5881,37 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5852
5881
|
this.clientBounds = this.view.getBoundingClientRect();
|
|
5853
5882
|
}
|
|
5854
5883
|
startAutoLayout(autoBounds, listener) {
|
|
5855
|
-
this.autoBounds = autoBounds;
|
|
5856
5884
|
this.resizeListener = listener;
|
|
5857
|
-
|
|
5858
|
-
this.
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
this.
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
this.
|
|
5866
|
-
|
|
5885
|
+
if (autoBounds) {
|
|
5886
|
+
this.autoBounds = autoBounds;
|
|
5887
|
+
try {
|
|
5888
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
5889
|
+
this.updateClientBounds();
|
|
5890
|
+
for (const entry of entries)
|
|
5891
|
+
this.checkAutoBounds(entry.contentRect);
|
|
5892
|
+
});
|
|
5893
|
+
const parent = this.parentView;
|
|
5894
|
+
if (parent) {
|
|
5895
|
+
this.resizeObserver.observe(parent);
|
|
5896
|
+
this.checkAutoBounds(parent.getBoundingClientRect());
|
|
5897
|
+
}
|
|
5898
|
+
else {
|
|
5899
|
+
this.checkAutoBounds(this.view);
|
|
5900
|
+
debug$7.warn('no parent');
|
|
5901
|
+
}
|
|
5867
5902
|
}
|
|
5868
|
-
|
|
5869
|
-
this.
|
|
5870
|
-
debug$7.warn('no parent');
|
|
5903
|
+
catch (_a) {
|
|
5904
|
+
this.imitateResizeObserver();
|
|
5871
5905
|
}
|
|
5872
5906
|
}
|
|
5873
|
-
|
|
5874
|
-
|
|
5907
|
+
else {
|
|
5908
|
+
window.addEventListener('resize', () => {
|
|
5909
|
+
const pixelRatio = Platform.devicePixelRatio;
|
|
5910
|
+
if (this.pixelRatio !== pixelRatio) {
|
|
5911
|
+
const { width, height } = this;
|
|
5912
|
+
this.emitResize({ width, height, pixelRatio });
|
|
5913
|
+
}
|
|
5914
|
+
});
|
|
5875
5915
|
}
|
|
5876
5916
|
}
|
|
5877
5917
|
imitateResizeObserver() {
|
|
@@ -5884,17 +5924,12 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5884
5924
|
checkAutoBounds(parentSize) {
|
|
5885
5925
|
const view = this.view;
|
|
5886
5926
|
const { x, y, width, height } = this.autoBounds.getBoundsFrom(parentSize);
|
|
5887
|
-
|
|
5927
|
+
const size = { width, height, pixelRatio: Platform.devicePixelRatio };
|
|
5928
|
+
if (!this.isSameSize(size)) {
|
|
5888
5929
|
const { style } = view;
|
|
5889
|
-
const { pixelRatio } = this;
|
|
5890
5930
|
style.marginLeft = x + 'px';
|
|
5891
5931
|
style.marginTop = y + 'px';
|
|
5892
|
-
|
|
5893
|
-
const oldSize = {};
|
|
5894
|
-
DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
|
|
5895
|
-
this.resize(size);
|
|
5896
|
-
if (this.width !== undefined)
|
|
5897
|
-
this.resizeListener(new ResizeEvent(size, oldSize));
|
|
5932
|
+
this.emitResize(size);
|
|
5898
5933
|
}
|
|
5899
5934
|
}
|
|
5900
5935
|
stopAutoLayout() {
|
|
@@ -5905,6 +5940,13 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5905
5940
|
this.resizeObserver = null;
|
|
5906
5941
|
}
|
|
5907
5942
|
}
|
|
5943
|
+
emitResize(size) {
|
|
5944
|
+
const oldSize = {};
|
|
5945
|
+
DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
|
|
5946
|
+
this.resize(size);
|
|
5947
|
+
if (this.width !== undefined)
|
|
5948
|
+
this.resizeListener(new ResizeEvent(size, oldSize));
|
|
5949
|
+
}
|
|
5908
5950
|
unrealCanvas() {
|
|
5909
5951
|
if (!this.unreal && this.parentView) {
|
|
5910
5952
|
const view = this.view;
|
|
@@ -5985,7 +6027,7 @@ function useCanvas(_canvasType, _power) {
|
|
|
5985
6027
|
Platform.name = 'web';
|
|
5986
6028
|
Platform.isMobile = 'ontouchstart' in window;
|
|
5987
6029
|
Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
|
|
5988
|
-
Platform
|
|
6030
|
+
defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, devicePixelRatio); } });
|
|
5989
6031
|
const { userAgent } = navigator;
|
|
5990
6032
|
if (userAgent.indexOf("Firefox") > -1) {
|
|
5991
6033
|
Platform.conicGradientRotate90 = true;
|
|
@@ -6482,14 +6524,14 @@ class Renderer {
|
|
|
6482
6524
|
if (Debug.showRepaint)
|
|
6483
6525
|
this.canvas.strokeWorld(bounds, 'red');
|
|
6484
6526
|
this.target.__render(this.canvas, options);
|
|
6485
|
-
this.renderBounds = realBounds || bounds;
|
|
6527
|
+
this.renderBounds = realBounds = realBounds || bounds;
|
|
6486
6528
|
this.renderOptions = options;
|
|
6487
|
-
this.totalBounds.isEmpty() ? this.totalBounds =
|
|
6529
|
+
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
6488
6530
|
if (Debug.showHitView)
|
|
6489
6531
|
this.renderHitView(options);
|
|
6490
6532
|
if (Debug.showBoundsView)
|
|
6491
6533
|
this.renderBoundsView(options);
|
|
6492
|
-
this.canvas.updateRender();
|
|
6534
|
+
this.canvas.updateRender(realBounds);
|
|
6493
6535
|
}
|
|
6494
6536
|
renderHitView(_options) { }
|
|
6495
6537
|
renderBoundsView(_options) { }
|
|
@@ -7811,7 +7853,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7811
7853
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7812
7854
|
if (this.isApp)
|
|
7813
7855
|
this.__setApp();
|
|
7814
|
-
this.__checkAutoLayout(config);
|
|
7856
|
+
this.__checkAutoLayout(config, parentApp);
|
|
7815
7857
|
this.view = canvas.view;
|
|
7816
7858
|
if (parentApp) {
|
|
7817
7859
|
this.__bindApp(parentApp);
|
|
@@ -7912,9 +7954,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7912
7954
|
this.leafer = leafer;
|
|
7913
7955
|
this.__level = 1;
|
|
7914
7956
|
}
|
|
7915
|
-
__checkAutoLayout(config) {
|
|
7916
|
-
if (!
|
|
7917
|
-
|
|
7957
|
+
__checkAutoLayout(config, parentApp) {
|
|
7958
|
+
if (!parentApp) {
|
|
7959
|
+
if (!config.width || !config.height)
|
|
7960
|
+
this.autoLayout = new AutoBounds(config);
|
|
7918
7961
|
this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
|
|
7919
7962
|
}
|
|
7920
7963
|
}
|
|
@@ -8049,7 +8092,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8049
8092
|
list.push(item);
|
|
8050
8093
|
}
|
|
8051
8094
|
}
|
|
8052
|
-
zoom(_zoomType, _padding, _fixedScale) {
|
|
8095
|
+
zoom(_zoomType, _padding, _fixedScale) {
|
|
8096
|
+
return debug$3.error('need @leafer-in/view');
|
|
8097
|
+
}
|
|
8053
8098
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
8054
8099
|
getValidScale(changeScale) { return changeScale; }
|
|
8055
8100
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
@@ -8576,8 +8621,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8576
8621
|
destroy() {
|
|
8577
8622
|
if (this.canvas) {
|
|
8578
8623
|
this.canvas.destroy();
|
|
8579
|
-
this.canvas = null;
|
|
8580
|
-
this.context = null;
|
|
8624
|
+
this.canvas = this.context = null;
|
|
8581
8625
|
}
|
|
8582
8626
|
super.destroy();
|
|
8583
8627
|
}
|
|
@@ -8930,11 +8974,13 @@ let App = class App extends Leafer {
|
|
|
8930
8974
|
this.renderer.update();
|
|
8931
8975
|
}
|
|
8932
8976
|
__render(canvas, options) {
|
|
8933
|
-
if (
|
|
8934
|
-
|
|
8935
|
-
|
|
8977
|
+
if (canvas.context) {
|
|
8978
|
+
if (options.matrix) {
|
|
8979
|
+
const { a, b, c, d, e, f } = options.matrix;
|
|
8980
|
+
canvas.setTransform(a, b, c, d, e, f);
|
|
8981
|
+
}
|
|
8982
|
+
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
8936
8983
|
}
|
|
8937
|
-
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
8938
8984
|
}
|
|
8939
8985
|
__onResize(event) {
|
|
8940
8986
|
this.children.forEach(leafer => leafer.resize(event));
|
|
@@ -9301,11 +9347,14 @@ leafer.getValidScale = function (changeScale) {
|
|
|
9301
9347
|
};
|
|
9302
9348
|
|
|
9303
9349
|
class Transformer {
|
|
9350
|
+
get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
|
|
9304
9351
|
constructor(interaction) {
|
|
9305
9352
|
this.interaction = interaction;
|
|
9306
9353
|
}
|
|
9307
9354
|
move(data) {
|
|
9308
9355
|
const { interaction } = this;
|
|
9356
|
+
if (!data.moveType)
|
|
9357
|
+
data.moveType = 'move';
|
|
9309
9358
|
if (!this.moveData) {
|
|
9310
9359
|
const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
|
|
9311
9360
|
data.path = path;
|
|
@@ -9470,8 +9519,10 @@ class Dragger {
|
|
|
9470
9519
|
return;
|
|
9471
9520
|
}
|
|
9472
9521
|
if (!this.moving && canDrag) {
|
|
9473
|
-
if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty)
|
|
9522
|
+
if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty) {
|
|
9523
|
+
this.dragData.moveType = 'drag';
|
|
9474
9524
|
interaction.emit(MoveEvent.START, this.dragData);
|
|
9525
|
+
}
|
|
9475
9526
|
}
|
|
9476
9527
|
if (!this.moving) {
|
|
9477
9528
|
this.dragStart(data, canDrag);
|
|
@@ -9510,6 +9561,7 @@ class Dragger {
|
|
|
9510
9561
|
this.dragData.throughPath = throughPath;
|
|
9511
9562
|
this.dragData.path = path;
|
|
9512
9563
|
if (this.moving) {
|
|
9564
|
+
this.dragData.moveType = 'drag';
|
|
9513
9565
|
interaction.emit(MoveEvent.BEFORE_MOVE, this.dragData);
|
|
9514
9566
|
interaction.emit(MoveEvent.MOVE, this.dragData);
|
|
9515
9567
|
}
|
|
@@ -9576,6 +9628,7 @@ class Dragger {
|
|
|
9576
9628
|
endDragData.path = path;
|
|
9577
9629
|
if (this.moving) {
|
|
9578
9630
|
this.moving = false;
|
|
9631
|
+
endDragData.moveType = 'drag';
|
|
9579
9632
|
interaction.emit(MoveEvent.END, endDragData);
|
|
9580
9633
|
}
|
|
9581
9634
|
if (this.dragging) {
|
|
@@ -9634,7 +9687,7 @@ class Dragger {
|
|
|
9634
9687
|
totalY += moveY;
|
|
9635
9688
|
PointHelper.move(downData, moveX, moveY);
|
|
9636
9689
|
PointHelper.move(this.dragData, moveX, moveY);
|
|
9637
|
-
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY }));
|
|
9690
|
+
interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
|
|
9638
9691
|
interaction.pointerMoveReal(data);
|
|
9639
9692
|
}, 10);
|
|
9640
9693
|
}
|
|
@@ -9754,9 +9807,11 @@ const config = {
|
|
|
9754
9807
|
const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1 } = InteractionHelper;
|
|
9755
9808
|
class InteractionBase {
|
|
9756
9809
|
get dragging() { return this.dragger.dragging; }
|
|
9810
|
+
get transforming() { return this.transformer.transforming; }
|
|
9757
9811
|
get moveMode() { return this.config.move.drag || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9812
|
+
get canHover() { return this.config.pointer.hover && !this.config.mobile; }
|
|
9758
9813
|
get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
|
|
9759
|
-
get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.
|
|
9814
|
+
get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
|
|
9760
9815
|
get isHoldMiddleKey() { return this.config.move.holdMiddleKey && this.downData && PointerButton.middle(this.downData); }
|
|
9761
9816
|
get isHoldRightKey() { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData); }
|
|
9762
9817
|
get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
|
|
@@ -9849,6 +9904,7 @@ class InteractionBase {
|
|
|
9849
9904
|
if (!downData)
|
|
9850
9905
|
return;
|
|
9851
9906
|
PointerButton.defaultLeft(data);
|
|
9907
|
+
data.multiTouch = downData.multiTouch;
|
|
9852
9908
|
this.findPath(data);
|
|
9853
9909
|
const upData = Object.assign(Object.assign({}, data), { path: data.path.clone() });
|
|
9854
9910
|
data.path.addList(downData.path.list);
|
|
@@ -9921,7 +9977,7 @@ class InteractionBase {
|
|
|
9921
9977
|
this.updateCursor();
|
|
9922
9978
|
}
|
|
9923
9979
|
pointerHover(data) {
|
|
9924
|
-
if (this.
|
|
9980
|
+
if (this.canHover) {
|
|
9925
9981
|
this.pointerOverOrOut(data);
|
|
9926
9982
|
this.pointerEnterOrLeave(data);
|
|
9927
9983
|
}
|
|
@@ -10058,7 +10114,7 @@ class InteractionBase {
|
|
|
10058
10114
|
this.hoverData = data;
|
|
10059
10115
|
}
|
|
10060
10116
|
updateCursor(data) {
|
|
10061
|
-
if (!this.config.cursor || !this.
|
|
10117
|
+
if (!this.config.cursor || !this.canHover)
|
|
10062
10118
|
return;
|
|
10063
10119
|
if (!data) {
|
|
10064
10120
|
this.updateHoverData();
|
|
@@ -10380,7 +10436,7 @@ const PointerEventHelper = {
|
|
|
10380
10436
|
convertTouch(e, local) {
|
|
10381
10437
|
const touch = PointerEventHelper.getTouch(e);
|
|
10382
10438
|
const base = InteractionHelper.getBase(e);
|
|
10383
|
-
return Object.assign(Object.assign({}, base), { x: local.x, y: local.y, width: 1, height: 1, pointerType: 'touch', pressure: touch.force });
|
|
10439
|
+
return Object.assign(Object.assign({}, base), { x: local.x, y: local.y, width: 1, height: 1, pointerType: 'touch', multiTouch: e.touches.length > 1, pressure: touch.force });
|
|
10384
10440
|
},
|
|
10385
10441
|
getTouch(e) {
|
|
10386
10442
|
return e.targetTouches[0] || e.changedTouches[0];
|
|
@@ -10521,21 +10577,21 @@ class Interaction extends InteractionBase {
|
|
|
10521
10577
|
}
|
|
10522
10578
|
onPointerDown(e) {
|
|
10523
10579
|
this.preventDefaultPointer(e);
|
|
10524
|
-
this.
|
|
10525
|
-
if (this.useMultiTouch)
|
|
10580
|
+
if (this.config.pointer.touch || this.useMultiTouch)
|
|
10526
10581
|
return;
|
|
10582
|
+
this.usePointer || (this.usePointer = true);
|
|
10527
10583
|
this.pointerDown(PointerEventHelper.convert(e, this.getLocal(e)));
|
|
10528
10584
|
}
|
|
10529
10585
|
onPointerMove(e) {
|
|
10530
|
-
this.
|
|
10531
|
-
if (this.useMultiTouch || this.preventWindowPointer(e))
|
|
10586
|
+
if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e))
|
|
10532
10587
|
return;
|
|
10588
|
+
this.usePointer || (this.usePointer = true);
|
|
10533
10589
|
this.pointerMove(PointerEventHelper.convert(e, this.getLocal(e, true)));
|
|
10534
10590
|
}
|
|
10535
10591
|
onPointerUp(e) {
|
|
10536
10592
|
if (this.downData)
|
|
10537
10593
|
this.preventDefaultPointer(e);
|
|
10538
|
-
if (this.useMultiTouch || this.preventWindowPointer(e))
|
|
10594
|
+
if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e))
|
|
10539
10595
|
return;
|
|
10540
10596
|
this.pointerUp(PointerEventHelper.convert(e, this.getLocal(e)));
|
|
10541
10597
|
}
|
|
@@ -10605,7 +10661,7 @@ class Interaction extends InteractionBase {
|
|
|
10605
10661
|
this.pointerCancel();
|
|
10606
10662
|
}
|
|
10607
10663
|
multiTouchStart(e) {
|
|
10608
|
-
this.useMultiTouch = (e.touches.length
|
|
10664
|
+
this.useMultiTouch = (e.touches.length > 1);
|
|
10609
10665
|
this.touches = this.useMultiTouch ? this.getTouches(e.touches) : undefined;
|
|
10610
10666
|
if (this.useMultiTouch)
|
|
10611
10667
|
this.pointerCancel();
|
|
@@ -11295,7 +11351,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
11295
11351
|
const { abs } = Math;
|
|
11296
11352
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
11297
11353
|
const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
|
|
11298
|
-
if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
|
|
11354
|
+
if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
|
|
11299
11355
|
return false;
|
|
11300
11356
|
}
|
|
11301
11357
|
else {
|
|
@@ -12273,7 +12329,10 @@ const ExportModule = {
|
|
|
12273
12329
|
const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
|
|
12274
12330
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
12275
12331
|
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
12332
|
+
let sliceLeaf;
|
|
12276
12333
|
if (slice) {
|
|
12334
|
+
sliceLeaf = leaf;
|
|
12335
|
+
sliceLeaf.__worldOpacity = 0;
|
|
12277
12336
|
leaf = leafer;
|
|
12278
12337
|
renderOptions.bounds = canvas.bounds;
|
|
12279
12338
|
}
|
|
@@ -12288,6 +12347,8 @@ const ExportModule = {
|
|
|
12288
12347
|
leaf.__render(canvas, renderOptions);
|
|
12289
12348
|
}
|
|
12290
12349
|
canvas.restore();
|
|
12350
|
+
if (sliceLeaf)
|
|
12351
|
+
sliceLeaf.__updateWorldOpacity();
|
|
12291
12352
|
if (trim) {
|
|
12292
12353
|
trimBounds = getTrimBounds(canvas);
|
|
12293
12354
|
const old = canvas, { width, height } = trimBounds;
|