Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ellipses displaying even when the text does not exceed the limit #2

Merged
merged 4 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ const text = {
| top | number \| () => number | - | (必填)相对父元素y轴的偏移 |
| width | number | - | 文本宽度 |
| content | string | - | 文本内容 |
| color | string | - | 字体颜色 |
| fontSize | number | 14 | 字体大小 |
| fontWeight | string | 'normal' | 字体的粗细程度,一些字体只提供 normal 和 bold 两种值 |
| fontFamily | string | 'sans-serif' | 字体名称 |
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class MiniPoster {
index = prevIndex + 1;
}

if (lineClamp === lines.length + 1) {
if (lineClamp === lines.length + 1 && index < content.length) {
lines.push(content.slice(prevIndex, index - 1) + '...');
} else {
lines.push(content.slice(prevIndex, index));
Expand Down
Loading