@leafer-ui/text 2.1.10 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/text",
3
- "version": "2.1.10",
3
+ "version": "2.2.0",
4
4
  "description": "@leafer-ui/text",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,10 +22,10 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "2.1.10"
25
+ "@leafer/core": "2.2.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "2.1.10",
29
- "@leafer-ui/interface": "2.1.10"
28
+ "@leafer/interface": "2.2.0",
29
+ "@leafer-ui/interface": "2.2.0"
30
30
  }
31
31
  }
package/src/CharLayout.ts CHANGED
@@ -8,7 +8,8 @@ const TextMode = 2 // text: 'ab c'
8
8
  export function layoutChar(drawData: ITextDrawData, style: ITextData, width: number, _height: number): void {
9
9
 
10
10
  const { rows } = drawData
11
- const { textAlign, paraIndent, __letterSpacing } = style
11
+ const { textAlign, paraIndent } = style
12
+ const useLetter = style.__letterSpacing || style.motionText
12
13
 
13
14
  const justifyLast = width && textAlign.includes('both') // 最后一行是否两端对齐
14
15
  const justify = justifyLast || (width && textAlign.includes('justify')) // 是否两端对齐文本
@@ -26,8 +27,8 @@ export function layoutChar(drawData: ITextDrawData, style: ITextData, width: num
26
27
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1) // remainingWidth / (lettersLength - 1)
27
28
  else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0
28
29
  }
29
- mode = (__letterSpacing || row.isOverflow || justifyLetter) ? CharMode : (addWordWidth ? WordMode : TextMode)
30
- if (row.isOverflow && !__letterSpacing) row.textMode = true
30
+ mode = (useLetter || row.isOverflow || justifyLetter) ? CharMode : (addWordWidth ? WordMode : TextMode)
31
+ if (row.isOverflow && !useLetter) row.textMode = true
31
32
 
32
33
  if (mode === TextMode) {
33
34
 
@@ -22,6 +22,8 @@ export function getDrawData(content: string | number, style: ITextData): ITextDr
22
22
 
23
23
  const { __padding: padding } = style
24
24
 
25
+ if (style.motionText) width = height = 0
26
+
25
27
  if (padding) {
26
28
  if (width) x = padding[left], width -= (padding[right] + padding[left]), !width && (width = 0.01) // 防止变为自动宽度
27
29
  else if (!style.autoSizeAlign) x = padding[left]