leafer-ui 1.3.3 → 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 CHANGED
@@ -122,7 +122,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
122
122
  }
123
123
  }
124
124
  else {
125
- window.addEventListener('resize', () => {
125
+ window.addEventListener('resize', this.windowListener = () => {
126
126
  const pixelRatio = core.Platform.devicePixelRatio;
127
127
  if (this.pixelRatio !== pixelRatio) {
128
128
  const { width, height } = this;
@@ -151,11 +151,9 @@ class LeaferCanvas extends core.LeaferCanvasBase {
151
151
  }
152
152
  stopAutoLayout() {
153
153
  this.autoLayout = false;
154
- this.resizeListener = null;
155
- if (this.resizeObserver) {
154
+ if (this.resizeObserver)
156
155
  this.resizeObserver.disconnect();
157
- this.resizeObserver = null;
158
- }
156
+ this.resizeListener = this.resizeObserver = null;
159
157
  }
160
158
  emitResize(size) {
161
159
  const oldSize = {};
@@ -176,6 +174,10 @@ class LeaferCanvas extends core.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) => canvas.toDataURL(mineType(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
  core.Platform.name = 'web';
248
253
  core.Platform.isMobile = 'ontouchstart' in window;
249
254
  core.Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
250
- core.defineKey(core.Platform, 'devicePixelRatio', { get() { return Math.max(1, devicePixelRatio); } });
255
+ core.defineKey(core.Platform, 'devicePixelRatio', { get() { return devicePixelRatio; } });
251
256
  const { userAgent } = navigator;
252
257
  if (userAgent.indexOf("Firefox") > -1) {
253
258
  core.Platform.conicGradientRotate90 = true;
@@ -1053,6 +1058,7 @@ class Interaction extends core$1.InteractionBase {
1053
1058
  'pointerdown': this.onPointerDown,
1054
1059
  'mousedown': this.onMouseDown,
1055
1060
  'touchstart': this.onTouchStart,
1061
+ 'pointerleave': this.onPointerLeave,
1056
1062
  'contextmenu': this.onContextMenu,
1057
1063
  'wheel': this.onWheel,
1058
1064
  'gesturestart': this.onGesturestart,
@@ -1135,11 +1141,15 @@ class Interaction extends core$1.InteractionBase {
1135
1141
  this.usePointer || (this.usePointer = true);
1136
1142
  this.pointerDown(PointerEventHelper.convert(e, this.getLocal(e)));
1137
1143
  }
1138
- onPointerMove(e) {
1144
+ onPointerMove(e, isLeave) {
1139
1145
  if (this.config.pointer.touch || this.useMultiTouch || this.preventWindowPointer(e))
1140
1146
  return;
1141
1147
  this.usePointer || (this.usePointer = true);
1142
- this.pointerMove(PointerEventHelper.convert(e, this.getLocal(e, true)));
1148
+ const data = PointerEventHelper.convert(e, this.getLocal(e, true));
1149
+ isLeave ? this.pointerHover(data) : this.pointerMove(data);
1150
+ }
1151
+ onPointerLeave(e) {
1152
+ this.onPointerMove(e, true);
1143
1153
  }
1144
1154
  onPointerUp(e) {
1145
1155
  if (this.downData)
@@ -2557,11 +2567,11 @@ const TextMode = 2;
2557
2567
  function layoutChar(drawData, style, width, _height) {
2558
2568
  const { rows } = drawData;
2559
2569
  const { textAlign, paraIndent, letterSpacing } = style;
2560
- let charX, addWordWidth, indentWidth, mode, wordChar;
2570
+ let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
2561
2571
  rows.forEach(row => {
2562
2572
  if (row.words) {
2563
- indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
2564
- addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
2573
+ indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
2574
+ addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
2565
2575
  mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
2566
2576
  if (row.isOverflow && !letterSpacing)
2567
2577
  row.textMode = true;
@@ -2573,7 +2583,7 @@ function layoutChar(drawData, style, width, _height) {
2573
2583
  row.x += indentWidth;
2574
2584
  charX = row.x;
2575
2585
  row.data = [];
2576
- row.words.forEach(word => {
2586
+ row.words.forEach((word, index) => {
2577
2587
  if (mode === WordMode) {
2578
2588
  wordChar = { char: '', x: charX };
2579
2589
  charX = toWordChar(word.data, charX, wordChar);
@@ -2583,7 +2593,7 @@ function layoutChar(drawData, style, width, _height) {
2583
2593
  else {
2584
2594
  charX = toChar(word.data, charX, row.data, row.isOverflow);
2585
2595
  }
2586
- if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
2596
+ if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
2587
2597
  charX += addWordWidth;
2588
2598
  row.width += addWordWidth;
2589
2599
  }
@@ -2863,3 +2873,4 @@ Object.keys(core$1).forEach(function (k) {
2863
2873
  get: function () { return core$1[k]; }
2864
2874
  });
2865
2875
  });
2876
+ //# sourceMappingURL=web.cjs.map