leafer-draw 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.cjs +6 -5
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +6 -5
- package/dist/web.esm.js.map +1 -1
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +34 -25
- package/dist/web.js.map +1 -1
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +34 -25
- package/dist/web.module.js.map +1 -1
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +2 -2
package/dist/web.js
CHANGED
|
@@ -3638,7 +3638,12 @@ var LeaferUI = (function (exports) {
|
|
|
3638
3638
|
return R.map[key];
|
|
3639
3639
|
},
|
|
3640
3640
|
remove(key) {
|
|
3641
|
-
|
|
3641
|
+
const r = R.map[key];
|
|
3642
|
+
if (r) {
|
|
3643
|
+
if (r.destroy)
|
|
3644
|
+
r.destroy();
|
|
3645
|
+
delete R.map[key];
|
|
3646
|
+
}
|
|
3642
3647
|
},
|
|
3643
3648
|
loadImage(key, format) {
|
|
3644
3649
|
return new Promise((resolve, reject) => {
|
|
@@ -3664,6 +3669,7 @@ var LeaferUI = (function (exports) {
|
|
|
3664
3669
|
const R = Resource;
|
|
3665
3670
|
|
|
3666
3671
|
const ImageManager = {
|
|
3672
|
+
maxRecycled: 100,
|
|
3667
3673
|
recycledList: [],
|
|
3668
3674
|
patternTasker: new TaskProcessor(),
|
|
3669
3675
|
get(config) {
|
|
@@ -3680,13 +3686,8 @@ var LeaferUI = (function (exports) {
|
|
|
3680
3686
|
},
|
|
3681
3687
|
clearRecycled() {
|
|
3682
3688
|
const list = I.recycledList;
|
|
3683
|
-
if (list.length >
|
|
3684
|
-
list.forEach(image =>
|
|
3685
|
-
if (!image.use && image.url) {
|
|
3686
|
-
Resource.remove(image.url);
|
|
3687
|
-
image.destroy();
|
|
3688
|
-
}
|
|
3689
|
-
});
|
|
3689
|
+
if (list.length > I.maxRecycled) {
|
|
3690
|
+
list.forEach(image => (!image.use && image.url) && Resource.remove(image.url));
|
|
3690
3691
|
list.length = 0;
|
|
3691
3692
|
}
|
|
3692
3693
|
},
|
|
@@ -4072,12 +4073,11 @@ var LeaferUI = (function (exports) {
|
|
|
4072
4073
|
if (defaultValue === undefined) {
|
|
4073
4074
|
property.get = function () { return this[computedKey]; };
|
|
4074
4075
|
}
|
|
4075
|
-
else if (typeof defaultValue === '
|
|
4076
|
-
const { clone } = DataHelper;
|
|
4076
|
+
else if (typeof defaultValue === 'function') {
|
|
4077
4077
|
property.get = function () {
|
|
4078
4078
|
let v = this[computedKey];
|
|
4079
4079
|
if (v === undefined)
|
|
4080
|
-
this[computedKey] = v =
|
|
4080
|
+
this[computedKey] = v = defaultValue(this.__leaf);
|
|
4081
4081
|
return v;
|
|
4082
4082
|
};
|
|
4083
4083
|
}
|
|
@@ -5724,10 +5724,10 @@ var LeaferUI = (function (exports) {
|
|
|
5724
5724
|
static changeAttr(attrName, defaultValue, fn) {
|
|
5725
5725
|
fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
5726
5726
|
}
|
|
5727
|
-
static addAttr(attrName, defaultValue, fn) {
|
|
5727
|
+
static addAttr(attrName, defaultValue, fn, helpValue) {
|
|
5728
5728
|
if (!fn)
|
|
5729
5729
|
fn = boundsType;
|
|
5730
|
-
fn(defaultValue)(this.prototype, attrName);
|
|
5730
|
+
fn(defaultValue, helpValue)(this.prototype, attrName);
|
|
5731
5731
|
}
|
|
5732
5732
|
__emitLifeEvent(type) {
|
|
5733
5733
|
if (this.hasEvent(type))
|
|
@@ -6054,7 +6054,7 @@ var LeaferUI = (function (exports) {
|
|
|
6054
6054
|
}
|
|
6055
6055
|
}
|
|
6056
6056
|
|
|
6057
|
-
const version = "1.
|
|
6057
|
+
const version = "1.5.0";
|
|
6058
6058
|
|
|
6059
6059
|
const debug$4 = Debug.get('LeaferCanvas');
|
|
6060
6060
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6965,7 +6965,11 @@ var LeaferUI = (function (exports) {
|
|
|
6965
6965
|
setStyleName() { return Plugin.need('state'); },
|
|
6966
6966
|
set() { return Plugin.need('state'); }
|
|
6967
6967
|
};
|
|
6968
|
-
const Transition = {
|
|
6968
|
+
const Transition = {
|
|
6969
|
+
list: {},
|
|
6970
|
+
register(attrName, fn) { Transition.list[attrName] = fn; },
|
|
6971
|
+
get(attrName) { return Transition.list[attrName]; }
|
|
6972
|
+
};
|
|
6969
6973
|
|
|
6970
6974
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6971
6975
|
const emptyPaint = {};
|
|
@@ -7389,9 +7393,6 @@ var LeaferUI = (function (exports) {
|
|
|
7389
7393
|
this.__drawPathByBox(pen);
|
|
7390
7394
|
return pen;
|
|
7391
7395
|
}
|
|
7392
|
-
get editConfig() { return undefined; }
|
|
7393
|
-
get editOuter() { return ''; }
|
|
7394
|
-
get editInner() { return ''; }
|
|
7395
7396
|
constructor(data) {
|
|
7396
7397
|
super(data);
|
|
7397
7398
|
}
|
|
@@ -7473,8 +7474,11 @@ var LeaferUI = (function (exports) {
|
|
|
7473
7474
|
export(_filename, _options) {
|
|
7474
7475
|
return Plugin.need('export');
|
|
7475
7476
|
}
|
|
7477
|
+
syncExport(_filename, _options) {
|
|
7478
|
+
return Plugin.need('export');
|
|
7479
|
+
}
|
|
7476
7480
|
clone(data) {
|
|
7477
|
-
const json = this.toJSON();
|
|
7481
|
+
const json = DataHelper.clone(this.toJSON());
|
|
7478
7482
|
if (data)
|
|
7479
7483
|
Object.assign(json, data);
|
|
7480
7484
|
return UI_1.one(json);
|
|
@@ -7773,7 +7777,7 @@ var LeaferUI = (function (exports) {
|
|
|
7773
7777
|
get layoutLocked() { return !this.layouter.running; }
|
|
7774
7778
|
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
7775
7779
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
7776
|
-
get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
|
|
7780
|
+
get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
|
|
7777
7781
|
constructor(userConfig, data) {
|
|
7778
7782
|
super(data);
|
|
7779
7783
|
this.config = {
|
|
@@ -8075,6 +8079,10 @@ var LeaferUI = (function (exports) {
|
|
|
8075
8079
|
getPagePointByClient(clientPoint, updateClient) {
|
|
8076
8080
|
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8077
8081
|
}
|
|
8082
|
+
getClientPointByWorld(worldPoint) {
|
|
8083
|
+
const { x, y } = this.clientBounds;
|
|
8084
|
+
return { x: x + worldPoint.x, y: y + worldPoint.y };
|
|
8085
|
+
}
|
|
8078
8086
|
updateClientBounds() {
|
|
8079
8087
|
this.canvas && this.canvas.updateClientBounds();
|
|
8080
8088
|
}
|
|
@@ -10110,13 +10118,14 @@ var LeaferUI = (function (exports) {
|
|
|
10110
10118
|
}
|
|
10111
10119
|
|
|
10112
10120
|
function layoutText(drawData, style) {
|
|
10113
|
-
const { rows, bounds } = drawData;
|
|
10121
|
+
const { rows, bounds } = drawData, countRows = rows.length;
|
|
10114
10122
|
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
10115
|
-
let { x, y, width, height } = bounds, realHeight = __lineHeight *
|
|
10123
|
+
let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
10116
10124
|
let starY = __baseLine;
|
|
10117
10125
|
if (__clipText && realHeight > height) {
|
|
10118
10126
|
realHeight = Math.max(height, __lineHeight);
|
|
10119
|
-
|
|
10127
|
+
if (countRows > 1)
|
|
10128
|
+
drawData.overflow = countRows;
|
|
10120
10129
|
}
|
|
10121
10130
|
else if (height || autoSizeAlign) {
|
|
10122
10131
|
switch (verticalAlign) {
|
|
@@ -10128,7 +10137,7 @@ var LeaferUI = (function (exports) {
|
|
|
10128
10137
|
}
|
|
10129
10138
|
starY += y;
|
|
10130
10139
|
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
10131
|
-
for (let i = 0, len =
|
|
10140
|
+
for (let i = 0, len = countRows; i < len; i++) {
|
|
10132
10141
|
row = rows[i];
|
|
10133
10142
|
row.x = x;
|
|
10134
10143
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
@@ -10197,7 +10206,7 @@ var LeaferUI = (function (exports) {
|
|
|
10197
10206
|
if (i === end && charRight < right) {
|
|
10198
10207
|
break;
|
|
10199
10208
|
}
|
|
10200
|
-
else if (charRight < right && char.char !== ' ') {
|
|
10209
|
+
else if ((charRight < right && char.char !== ' ') || !i) {
|
|
10201
10210
|
row.data.splice(i + 1);
|
|
10202
10211
|
row.width -= char.width;
|
|
10203
10212
|
break;
|