leafer-draw 1.3.2 → 1.4.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 +23 -17
- package/dist/web.cjs.map +1 -0
- package/dist/web.esm.js +23 -17
- package/dist/web.esm.js.map +1 -0
- package/dist/web.esm.min.js +2 -1
- package/dist/web.esm.min.js.map +1 -0
- package/dist/web.js +252 -240
- package/dist/web.js.map +1 -0
- package/dist/web.min.cjs +2 -1
- package/dist/web.min.cjs.map +1 -0
- package/dist/web.min.js +2 -1
- package/dist/web.min.js.map +1 -0
- package/dist/web.module.js +252 -240
- package/dist/web.module.js.map +1 -0
- package/dist/web.module.min.js +2 -1
- package/dist/web.module.min.js.map +1 -0
- package/package.json +7 -7
package/dist/web.cjs
CHANGED
|
@@ -121,7 +121,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
else {
|
|
124
|
-
window.addEventListener('resize', () => {
|
|
124
|
+
window.addEventListener('resize', this.windowListener = () => {
|
|
125
125
|
const pixelRatio = core.Platform.devicePixelRatio;
|
|
126
126
|
if (this.pixelRatio !== pixelRatio) {
|
|
127
127
|
const { width, height } = this;
|
|
@@ -150,11 +150,9 @@ class LeaferCanvas extends core.LeaferCanvasBase {
|
|
|
150
150
|
}
|
|
151
151
|
stopAutoLayout() {
|
|
152
152
|
this.autoLayout = false;
|
|
153
|
-
this.
|
|
154
|
-
if (this.resizeObserver) {
|
|
153
|
+
if (this.resizeObserver)
|
|
155
154
|
this.resizeObserver.disconnect();
|
|
156
|
-
|
|
157
|
-
}
|
|
155
|
+
this.resizeListener = this.resizeObserver = null;
|
|
158
156
|
}
|
|
159
157
|
emitResize(size) {
|
|
160
158
|
const oldSize = {};
|
|
@@ -175,6 +173,10 @@ class LeaferCanvas extends core.LeaferCanvasBase {
|
|
|
175
173
|
destroy() {
|
|
176
174
|
if (this.view) {
|
|
177
175
|
this.stopAutoLayout();
|
|
176
|
+
if (this.windowListener) {
|
|
177
|
+
window.removeEventListener('resize', this.windowListener);
|
|
178
|
+
this.windowListener = null;
|
|
179
|
+
}
|
|
178
180
|
if (!this.unreal) {
|
|
179
181
|
const view = this.view;
|
|
180
182
|
if (view.parentElement)
|
|
@@ -201,7 +203,10 @@ function useCanvas(_canvasType, _power) {
|
|
|
201
203
|
canvas.height = height;
|
|
202
204
|
return canvas;
|
|
203
205
|
},
|
|
204
|
-
canvasToDataURL: (canvas, type, quality) =>
|
|
206
|
+
canvasToDataURL: (canvas, type, quality) => {
|
|
207
|
+
const imageType = mineType(type), url = canvas.toDataURL(imageType, quality);
|
|
208
|
+
return imageType === 'image/bmp' ? url.replace('image/png;', 'image/bmp;') : url;
|
|
209
|
+
},
|
|
205
210
|
canvasToBolb: (canvas, type, quality) => new Promise((resolve) => canvas.toBlob(resolve, mineType(type), quality)),
|
|
206
211
|
canvasSaveAs: (canvas, filename, quality) => {
|
|
207
212
|
const url = canvas.toDataURL(mineType(fileType(filename)), quality);
|
|
@@ -246,7 +251,7 @@ function useCanvas(_canvasType, _power) {
|
|
|
246
251
|
core.Platform.name = 'web';
|
|
247
252
|
core.Platform.isMobile = 'ontouchstart' in window;
|
|
248
253
|
core.Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
|
|
249
|
-
core.defineKey(core.Platform, 'devicePixelRatio', { get() { return
|
|
254
|
+
core.defineKey(core.Platform, 'devicePixelRatio', { get() { return devicePixelRatio; } });
|
|
250
255
|
const { userAgent } = navigator;
|
|
251
256
|
if (userAgent.indexOf("Firefox") > -1) {
|
|
252
257
|
core.Platform.conicGradientRotate90 = true;
|
|
@@ -522,7 +527,7 @@ class Layouter {
|
|
|
522
527
|
}
|
|
523
528
|
partLayout() {
|
|
524
529
|
var _a;
|
|
525
|
-
if (!((_a = this.__updatedList) === null || _a ===
|
|
530
|
+
if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
|
|
526
531
|
return;
|
|
527
532
|
const t = core.Run.start('PartLayout');
|
|
528
533
|
const { target, __updatedList: updateList } = this;
|
|
@@ -1445,7 +1450,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
1445
1450
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1446
1451
|
PERFORMANCE OF THIS SOFTWARE.
|
|
1447
1452
|
***************************************************************************** */
|
|
1448
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
1453
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
1449
1454
|
|
|
1450
1455
|
|
|
1451
1456
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
@@ -1506,7 +1511,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1506
1511
|
}
|
|
1507
1512
|
else {
|
|
1508
1513
|
if (!paint.patternTask) {
|
|
1509
|
-
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this,
|
|
1514
|
+
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
|
|
1510
1515
|
paint.patternTask = null;
|
|
1511
1516
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1512
1517
|
createPattern(ui, paint, pixelRatio);
|
|
@@ -1662,7 +1667,7 @@ function shadow(ui, current, shape) {
|
|
|
1662
1667
|
const end = shadow.length - 1;
|
|
1663
1668
|
toOffsetOutBounds$1(bounds, offsetOutBounds$1);
|
|
1664
1669
|
shadow.forEach((item, index) => {
|
|
1665
|
-
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, item.color);
|
|
1670
|
+
other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, draw.ColorConvert.string(item.color));
|
|
1666
1671
|
spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
|
|
1667
1672
|
drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
|
|
1668
1673
|
copyBounds = bounds;
|
|
@@ -1738,7 +1743,7 @@ function innerShadow(ui, current, shape) {
|
|
|
1738
1743
|
other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out');
|
|
1739
1744
|
copyBounds = bounds;
|
|
1740
1745
|
}
|
|
1741
|
-
other.fillWorld(copyBounds, item.color, 'source-in');
|
|
1746
|
+
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
1742
1747
|
if (ui.__worldFlipped) {
|
|
1743
1748
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1744
1749
|
}
|
|
@@ -2096,11 +2101,11 @@ const TextMode = 2;
|
|
|
2096
2101
|
function layoutChar(drawData, style, width, _height) {
|
|
2097
2102
|
const { rows } = drawData;
|
|
2098
2103
|
const { textAlign, paraIndent, letterSpacing } = style;
|
|
2099
|
-
let charX, addWordWidth, indentWidth, mode, wordChar;
|
|
2104
|
+
let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
|
|
2100
2105
|
rows.forEach(row => {
|
|
2101
2106
|
if (row.words) {
|
|
2102
|
-
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2103
|
-
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') &&
|
|
2107
|
+
indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
|
|
2108
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
|
|
2104
2109
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2105
2110
|
if (row.isOverflow && !letterSpacing)
|
|
2106
2111
|
row.textMode = true;
|
|
@@ -2112,7 +2117,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2112
2117
|
row.x += indentWidth;
|
|
2113
2118
|
charX = row.x;
|
|
2114
2119
|
row.data = [];
|
|
2115
|
-
row.words.forEach(word => {
|
|
2120
|
+
row.words.forEach((word, index) => {
|
|
2116
2121
|
if (mode === WordMode) {
|
|
2117
2122
|
wordChar = { char: '', x: charX };
|
|
2118
2123
|
charX = toWordChar(word.data, charX, wordChar);
|
|
@@ -2122,7 +2127,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2122
2127
|
else {
|
|
2123
2128
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2124
2129
|
}
|
|
2125
|
-
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2130
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
|
|
2126
2131
|
charX += addWordWidth;
|
|
2127
2132
|
row.width += addWordWidth;
|
|
2128
2133
|
}
|
|
@@ -2394,3 +2399,4 @@ Object.keys(draw).forEach(function (k) {
|
|
|
2394
2399
|
get: function () { return draw[k]; }
|
|
2395
2400
|
});
|
|
2396
2401
|
});
|
|
2402
|
+
//# sourceMappingURL=web.cjs.map
|