@leafer-ui/miniapp 2.1.11 → 2.2.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.
@@ -817,6 +817,11 @@ const PointHelper = {
817
817
  toOuterOf(t, matrix, to) {
818
818
  toOuterPoint$3(matrix, t, to);
819
819
  },
820
+ toVertical(t, rotation, verticalDistance, to) {
821
+ const r = rotation * OneRadian;
822
+ t.x += -Math.sin(r) * verticalDistance;
823
+ t.y += Math.cos(r) * verticalDistance;
824
+ },
820
825
  getCenter(t, to) {
821
826
  return {
822
827
  x: t.x + (to.x - t.x) / 2,
@@ -6985,7 +6990,7 @@ class LeafLevelList {
6985
6990
  }
6986
6991
  }
6987
6992
 
6988
- const version = "2.1.11";
6993
+ const version = "2.2.0";
6989
6994
 
6990
6995
  class LeaferCanvas extends LeaferCanvasBase {
6991
6996
  get allowBackgroundColor() {
@@ -9788,7 +9793,7 @@ let Text = class Text extends UI {
9788
9793
  data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
9789
9794
  stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
9790
9795
  stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
9791
- stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
9796
+ stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
9792
9797
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
9793
9798
  }
9794
9799
  __updateBoxBounds() {
@@ -9813,7 +9818,7 @@ let Text = class Text extends UI {
9813
9818
  this.__updateNaturalSize();
9814
9819
  } else super.__updateBoxBounds();
9815
9820
  if (italic) b.width += fontSize * .16;
9816
- DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
9821
+ DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds) && !data.motionText);
9817
9822
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
9818
9823
  }
9819
9824
  __updateRenderSpread() {
@@ -11416,8 +11421,10 @@ ui$1.__hit = function(inner, forceHitFill) {
11416
11421
  if (!needHitFillPath && !needHitStrokePath) return false;
11417
11422
  const radiusWidth = inner.radiusX * 2;
11418
11423
  let hitWidth = radiusWidth;
11424
+ let {strokeAlign: strokeAlign} = data;
11425
+ if (data.motionText) hitWidth += data.fontSize / 2, strokeAlign = "center";
11419
11426
  if (needHitStrokePath) {
11420
- switch (data.strokeAlign) {
11427
+ switch (strokeAlign) {
11421
11428
  case "inside":
11422
11429
  hitWidth += strokeWidth * 2;
11423
11430
  if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth)) return true;
@@ -11451,9 +11458,9 @@ rect.__hitFill = box$1.__hitFill = function(inner) {
11451
11458
  };
11452
11459
 
11453
11460
  Text.prototype.__drawHitPath = function(canvas) {
11454
- const {__lineHeight: __lineHeight, fontSize: fontSize, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __textDrawData: data} = this.__;
11461
+ const data = this.__, {__lineHeight: __lineHeight, fontSize: fontSize, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __textDrawData: drawData} = data;
11455
11462
  canvas.beginPath();
11456
- if (__letterSpacing < 0) this.__drawPathByBox(canvas); else data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
11463
+ if (data.motionText) this.__drawPathByData(canvas, data.__pathForMotionText); else if (__letterSpacing < 0) this.__drawPathByBox(canvas); else drawData.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
11457
11464
  };
11458
11465
 
11459
11466
  Group.prototype.pick = function(hitPoint, options) {
@@ -11640,7 +11647,8 @@ function fillPathOrText(ui, canvas, renderOptions) {
11640
11647
  ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
11641
11648
  }
11642
11649
 
11643
- function fillText(ui, canvas, _renderOptions) {
11650
+ function fillText(ui, canvas, renderOptions) {
11651
+ if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
11644
11652
  const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
11645
11653
  if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
11646
11654
  let row;
@@ -13002,7 +13010,8 @@ const TextMode = 2;
13002
13010
 
13003
13011
  function layoutChar(drawData, style, width, _height) {
13004
13012
  const {rows: rows} = drawData;
13005
- const {textAlign: textAlign, paraIndent: paraIndent, __letterSpacing: __letterSpacing} = style;
13013
+ const {textAlign: textAlign, paraIndent: paraIndent} = style;
13014
+ const useLetter = style.__letterSpacing || style.motionText;
13006
13015
  const justifyLast = width && textAlign.includes("both");
13007
13016
  const justify = justifyLast || width && textAlign.includes("justify");
13008
13017
  const justifyLetter = justify && textAlign.includes("letter");
@@ -13015,8 +13024,8 @@ function layoutChar(drawData, style, width, _height) {
13015
13024
  remainingWidth = width - row.width - indentWidth;
13016
13025
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
13017
13026
  }
13018
- mode = __letterSpacing || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
13019
- if (row.isOverflow && !__letterSpacing) row.textMode = true;
13027
+ mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
13028
+ if (row.isOverflow && !useLetter) row.textMode = true;
13020
13029
  if (mode === TextMode) {
13021
13030
  row.x += indentWidth;
13022
13031
  toTextChar$1(row);
@@ -13217,6 +13226,7 @@ function getDrawData(content, style) {
13217
13226
  let width = style.__getInput("width") || 0;
13218
13227
  let height = style.__getInput("height") || 0;
13219
13228
  const {__padding: padding} = style;
13229
+ if (style.motionText) width = height = 0;
13220
13230
  if (padding) {
13221
13231
  if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
13222
13232
  if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];