@leafer-ui/text 1.0.0-rc.23 → 1.0.0-rc.25

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": "1.0.0-rc.23",
3
+ "version": "1.0.0-rc.25",
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": "1.0.0-rc.23"
25
+ "@leafer/core": "1.0.0-rc.25"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.0.0-rc.23",
29
- "@leafer-ui/interface": "1.0.0-rc.23"
28
+ "@leafer/interface": "1.0.0-rc.25",
29
+ "@leafer-ui/interface": "1.0.0-rc.25"
30
30
  }
31
31
  }
package/src/CharLayout.ts CHANGED
@@ -36,11 +36,11 @@ export function layoutChar(drawData: ITextDrawData, style: ITextData, width: num
36
36
 
37
37
  wordChar = { char: '', x: charX }
38
38
  charX = toWordChar(word.data, charX, wordChar)
39
- if (wordChar.char !== ' ') row.data.push(wordChar)
39
+ if (row.isOverflow || wordChar.char !== ' ') row.data.push(wordChar)
40
40
 
41
41
  } else {
42
42
 
43
- charX = toChar(word.data, charX, row.data)
43
+ charX = toChar(word.data, charX, row.data, row.isOverflow)
44
44
 
45
45
  }
46
46
 
@@ -75,9 +75,9 @@ function toWordChar(data: ITextCharData[], charX: number, wordChar: ITextCharDat
75
75
  return charX
76
76
  }
77
77
 
78
- function toChar(data: ITextCharData[], charX: number, rowData: ITextCharData[]): number {
78
+ function toChar(data: ITextCharData[], charX: number, rowData: ITextCharData[], isOverflow?: boolean): number {
79
79
  data.forEach(char => {
80
- if (char.char !== ' ') {
80
+ if (isOverflow || char.char !== ' ') {
81
81
  char.x = charX
82
82
  rowData.push(char)
83
83
  }
package/src/TextLayout.ts CHANGED
@@ -33,12 +33,14 @@ export function layoutText(drawData: ITextDrawData, style: ITextData): void {
33
33
  row = rows[i]
34
34
  row.x = x
35
35
 
36
- switch (textAlign) {
37
- case 'center':
38
- row.x += (width - row.width) / 2
39
- break
40
- case 'right':
41
- row.x += width - row.width
36
+ if (row.width < width || (row.width > width && !__clipText)) {
37
+ switch (textAlign) {
38
+ case 'center':
39
+ row.x += (width - row.width) / 2
40
+ break
41
+ case 'right':
42
+ row.x += width - row.width
43
+ }
42
44
  }
43
45
 
44
46
  if (row.paraStart && paraSpacing && i > 0) starY += paraSpacing