leafer-ui 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.esm.js CHANGED
@@ -123,7 +123,7 @@ class LeaferCanvas extends LeaferCanvasBase {
123
123
  }
124
124
  }
125
125
  else {
126
- window.addEventListener('resize', () => {
126
+ window.addEventListener('resize', this.windowListener = () => {
127
127
  const pixelRatio = Platform.devicePixelRatio;
128
128
  if (this.pixelRatio !== pixelRatio) {
129
129
  const { width, height } = this;
@@ -152,11 +152,9 @@ class LeaferCanvas extends LeaferCanvasBase {
152
152
  }
153
153
  stopAutoLayout() {
154
154
  this.autoLayout = false;
155
- this.resizeListener = null;
156
- if (this.resizeObserver) {
155
+ if (this.resizeObserver)
157
156
  this.resizeObserver.disconnect();
158
- this.resizeObserver = null;
159
- }
157
+ this.resizeListener = this.resizeObserver = null;
160
158
  }
161
159
  emitResize(size) {
162
160
  const oldSize = {};
@@ -177,6 +175,10 @@ class LeaferCanvas extends LeaferCanvasBase {
177
175
  destroy() {
178
176
  if (this.view) {
179
177
  this.stopAutoLayout();
178
+ if (this.windowListener) {
179
+ window.removeEventListener('resize', this.windowListener);
180
+ this.windowListener = null;
181
+ }
180
182
  if (!this.unreal) {
181
183
  const view = this.view;
182
184
  if (view.parentElement)
@@ -203,7 +205,10 @@ function useCanvas(_canvasType, _power) {
203
205
  canvas.height = height;
204
206
  return canvas;
205
207
  },
206
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
208
+ canvasToDataURL: (canvas, type, quality) => {
209
+ const imageType = mineType(type), url = canvas.toDataURL(imageType, quality);
210
+ return imageType === 'image/bmp' ? url.replace('image/png;', 'image/bmp;') : url;
211
+ },
207
212
  canvasToBolb: (canvas, type, quality) => new Promise((resolve) => canvas.toBlob(resolve, mineType(type), quality)),
208
213
  canvasSaveAs: (canvas, filename, quality) => {
209
214
  const url = canvas.toDataURL(mineType(fileType(filename)), quality);
@@ -248,7 +253,7 @@ function useCanvas(_canvasType, _power) {
248
253
  Platform.name = 'web';
249
254
  Platform.isMobile = 'ontouchstart' in window;
250
255
  Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
251
- defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, devicePixelRatio); } });
256
+ defineKey(Platform, 'devicePixelRatio', { get() { return devicePixelRatio; } });
252
257
  const { userAgent } = navigator;
253
258
  if (userAgent.indexOf("Firefox") > -1) {
254
259
  Platform.conicGradientRotate90 = true;
@@ -524,7 +529,7 @@ class Layouter {
524
529
  }
525
530
  partLayout() {
526
531
  var _a;
527
- if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length))
532
+ if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
528
533
  return;
529
534
  const t = Run.start('PartLayout');
530
535
  const { target, __updatedList: updateList } = this;
@@ -1054,6 +1059,7 @@ class Interaction extends InteractionBase {
1054
1059
  'pointerdown': this.onPointerDown,
1055
1060
  'mousedown': this.onMouseDown,
1056
1061
  'touchstart': this.onTouchStart,
1062
+ 'pointerleave': this.onPointerLeave,
1057
1063
  'contextmenu': this.onContextMenu,
1058
1064
  'wheel': this.onWheel,
1059
1065
  'gesturestart': this.onGesturestart,
@@ -1136,11 +1142,15 @@ class Interaction extends InteractionBase {
1136
1142
  this.usePointer || (this.usePointer = true);
1137
1143
  this.pointerDown(PointerEventHelper.convert(e, this.getLocal(e)));
1138
1144
  }
1139
- onPointerMove(e) {
1145
+ onPointerMove(e, isLeave) {
1140
1146
  if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e))
1141
1147
  return;
1142
1148
  this.usePointer || (this.usePointer = true);
1143
- this.pointerMove(PointerEventHelper.convert(e, this.getLocal(e, true)));
1149
+ const data = PointerEventHelper.convert(e, this.getLocal(e, true));
1150
+ isLeave ? this.pointerHover(data) : this.pointerMove(data);
1151
+ }
1152
+ onPointerLeave(e) {
1153
+ this.onPointerMove(e, true);
1144
1154
  }
1145
1155
  onPointerUp(e) {
1146
1156
  if (this.downData)
@@ -1907,7 +1917,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1907
1917
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1908
1918
  PERFORMANCE OF THIS SOFTWARE.
1909
1919
  ***************************************************************************** */
1910
- /* global Reflect, Promise, SuppressedError, Symbol */
1920
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1911
1921
 
1912
1922
 
1913
1923
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -1968,7 +1978,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1968
1978
  }
1969
1979
  else {
1970
1980
  if (!paint.patternTask) {
1971
- paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1981
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
1972
1982
  paint.patternTask = null;
1973
1983
  if (canvas.bounds.hit(ui.__nowWorld))
1974
1984
  createPattern(ui, paint, pixelRatio);
@@ -2124,7 +2134,7 @@ function shadow(ui, current, shape) {
2124
2134
  const end = shadow.length - 1;
2125
2135
  toOffsetOutBounds$1(bounds, offsetOutBounds$1);
2126
2136
  shadow.forEach((item, index) => {
2127
- other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, item.color);
2137
+ other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, ColorConvert.string(item.color));
2128
2138
  spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
2129
2139
  drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
2130
2140
  copyBounds = bounds;
@@ -2200,7 +2210,7 @@ function innerShadow(ui, current, shape) {
2200
2210
  other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out');
2201
2211
  copyBounds = bounds;
2202
2212
  }
2203
- other.fillWorld(copyBounds, item.color, 'source-in');
2213
+ other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
2204
2214
  if (ui.__worldFlipped) {
2205
2215
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
2206
2216
  }
@@ -2558,11 +2568,11 @@ const TextMode = 2;
2558
2568
  function layoutChar(drawData, style, width, _height) {
2559
2569
  const { rows } = drawData;
2560
2570
  const { textAlign, paraIndent, letterSpacing } = style;
2561
- let charX, addWordWidth, indentWidth, mode, wordChar;
2571
+ let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
2562
2572
  rows.forEach(row => {
2563
2573
  if (row.words) {
2564
- indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
2565
- addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
2574
+ indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
2575
+ addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
2566
2576
  mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
2567
2577
  if (row.isOverflow && !letterSpacing)
2568
2578
  row.textMode = true;
@@ -2574,7 +2584,7 @@ function layoutChar(drawData, style, width, _height) {
2574
2584
  row.x += indentWidth;
2575
2585
  charX = row.x;
2576
2586
  row.data = [];
2577
- row.words.forEach(word => {
2587
+ row.words.forEach((word, index) => {
2578
2588
  if (mode === WordMode) {
2579
2589
  wordChar = { char: '', x: charX };
2580
2590
  charX = toWordChar(word.data, charX, wordChar);
@@ -2584,7 +2594,7 @@ function layoutChar(drawData, style, width, _height) {
2584
2594
  else {
2585
2595
  charX = toChar(word.data, charX, row.data, row.isOverflow);
2586
2596
  }
2587
- if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
2597
+ if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
2588
2598
  charX += addWordWidth;
2589
2599
  row.width += addWordWidth;
2590
2600
  }
@@ -2841,3 +2851,4 @@ Object.assign(Creator, {
2841
2851
  useCanvas();
2842
2852
 
2843
2853
  export { Interaction, Layouter, LeaferCanvas, Picker, Renderer, Selector, Watcher, useCanvas };
2854
+ //# sourceMappingURL=web.esm.js.map