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/dist/web.esm.js CHANGED
@@ -125,7 +125,7 @@ class LeaferCanvas extends LeaferCanvasBase {
125
125
  else {
126
126
  window.addEventListener('resize', this.windowListener = () => {
127
127
  const pixelRatio = Platform.devicePixelRatio;
128
- if (this.pixelRatio !== pixelRatio) {
128
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
129
129
  const { width, height } = this;
130
130
  this.emitResize({ width, height, pixelRatio });
131
131
  }
@@ -142,7 +142,7 @@ class LeaferCanvas extends LeaferCanvasBase {
142
142
  checkAutoBounds(parentSize) {
143
143
  const view = this.view;
144
144
  const { x, y, width, height } = this.autoBounds.getBoundsFrom(parentSize);
145
- const size = { width, height, pixelRatio: Platform.devicePixelRatio };
145
+ const size = { width, height, pixelRatio: this.config.pixelRatio ? this.pixelRatio : Platform.devicePixelRatio };
146
146
  if (!this.isSameSize(size)) {
147
147
  const { style } = view;
148
148
  style.marginLeft = x + 'px';
@@ -2634,13 +2634,14 @@ function toChar(data, charX, rowData, isOverflow) {
2634
2634
  }
2635
2635
 
2636
2636
  function layoutText(drawData, style) {
2637
- const { rows, bounds } = drawData;
2637
+ const { rows, bounds } = drawData, countRows = rows.length;
2638
2638
  const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
2639
- let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2639
+ let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2640
2640
  let starY = __baseLine;
2641
2641
  if (__clipText && realHeight > height) {
2642
2642
  realHeight = Math.max(height, __lineHeight);
2643
- drawData.overflow = rows.length;
2643
+ if (countRows > 1)
2644
+ drawData.overflow = countRows;
2644
2645
  }
2645
2646
  else if (height || autoSizeAlign) {
2646
2647
  switch (verticalAlign) {
@@ -2652,7 +2653,7 @@ function layoutText(drawData, style) {
2652
2653
  }
2653
2654
  starY += y;
2654
2655
  let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
2655
- for (let i = 0, len = rows.length; i < len; i++) {
2656
+ for (let i = 0, len = countRows; i < len; i++) {
2656
2657
  row = rows[i];
2657
2658
  row.x = x;
2658
2659
  if (row.width < width || (row.width > width && !__clipText)) {
@@ -2721,7 +2722,7 @@ function clipText(drawData, style, x, width) {
2721
2722
  if (i === end && charRight < right) {
2722
2723
  break;
2723
2724
  }
2724
- else if (charRight < right && char.char !== ' ') {
2725
+ else if ((charRight < right && char.char !== ' ') || !i) {
2725
2726
  row.data.splice(i + 1);
2726
2727
  row.width -= char.width;
2727
2728
  break;