@leafer-ui/text 1.0.0-rc.28 → 1.0.0-rc.30

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.28",
3
+ "version": "1.0.0-rc.30",
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.28"
25
+ "@leafer/core": "1.0.0-rc.30"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.0.0-rc.28",
29
- "@leafer-ui/interface": "1.0.0-rc.28"
28
+ "@leafer/interface": "1.0.0-rc.30",
29
+ "@leafer-ui/interface": "1.0.0-rc.30"
30
30
  }
31
31
  }
package/src/TextClip.ts CHANGED
@@ -3,7 +3,8 @@ import { Platform } from '@leafer/core'
3
3
  import { ITextCharData, ITextData, ITextDrawData, ITextRowData } from '@leafer-ui/interface'
4
4
 
5
5
 
6
- export function clipText(drawData: ITextDrawData, style: ITextData): void {
6
+ export function clipText(drawData: ITextDrawData, style: ITextData, x: number, width: number): void {
7
+ if (!width) return
7
8
 
8
9
  const { rows, overflow } = drawData
9
10
  let { textOverflow } = style
@@ -15,7 +16,7 @@ export function clipText(drawData: ITextDrawData, style: ITextData): void {
15
16
 
16
17
  let char: ITextCharData, charRight: number
17
18
  const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0
18
- const right = style.x + style.width - ellipsisWidth
19
+ const right = x + width - ellipsisWidth
19
20
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]]
20
21
 
21
22
  list.forEach(row => {
@@ -48,7 +48,7 @@ export function getDrawData(content: string, style: ITextData): ITextDrawData {
48
48
 
49
49
  layoutChar(drawData, style, width, height) // set char.x
50
50
 
51
- if (drawData.overflow) clipText(drawData, style)
51
+ if (drawData.overflow) clipText(drawData, style, x, width)
52
52
 
53
53
  if (textDecoration !== 'none') decorationText(drawData, style)
54
54