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