@leafer-ui/miniapp 1.0.6 → 1.0.8
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 +24 -38
- package/dist/miniapp.esm.js +24 -38
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.module.js +99 -134
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +10 -10
package/dist/miniapp.module.js
CHANGED
|
@@ -2958,7 +2958,6 @@ class PathCreator {
|
|
|
2958
2958
|
set path(value) { this.__path = value; }
|
|
2959
2959
|
get path() { return this.__path; }
|
|
2960
2960
|
constructor(path) {
|
|
2961
|
-
this.clearPath = this.beginPath;
|
|
2962
2961
|
this.set(path);
|
|
2963
2962
|
}
|
|
2964
2963
|
set(path) {
|
|
@@ -3040,6 +3039,9 @@ class PathCreator {
|
|
|
3040
3039
|
this.paint();
|
|
3041
3040
|
return this;
|
|
3042
3041
|
}
|
|
3042
|
+
clearPath() {
|
|
3043
|
+
return this.beginPath();
|
|
3044
|
+
}
|
|
3043
3045
|
paint() { }
|
|
3044
3046
|
}
|
|
3045
3047
|
|
|
@@ -3635,6 +3637,8 @@ const ImageManager = {
|
|
|
3635
3637
|
else {
|
|
3636
3638
|
if (url.includes('.' + format) || url.includes('.' + FileHelper.upperCaseTypeMap[format]))
|
|
3637
3639
|
return true;
|
|
3640
|
+
else if (format === 'png' && !url.includes('.'))
|
|
3641
|
+
return true;
|
|
3638
3642
|
}
|
|
3639
3643
|
return false;
|
|
3640
3644
|
},
|
|
@@ -4426,13 +4430,10 @@ class LeafLayout {
|
|
|
4426
4430
|
update() {
|
|
4427
4431
|
const { leafer } = this.leaf;
|
|
4428
4432
|
if (leafer) {
|
|
4429
|
-
if (leafer.ready)
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
}
|
|
4433
|
-
else {
|
|
4433
|
+
if (leafer.ready)
|
|
4434
|
+
leafer.watcher.changed && leafer.layouter.layout();
|
|
4435
|
+
else
|
|
4434
4436
|
leafer.start();
|
|
4435
|
-
}
|
|
4436
4437
|
}
|
|
4437
4438
|
else {
|
|
4438
4439
|
let root = this.leaf;
|
|
@@ -5255,7 +5256,7 @@ const BranchRender = {
|
|
|
5255
5256
|
const { LEAF, create } = IncrementId;
|
|
5256
5257
|
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5257
5258
|
const { toOuterOf } = BoundsHelper;
|
|
5258
|
-
const { copy: copy$4, move
|
|
5259
|
+
const { copy: copy$4, move } = PointHelper;
|
|
5259
5260
|
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
5260
5261
|
let Leaf = class Leaf {
|
|
5261
5262
|
get tag() { return this.__tag; }
|
|
@@ -5490,7 +5491,7 @@ let Leaf = class Leaf {
|
|
|
5490
5491
|
}
|
|
5491
5492
|
getBoxPointByInner(inner, _relative, _distance, change) {
|
|
5492
5493
|
const point = change ? inner : Object.assign({}, inner), { x, y } = this.boxBounds;
|
|
5493
|
-
move
|
|
5494
|
+
move(point, -x, -y);
|
|
5494
5495
|
return point;
|
|
5495
5496
|
}
|
|
5496
5497
|
getInnerPoint(world, relative, distance, change) {
|
|
@@ -5500,7 +5501,7 @@ let Leaf = class Leaf {
|
|
|
5500
5501
|
}
|
|
5501
5502
|
getInnerPointByBox(box, _relative, _distance, change) {
|
|
5502
5503
|
const point = change ? box : Object.assign({}, box), { x, y } = this.boxBounds;
|
|
5503
|
-
move
|
|
5504
|
+
move(point, x, y);
|
|
5504
5505
|
return point;
|
|
5505
5506
|
}
|
|
5506
5507
|
getInnerPointByLocal(local, _relative, distance, change) {
|
|
@@ -5641,11 +5642,10 @@ let Leaf = class Leaf {
|
|
|
5641
5642
|
}
|
|
5642
5643
|
destroy() {
|
|
5643
5644
|
if (!this.destroyed) {
|
|
5644
|
-
|
|
5645
|
-
if (parent)
|
|
5645
|
+
if (this.parent)
|
|
5646
5646
|
this.remove();
|
|
5647
5647
|
if (this.children)
|
|
5648
|
-
this.
|
|
5648
|
+
this.clear();
|
|
5649
5649
|
this.__emitLifeEvent(ChildEvent.DESTROY);
|
|
5650
5650
|
this.__.destroy();
|
|
5651
5651
|
this.__layout.destroy();
|
|
@@ -5959,7 +5959,7 @@ class LeafLevelList {
|
|
|
5959
5959
|
}
|
|
5960
5960
|
}
|
|
5961
5961
|
|
|
5962
|
-
const version = "1.0.
|
|
5962
|
+
const version = "1.0.8";
|
|
5963
5963
|
|
|
5964
5964
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5965
5965
|
get allowBackgroundColor() { return false; }
|
|
@@ -6070,7 +6070,10 @@ Object.assign(Creator, {
|
|
|
6070
6070
|
});
|
|
6071
6071
|
function useCanvas(_canvasType, app) {
|
|
6072
6072
|
Platform.origin = {
|
|
6073
|
-
createCanvas: (width, height, _format) =>
|
|
6073
|
+
createCanvas: (width, height, _format) => {
|
|
6074
|
+
const data = { type: '2d', width, height };
|
|
6075
|
+
app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
|
|
6076
|
+
},
|
|
6074
6077
|
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
|
|
6075
6078
|
canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
|
|
6076
6079
|
canvasSaveAs: (canvas, filePath, quality) => {
|
|
@@ -6815,7 +6818,8 @@ class Picker {
|
|
|
6815
6818
|
path.add(leaf);
|
|
6816
6819
|
leaf = leaf.parent;
|
|
6817
6820
|
}
|
|
6818
|
-
|
|
6821
|
+
if (this.target)
|
|
6822
|
+
path.add(this.target);
|
|
6819
6823
|
return path;
|
|
6820
6824
|
}
|
|
6821
6825
|
getHitablePath(leaf) {
|
|
@@ -6901,8 +6905,8 @@ class Selector {
|
|
|
6901
6905
|
this.innerIdMap = {};
|
|
6902
6906
|
this.idMap = {};
|
|
6903
6907
|
this.methods = {
|
|
6904
|
-
id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
|
|
6905
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
|
|
6908
|
+
id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
|
|
6909
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
|
|
6906
6910
|
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
6907
6911
|
tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
|
|
6908
6912
|
tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
|
|
@@ -6911,7 +6915,8 @@ class Selector {
|
|
|
6911
6915
|
if (userConfig)
|
|
6912
6916
|
this.config = DataHelper.default(userConfig, this.config);
|
|
6913
6917
|
this.picker = new Picker(target, this);
|
|
6914
|
-
|
|
6918
|
+
if (target)
|
|
6919
|
+
this.__listenEvents();
|
|
6915
6920
|
}
|
|
6916
6921
|
getBy(condition, branch, one, options) {
|
|
6917
6922
|
switch (typeof condition) {
|
|
@@ -6946,7 +6951,7 @@ class Selector {
|
|
|
6946
6951
|
}
|
|
6947
6952
|
}
|
|
6948
6953
|
getByPoint(hitPoint, hitRadius, options) {
|
|
6949
|
-
if (Platform.name === 'node')
|
|
6954
|
+
if (Platform.name === 'node' && this.target)
|
|
6950
6955
|
this.target.emit(LayoutEvent.CHECK_UPDATE);
|
|
6951
6956
|
return this.picker.getByPoint(hitPoint, hitRadius, options);
|
|
6952
6957
|
}
|
|
@@ -7095,12 +7100,8 @@ const State = {
|
|
|
7095
7100
|
};
|
|
7096
7101
|
const Transition = {
|
|
7097
7102
|
list: {},
|
|
7098
|
-
register(attrName, fn) {
|
|
7099
|
-
|
|
7100
|
-
},
|
|
7101
|
-
get(attrName) {
|
|
7102
|
-
return Transition.list[attrName];
|
|
7103
|
-
}
|
|
7103
|
+
register(attrName, fn) { Transition.list[attrName] = fn; },
|
|
7104
|
+
get(attrName) { return Transition.list[attrName]; }
|
|
7104
7105
|
};
|
|
7105
7106
|
|
|
7106
7107
|
const { parse, objectToCanvasData } = PathConvert;
|
|
@@ -7546,8 +7547,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7546
7547
|
pen.set(path = []), this.__drawPathByBox(pen);
|
|
7547
7548
|
return curve ? PathConvert.toCanvasData(path, true) : path;
|
|
7548
7549
|
}
|
|
7549
|
-
getPathString(curve, pathForRender) {
|
|
7550
|
-
return PathConvert.stringify(this.getPath(curve, pathForRender));
|
|
7550
|
+
getPathString(curve, pathForRender, floatLength) {
|
|
7551
|
+
return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength);
|
|
7551
7552
|
}
|
|
7552
7553
|
load() {
|
|
7553
7554
|
this.__.__computePaint();
|
|
@@ -7956,11 +7957,11 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7956
7957
|
start() {
|
|
7957
7958
|
clearTimeout(this.__startTimer);
|
|
7958
7959
|
if (!this.running && this.canvas) {
|
|
7960
|
+
this.running = true;
|
|
7959
7961
|
this.ready ? this.emitLeafer(LeaferEvent.RESTART) : this.emitLeafer(LeaferEvent.START);
|
|
7960
7962
|
this.__controllers.forEach(item => item.start());
|
|
7961
7963
|
if (!this.isApp)
|
|
7962
7964
|
this.renderer.render();
|
|
7963
|
-
this.running = true;
|
|
7964
7965
|
}
|
|
7965
7966
|
}
|
|
7966
7967
|
stop() {
|
|
@@ -8066,12 +8067,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8066
8067
|
}
|
|
8067
8068
|
__changeFill(newValue) {
|
|
8068
8069
|
this.config.fill = newValue;
|
|
8069
|
-
if (this.canvas.allowBackgroundColor)
|
|
8070
|
+
if (this.canvas.allowBackgroundColor)
|
|
8070
8071
|
this.canvas.backgroundColor = newValue;
|
|
8071
|
-
|
|
8072
|
-
else {
|
|
8072
|
+
else
|
|
8073
8073
|
this.forceRender();
|
|
8074
|
-
}
|
|
8075
8074
|
}
|
|
8076
8075
|
__onCreated() {
|
|
8077
8076
|
this.created = true;
|
|
@@ -8138,13 +8137,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8138
8137
|
if (bind)
|
|
8139
8138
|
item = item.bind(bind);
|
|
8140
8139
|
this.__viewCompletedWait.push(item);
|
|
8141
|
-
if (this.viewCompleted)
|
|
8140
|
+
if (this.viewCompleted)
|
|
8142
8141
|
this.__checkViewCompleted(false);
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
if (!this.running)
|
|
8146
|
-
this.start();
|
|
8147
|
-
}
|
|
8142
|
+
else if (!this.running)
|
|
8143
|
+
this.start();
|
|
8148
8144
|
}
|
|
8149
8145
|
nextRender(item, bind, off) {
|
|
8150
8146
|
if (bind)
|
|
@@ -8158,9 +8154,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8158
8154
|
}
|
|
8159
8155
|
}
|
|
8160
8156
|
}
|
|
8161
|
-
else
|
|
8157
|
+
else
|
|
8162
8158
|
list.push(item);
|
|
8163
|
-
}
|
|
8164
8159
|
}
|
|
8165
8160
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
8166
8161
|
return needPlugin('view');
|
|
@@ -8204,10 +8199,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8204
8199
|
this.stop();
|
|
8205
8200
|
this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
|
|
8206
8201
|
this.__removeListenEvents();
|
|
8207
|
-
this.__controllers.forEach(item =>
|
|
8208
|
-
if (!(this.parent && item === this.interaction))
|
|
8209
|
-
item.destroy();
|
|
8210
|
-
});
|
|
8202
|
+
this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
|
|
8211
8203
|
this.__controllers.length = 0;
|
|
8212
8204
|
if (!this.parent) {
|
|
8213
8205
|
if (this.selector)
|
|
@@ -8740,23 +8732,23 @@ let Text = class Text extends UI {
|
|
|
8740
8732
|
}
|
|
8741
8733
|
__updateTextDrawData() {
|
|
8742
8734
|
const data = this.__;
|
|
8743
|
-
data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
|
|
8744
|
-
}
|
|
8745
|
-
__updateBoxBounds() {
|
|
8746
|
-
const data = this.__;
|
|
8747
|
-
const layout = this.__layout;
|
|
8748
8735
|
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
8749
|
-
const autoWidth = data.__autoWidth;
|
|
8750
|
-
const autoHeight = data.__autoHeight;
|
|
8751
8736
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
8752
8737
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
8753
8738
|
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
8754
8739
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
8755
8740
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
8756
8741
|
data.__clipText = textOverflow !== 'show' && !data.__autoSize;
|
|
8742
|
+
data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
|
|
8743
|
+
}
|
|
8744
|
+
__updateBoxBounds() {
|
|
8745
|
+
const data = this.__;
|
|
8746
|
+
const layout = this.__layout;
|
|
8747
|
+
const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data;
|
|
8757
8748
|
this.__updateTextDrawData();
|
|
8758
8749
|
const { bounds } = data.__textDrawData;
|
|
8759
8750
|
const b = layout.boxBounds;
|
|
8751
|
+
console.log(bounds, autoWidth, autoHeight);
|
|
8760
8752
|
if (data.__lineHeight < fontSize)
|
|
8761
8753
|
spread(bounds, fontSize / 2);
|
|
8762
8754
|
if (autoWidth || autoHeight) {
|
|
@@ -8766,20 +8758,15 @@ let Text = class Text extends UI {
|
|
|
8766
8758
|
b.height = autoHeight ? bounds.height : data.height;
|
|
8767
8759
|
if (padding) {
|
|
8768
8760
|
const [top, right, bottom, left] = data.__padding;
|
|
8769
|
-
if (autoWidth)
|
|
8770
|
-
b.x -= left;
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
if (autoHeight) {
|
|
8774
|
-
b.y -= top;
|
|
8775
|
-
b.height += (bottom + top);
|
|
8776
|
-
}
|
|
8761
|
+
if (autoWidth)
|
|
8762
|
+
b.x -= left, b.width += (right + left);
|
|
8763
|
+
if (autoHeight)
|
|
8764
|
+
b.y -= top, b.height += (bottom + top);
|
|
8777
8765
|
}
|
|
8778
8766
|
this.__updateNaturalSize();
|
|
8779
8767
|
}
|
|
8780
|
-
else
|
|
8768
|
+
else
|
|
8781
8769
|
super.__updateBoxBounds();
|
|
8782
|
-
}
|
|
8783
8770
|
if (italic)
|
|
8784
8771
|
b.width += fontSize * 0.16;
|
|
8785
8772
|
const contentBounds = includes(b, bounds) ? b : bounds;
|
|
@@ -8788,9 +8775,8 @@ let Text = class Text extends UI {
|
|
|
8788
8775
|
layout.renderChanged = true;
|
|
8789
8776
|
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
8790
8777
|
}
|
|
8791
|
-
else
|
|
8778
|
+
else
|
|
8792
8779
|
data.__textBoxBounds = contentBounds;
|
|
8793
|
-
}
|
|
8794
8780
|
}
|
|
8795
8781
|
__updateRenderSpread() {
|
|
8796
8782
|
let width = super.__updateRenderSpread();
|
|
@@ -8903,11 +8889,7 @@ let Pen = class Pen extends Group {
|
|
|
8903
8889
|
this.add(path);
|
|
8904
8890
|
return this;
|
|
8905
8891
|
}
|
|
8906
|
-
beginPath() {
|
|
8907
|
-
this.__path.length = 0;
|
|
8908
|
-
this.paint();
|
|
8909
|
-
return this;
|
|
8910
|
-
}
|
|
8892
|
+
beginPath() { return this; }
|
|
8911
8893
|
moveTo(_x, _y) { return this; }
|
|
8912
8894
|
lineTo(_x, _y) { return this; }
|
|
8913
8895
|
bezierCurveTo(_x1, _y1, _x2, _y2, _x, _y) { return this; }
|
|
@@ -8934,7 +8916,7 @@ __decorate([
|
|
|
8934
8916
|
penPathType()
|
|
8935
8917
|
], Pen.prototype, "path", void 0);
|
|
8936
8918
|
Pen = __decorate([
|
|
8937
|
-
useModule(PathCreator, ['set', '
|
|
8919
|
+
useModule(PathCreator, ['set', 'path', 'paint']),
|
|
8938
8920
|
registerUI()
|
|
8939
8921
|
], Pen);
|
|
8940
8922
|
function penPathType() {
|
|
@@ -9036,10 +9018,9 @@ let App = class App extends Leafer {
|
|
|
9036
9018
|
}
|
|
9037
9019
|
__render(canvas, options) {
|
|
9038
9020
|
if (canvas.context) {
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
canvas.setTransform(a, b, c, d, e, f);
|
|
9042
|
-
}
|
|
9021
|
+
const m = options.matrix;
|
|
9022
|
+
if (m)
|
|
9023
|
+
canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
9043
9024
|
this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
|
|
9044
9025
|
}
|
|
9045
9026
|
}
|
|
@@ -9109,9 +9090,6 @@ class UIEvent extends Event {
|
|
|
9109
9090
|
constructor(params) {
|
|
9110
9091
|
super(params.type);
|
|
9111
9092
|
this.bubbles = true;
|
|
9112
|
-
this.getInner = this.getInnerPoint;
|
|
9113
|
-
this.getLocal = this.getLocalPoint;
|
|
9114
|
-
this.getPage = this.getPagePoint;
|
|
9115
9093
|
Object.assign(this, params);
|
|
9116
9094
|
}
|
|
9117
9095
|
getBoxPoint(relative) {
|
|
@@ -9132,6 +9110,9 @@ class UIEvent extends Event {
|
|
|
9132
9110
|
getPagePoint() {
|
|
9133
9111
|
return this.current.getPagePoint(this);
|
|
9134
9112
|
}
|
|
9113
|
+
getInner(relative) { return this.getInnerPoint(relative); }
|
|
9114
|
+
getLocal(relative) { return this.getLocalPoint(relative); }
|
|
9115
|
+
getPage() { return this.getPagePoint(); }
|
|
9135
9116
|
static changeName(oldName, newName) {
|
|
9136
9117
|
EventCreator.changeName(oldName, newName);
|
|
9137
9118
|
}
|
|
@@ -9163,7 +9144,7 @@ PointerEvent = __decorate([
|
|
|
9163
9144
|
], PointerEvent);
|
|
9164
9145
|
const MyPointerEvent = PointerEvent;
|
|
9165
9146
|
|
|
9166
|
-
const
|
|
9147
|
+
const tempMove = {};
|
|
9167
9148
|
let DragEvent = class DragEvent extends PointerEvent {
|
|
9168
9149
|
static setList(data) {
|
|
9169
9150
|
this.list = data instanceof LeafList ? data : new LeafList(data);
|
|
@@ -9214,19 +9195,19 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9214
9195
|
}
|
|
9215
9196
|
getPageMove(total) {
|
|
9216
9197
|
this.assignMove(total);
|
|
9217
|
-
return this.current.getPagePoint(
|
|
9198
|
+
return this.current.getPagePoint(tempMove, null, true);
|
|
9218
9199
|
}
|
|
9219
9200
|
getInnerMove(relative, total) {
|
|
9220
9201
|
if (!relative)
|
|
9221
9202
|
relative = this.current;
|
|
9222
9203
|
this.assignMove(total);
|
|
9223
|
-
return relative.getInnerPoint(
|
|
9204
|
+
return relative.getInnerPoint(tempMove, null, true);
|
|
9224
9205
|
}
|
|
9225
9206
|
getLocalMove(relative, total) {
|
|
9226
9207
|
if (!relative)
|
|
9227
9208
|
relative = this.current;
|
|
9228
9209
|
this.assignMove(total);
|
|
9229
|
-
return relative.getLocalPoint(
|
|
9210
|
+
return relative.getLocalPoint(tempMove, null, true);
|
|
9230
9211
|
}
|
|
9231
9212
|
getPageTotal() {
|
|
9232
9213
|
return this.getPageMove(true);
|
|
@@ -9246,8 +9227,8 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9246
9227
|
return bounds;
|
|
9247
9228
|
}
|
|
9248
9229
|
assignMove(total) {
|
|
9249
|
-
|
|
9250
|
-
|
|
9230
|
+
tempMove.x = total ? this.totalX : this.moveX;
|
|
9231
|
+
tempMove.y = total ? this.totalY : this.moveY;
|
|
9251
9232
|
}
|
|
9252
9233
|
};
|
|
9253
9234
|
DragEvent.BEFORE_DRAG = 'drag.before_drag';
|
|
@@ -9661,9 +9642,8 @@ class Dragger {
|
|
|
9661
9642
|
interaction.emit(DragEvent.OVER, data, path);
|
|
9662
9643
|
}
|
|
9663
9644
|
}
|
|
9664
|
-
else
|
|
9645
|
+
else
|
|
9665
9646
|
interaction.emit(DragEvent.OVER, data, path);
|
|
9666
|
-
}
|
|
9667
9647
|
}
|
|
9668
9648
|
dragEnterOrLeave(data) {
|
|
9669
9649
|
const { interaction } = this;
|
|
@@ -9684,9 +9664,8 @@ class Dragger {
|
|
|
9684
9664
|
this.drag(data);
|
|
9685
9665
|
this.animate(() => { this.dragEnd(data, 1); });
|
|
9686
9666
|
}
|
|
9687
|
-
else
|
|
9667
|
+
else
|
|
9688
9668
|
this.dragEndReal(data);
|
|
9689
|
-
}
|
|
9690
9669
|
}
|
|
9691
9670
|
dragEndReal(data) {
|
|
9692
9671
|
const { interaction, downData, dragData } = this;
|
|
@@ -9883,14 +9862,16 @@ const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData
|
|
|
9883
9862
|
class InteractionBase {
|
|
9884
9863
|
get dragging() { return this.dragger.dragging; }
|
|
9885
9864
|
get transforming() { return this.transformer.transforming; }
|
|
9886
|
-
get moveMode() { return this.
|
|
9887
|
-
get canHover() { return this.
|
|
9888
|
-
get isDragEmpty() { return this.
|
|
9889
|
-
get isMobileDragEmpty() { return this.
|
|
9890
|
-
get isHoldMiddleKey() { return this.
|
|
9891
|
-
get isHoldRightKey() { return this.
|
|
9892
|
-
get isHoldSpaceKey() { return this.
|
|
9893
|
-
get
|
|
9865
|
+
get moveMode() { return this.m.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9866
|
+
get canHover() { return this.p.hover && !this.config.mobile; }
|
|
9867
|
+
get isDragEmpty() { return this.m.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
|
|
9868
|
+
get isMobileDragEmpty() { return this.m.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
|
|
9869
|
+
get isHoldMiddleKey() { return this.m.holdMiddleKey && this.downData && PointerButton.middle(this.downData); }
|
|
9870
|
+
get isHoldRightKey() { return this.m.holdRightKey && this.downData && PointerButton.right(this.downData); }
|
|
9871
|
+
get isHoldSpaceKey() { return this.m.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
|
|
9872
|
+
get m() { return this.config.move; }
|
|
9873
|
+
get p() { return this.config.pointer; }
|
|
9874
|
+
get hitRadius() { return this.p.hitRadius; }
|
|
9894
9875
|
constructor(target, canvas, selector, userConfig) {
|
|
9895
9876
|
this.config = DataHelper.clone(config);
|
|
9896
9877
|
this.tapCount = 0;
|
|
@@ -9948,7 +9929,7 @@ class InteractionBase {
|
|
|
9948
9929
|
}
|
|
9949
9930
|
}
|
|
9950
9931
|
pointerMoveReal(data) {
|
|
9951
|
-
const { dragHover, dragDistance } = this.
|
|
9932
|
+
const { dragHover, dragDistance } = this.p;
|
|
9952
9933
|
this.emit(PointerEvent.BEFORE_MOVE, data, this.defaultPath);
|
|
9953
9934
|
if (this.downData) {
|
|
9954
9935
|
const canDrag = PointHelper.getDistance(this.downData, data) > dragDistance;
|
|
@@ -10133,7 +10114,7 @@ class InteractionBase {
|
|
|
10133
10114
|
}
|
|
10134
10115
|
}
|
|
10135
10116
|
findPath(data, options) {
|
|
10136
|
-
const { hitRadius, through } = this.
|
|
10117
|
+
const { hitRadius, through } = this.p;
|
|
10137
10118
|
const { bottomList } = this;
|
|
10138
10119
|
const find = this.selector.getByPoint(data, hitRadius, Object.assign({ bottomList, name: data.type }, (options || { through })));
|
|
10139
10120
|
if (find.throughPath)
|
|
@@ -10155,7 +10136,7 @@ class InteractionBase {
|
|
|
10155
10136
|
data.path = this.defaultPath;
|
|
10156
10137
|
}
|
|
10157
10138
|
canMove(data) {
|
|
10158
|
-
return data && (this.moveMode || (this.
|
|
10139
|
+
return data && (this.moveMode || (this.m.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path);
|
|
10159
10140
|
}
|
|
10160
10141
|
isDrag(leaf) {
|
|
10161
10142
|
return this.dragger.getList().has(leaf);
|
|
@@ -10253,7 +10234,7 @@ class InteractionBase {
|
|
|
10253
10234
|
this.longPressTimer = setTimeout(() => {
|
|
10254
10235
|
this.longPressed = true;
|
|
10255
10236
|
this.emit(PointerEvent.LONG_PRESS, data);
|
|
10256
|
-
}, this.
|
|
10237
|
+
}, this.p.longPressTime);
|
|
10257
10238
|
}
|
|
10258
10239
|
longTap(data) {
|
|
10259
10240
|
let hasLong;
|
|
@@ -10464,17 +10445,20 @@ rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
|
10464
10445
|
};
|
|
10465
10446
|
|
|
10466
10447
|
const ui = UI.prototype, group = Group.prototype;
|
|
10448
|
+
function getSelector(ui) {
|
|
10449
|
+
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
10450
|
+
}
|
|
10467
10451
|
ui.find = function (condition, options) {
|
|
10468
|
-
return this.
|
|
10452
|
+
return getSelector(this).getBy(condition, this, false, options);
|
|
10469
10453
|
};
|
|
10470
10454
|
ui.findOne = function (condition, options) {
|
|
10471
|
-
return this.
|
|
10455
|
+
return getSelector(this).getBy(condition, this, true, options);
|
|
10472
10456
|
};
|
|
10473
10457
|
group.pick = function (hitPoint, options) {
|
|
10474
10458
|
this.__layout.update();
|
|
10475
10459
|
if (!options)
|
|
10476
10460
|
options = {};
|
|
10477
|
-
return this.
|
|
10461
|
+
return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
10478
10462
|
};
|
|
10479
10463
|
|
|
10480
10464
|
const canvas$1 = LeaferCanvasBase.prototype;
|
|
@@ -10608,14 +10592,10 @@ function fillText(ui, canvas) {
|
|
|
10608
10592
|
const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
|
|
10609
10593
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
10610
10594
|
row = rows[i];
|
|
10611
|
-
if (row.text)
|
|
10595
|
+
if (row.text)
|
|
10612
10596
|
canvas.fillText(row.text, row.x, row.y);
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
row.data.forEach(charData => {
|
|
10616
|
-
canvas.fillText(charData.char, charData.x, row.y);
|
|
10617
|
-
});
|
|
10618
|
-
}
|
|
10597
|
+
else if (row.data)
|
|
10598
|
+
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
10619
10599
|
if (decorationY)
|
|
10620
10600
|
canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
|
|
10621
10601
|
}
|
|
@@ -10681,12 +10661,10 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
|
|
|
10681
10661
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
10682
10662
|
fillText(ui, out);
|
|
10683
10663
|
out.blendMode = 'normal';
|
|
10684
|
-
if (ui.__worldFlipped)
|
|
10664
|
+
if (ui.__worldFlipped)
|
|
10685
10665
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
10686
|
-
|
|
10687
|
-
else {
|
|
10666
|
+
else
|
|
10688
10667
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
10689
|
-
}
|
|
10690
10668
|
out.recycle(ui.__nowWorld);
|
|
10691
10669
|
}
|
|
10692
10670
|
function drawTextStroke(ui, canvas) {
|
|
@@ -10694,14 +10672,10 @@ function drawTextStroke(ui, canvas) {
|
|
|
10694
10672
|
const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
|
|
10695
10673
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
10696
10674
|
row = rows[i];
|
|
10697
|
-
if (row.text)
|
|
10675
|
+
if (row.text)
|
|
10698
10676
|
canvas.strokeText(row.text, row.x, row.y);
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
row.data.forEach(charData => {
|
|
10702
|
-
canvas.strokeText(charData.char, charData.x, row.y);
|
|
10703
|
-
});
|
|
10704
|
-
}
|
|
10677
|
+
else if (row.data)
|
|
10678
|
+
row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
|
|
10705
10679
|
if (decorationY)
|
|
10706
10680
|
canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
|
|
10707
10681
|
}
|
|
@@ -10754,12 +10728,10 @@ function stroke(stroke, ui, canvas) {
|
|
|
10754
10728
|
out.stroke();
|
|
10755
10729
|
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
10756
10730
|
out.clearWorld(ui.__layout.renderBounds);
|
|
10757
|
-
if (ui.__worldFlipped)
|
|
10731
|
+
if (ui.__worldFlipped)
|
|
10758
10732
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
10759
|
-
|
|
10760
|
-
else {
|
|
10733
|
+
else
|
|
10761
10734
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
10762
|
-
}
|
|
10763
10735
|
out.recycle(ui.__nowWorld);
|
|
10764
10736
|
break;
|
|
10765
10737
|
}
|
|
@@ -10794,12 +10766,10 @@ function strokes(strokes, ui, canvas) {
|
|
|
10794
10766
|
drawStrokesStyle(strokes, false, ui, out);
|
|
10795
10767
|
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
10796
10768
|
out.clearWorld(renderBounds);
|
|
10797
|
-
if (ui.__worldFlipped)
|
|
10769
|
+
if (ui.__worldFlipped)
|
|
10798
10770
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
10799
|
-
|
|
10800
|
-
else {
|
|
10771
|
+
else
|
|
10801
10772
|
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
10802
|
-
}
|
|
10803
10773
|
out.recycle(ui.__nowWorld);
|
|
10804
10774
|
break;
|
|
10805
10775
|
}
|
|
@@ -10863,12 +10833,7 @@ function compute(attrName, ui) {
|
|
|
10863
10833
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
10864
10834
|
if (leafPaints.length && leafPaints[0].image)
|
|
10865
10835
|
hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
|
|
10866
|
-
|
|
10867
|
-
data.__pixelFill = hasOpacityPixel;
|
|
10868
|
-
}
|
|
10869
|
-
else {
|
|
10870
|
-
data.__pixelStroke = hasOpacityPixel;
|
|
10871
|
-
}
|
|
10836
|
+
attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
|
|
10872
10837
|
}
|
|
10873
10838
|
function getLeafPaint(attrName, paint, ui) {
|
|
10874
10839
|
if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
|