leafer-ui 1.4.2 → 1.5.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 +15 -7
- package/dist/web.cjs +8 -7
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +8 -7
- 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 +29 -27
- 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 +29 -27
- 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 +12 -12
package/dist/web.module.js
CHANGED
|
@@ -2029,13 +2029,11 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2029
2029
|
this.worldTransform = {};
|
|
2030
2030
|
if (!config)
|
|
2031
2031
|
config = minSize;
|
|
2032
|
-
if (!config.pixelRatio)
|
|
2033
|
-
config.pixelRatio = Platform.devicePixelRatio;
|
|
2034
2032
|
this.manager = manager;
|
|
2035
2033
|
this.innerId = IncrementId.create(IncrementId.CNAVAS);
|
|
2036
2034
|
const { width, height, pixelRatio } = config;
|
|
2037
2035
|
this.autoLayout = !width || !height;
|
|
2038
|
-
this.size.pixelRatio = pixelRatio;
|
|
2036
|
+
this.size.pixelRatio = pixelRatio | Platform.devicePixelRatio;
|
|
2039
2037
|
this.config = config;
|
|
2040
2038
|
this.init();
|
|
2041
2039
|
}
|
|
@@ -2232,7 +2230,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2232
2230
|
tempBounds$1.ceil();
|
|
2233
2231
|
}
|
|
2234
2232
|
isSameSize(size) {
|
|
2235
|
-
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
2233
|
+
return this.width === size.width && this.height === size.height && (!size.pixelRatio || this.pixelRatio === size.pixelRatio);
|
|
2236
2234
|
}
|
|
2237
2235
|
getSameCanvas(useSameWorldTransform, useSameSmooth) {
|
|
2238
2236
|
const canvas = this.manager ? this.manager.get(this.size) : Creator.canvas(Object.assign({}, this.size));
|
|
@@ -4070,13 +4068,10 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
4070
4068
|
if (defaultValue === undefined) {
|
|
4071
4069
|
property.get = function () { return this[computedKey]; };
|
|
4072
4070
|
}
|
|
4073
|
-
else if (typeof defaultValue === '
|
|
4074
|
-
const { clone } = DataHelper;
|
|
4071
|
+
else if (typeof defaultValue === 'function') {
|
|
4075
4072
|
property.get = function () {
|
|
4076
4073
|
let v = this[computedKey];
|
|
4077
|
-
|
|
4078
|
-
this[computedKey] = v = clone(defaultValue);
|
|
4079
|
-
return v;
|
|
4074
|
+
return v === undefined ? defaultValue(this.__leaf) : v;
|
|
4080
4075
|
};
|
|
4081
4076
|
}
|
|
4082
4077
|
if (key === 'width') {
|
|
@@ -5722,10 +5717,10 @@ let Leaf = class Leaf {
|
|
|
5722
5717
|
static changeAttr(attrName, defaultValue, fn) {
|
|
5723
5718
|
fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
5724
5719
|
}
|
|
5725
|
-
static addAttr(attrName, defaultValue, fn) {
|
|
5720
|
+
static addAttr(attrName, defaultValue, fn, helpValue) {
|
|
5726
5721
|
if (!fn)
|
|
5727
5722
|
fn = boundsType;
|
|
5728
|
-
fn(defaultValue)(this.prototype, attrName);
|
|
5723
|
+
fn(defaultValue, helpValue)(this.prototype, attrName);
|
|
5729
5724
|
}
|
|
5730
5725
|
__emitLifeEvent(type) {
|
|
5731
5726
|
if (this.hasEvent(type))
|
|
@@ -6052,7 +6047,7 @@ class LeafLevelList {
|
|
|
6052
6047
|
}
|
|
6053
6048
|
}
|
|
6054
6049
|
|
|
6055
|
-
const version = "1.
|
|
6050
|
+
const version = "1.5.1";
|
|
6056
6051
|
|
|
6057
6052
|
const debug$5 = Debug.get('LeaferCanvas');
|
|
6058
6053
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6174,7 +6169,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
6174
6169
|
else {
|
|
6175
6170
|
window.addEventListener('resize', this.windowListener = () => {
|
|
6176
6171
|
const pixelRatio = Platform.devicePixelRatio;
|
|
6177
|
-
if (this.pixelRatio !== pixelRatio) {
|
|
6172
|
+
if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
|
|
6178
6173
|
const { width, height } = this;
|
|
6179
6174
|
this.emitResize({ width, height, pixelRatio });
|
|
6180
6175
|
}
|
|
@@ -6191,7 +6186,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
6191
6186
|
checkAutoBounds(parentSize) {
|
|
6192
6187
|
const view = this.view;
|
|
6193
6188
|
const { x, y, width, height } = this.autoBounds.getBoundsFrom(parentSize);
|
|
6194
|
-
const size = { width, height, pixelRatio: Platform.devicePixelRatio };
|
|
6189
|
+
const size = { width, height, pixelRatio: this.config.pixelRatio ? this.pixelRatio : Platform.devicePixelRatio };
|
|
6195
6190
|
if (!this.isSameSize(size)) {
|
|
6196
6191
|
const { style } = view;
|
|
6197
6192
|
style.marginLeft = x + 'px';
|
|
@@ -7120,7 +7115,11 @@ const State = {
|
|
|
7120
7115
|
setStyleName() { return Plugin.need('state'); },
|
|
7121
7116
|
set() { return Plugin.need('state'); }
|
|
7122
7117
|
};
|
|
7123
|
-
const Transition = {
|
|
7118
|
+
const Transition = {
|
|
7119
|
+
list: {},
|
|
7120
|
+
register(attrName, fn) { Transition.list[attrName] = fn; },
|
|
7121
|
+
get(attrName) { return Transition.list[attrName]; }
|
|
7122
|
+
};
|
|
7124
7123
|
|
|
7125
7124
|
const { parse, objectToCanvasData } = PathConvert;
|
|
7126
7125
|
const emptyPaint = {};
|
|
@@ -7544,9 +7543,6 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7544
7543
|
this.__drawPathByBox(pen);
|
|
7545
7544
|
return pen;
|
|
7546
7545
|
}
|
|
7547
|
-
get editConfig() { return undefined; }
|
|
7548
|
-
get editOuter() { return ''; }
|
|
7549
|
-
get editInner() { return ''; }
|
|
7550
7546
|
constructor(data) {
|
|
7551
7547
|
super(data);
|
|
7552
7548
|
}
|
|
@@ -7628,8 +7624,11 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7628
7624
|
export(_filename, _options) {
|
|
7629
7625
|
return Plugin.need('export');
|
|
7630
7626
|
}
|
|
7627
|
+
syncExport(_filename, _options) {
|
|
7628
|
+
return Plugin.need('export');
|
|
7629
|
+
}
|
|
7631
7630
|
clone(data) {
|
|
7632
|
-
const json = this.toJSON();
|
|
7631
|
+
const json = DataHelper.clone(this.toJSON());
|
|
7633
7632
|
if (data)
|
|
7634
7633
|
Object.assign(json, data);
|
|
7635
7634
|
return UI_1.one(json);
|
|
@@ -7928,7 +7927,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7928
7927
|
get layoutLocked() { return !this.layouter.running; }
|
|
7929
7928
|
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
7930
7929
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
7931
|
-
get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
|
|
7930
|
+
get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
|
|
7932
7931
|
constructor(userConfig, data) {
|
|
7933
7932
|
super(data);
|
|
7934
7933
|
this.config = {
|
|
@@ -8230,6 +8229,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8230
8229
|
getPagePointByClient(clientPoint, updateClient) {
|
|
8231
8230
|
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8232
8231
|
}
|
|
8232
|
+
getClientPointByWorld(worldPoint) {
|
|
8233
|
+
const { x, y } = this.clientBounds;
|
|
8234
|
+
return { x: x + worldPoint.x, y: y + worldPoint.y };
|
|
8235
|
+
}
|
|
8233
8236
|
updateClientBounds() {
|
|
8234
8237
|
this.canvas && this.canvas.updateClientBounds();
|
|
8235
8238
|
}
|
|
@@ -10198,8 +10201,6 @@ ui$1.__updateHitCanvas = function () {
|
|
|
10198
10201
|
h.setStrokeOptions(data);
|
|
10199
10202
|
};
|
|
10200
10203
|
ui$1.__hit = function (inner) {
|
|
10201
|
-
if (Platform.name === 'miniapp')
|
|
10202
|
-
this.__drawHitPath(this.__hitCanvas);
|
|
10203
10204
|
const data = this.__;
|
|
10204
10205
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
10205
10206
|
return true;
|
|
@@ -11863,13 +11864,14 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
11863
11864
|
}
|
|
11864
11865
|
|
|
11865
11866
|
function layoutText(drawData, style) {
|
|
11866
|
-
const { rows, bounds } = drawData;
|
|
11867
|
+
const { rows, bounds } = drawData, countRows = rows.length;
|
|
11867
11868
|
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
11868
|
-
let { x, y, width, height } = bounds, realHeight = __lineHeight *
|
|
11869
|
+
let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
11869
11870
|
let starY = __baseLine;
|
|
11870
11871
|
if (__clipText && realHeight > height) {
|
|
11871
11872
|
realHeight = Math.max(height, __lineHeight);
|
|
11872
|
-
|
|
11873
|
+
if (countRows > 1)
|
|
11874
|
+
drawData.overflow = countRows;
|
|
11873
11875
|
}
|
|
11874
11876
|
else if (height || autoSizeAlign) {
|
|
11875
11877
|
switch (verticalAlign) {
|
|
@@ -11881,7 +11883,7 @@ function layoutText(drawData, style) {
|
|
|
11881
11883
|
}
|
|
11882
11884
|
starY += y;
|
|
11883
11885
|
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
11884
|
-
for (let i = 0, len =
|
|
11886
|
+
for (let i = 0, len = countRows; i < len; i++) {
|
|
11885
11887
|
row = rows[i];
|
|
11886
11888
|
row.x = x;
|
|
11887
11889
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
@@ -11950,7 +11952,7 @@ function clipText(drawData, style, x, width) {
|
|
|
11950
11952
|
if (i === end && charRight < right) {
|
|
11951
11953
|
break;
|
|
11952
11954
|
}
|
|
11953
|
-
else if (charRight < right && char.char !== ' ') {
|
|
11955
|
+
else if ((charRight < right && char.char !== ' ') || !i) {
|
|
11954
11956
|
row.data.splice(i + 1);
|
|
11955
11957
|
row.width -= char.width;
|
|
11956
11958
|
break;
|