Skip to content

Commit

Permalink
fix(TextEllipsis): optimize limit function
Browse files Browse the repository at this point in the history
  • Loading branch information
vvpvvp committed Jan 23, 2019
1 parent 2096518 commit aa827fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/textellipsis/textellipsis.vue
Expand Up @@ -66,7 +66,11 @@ export default {
more.style.display = 'inline-block';
let text = this.text;
while (title.offsetHeight > this.height && n > 0) {
textDom.innerText = text = text.substring(0, text.length-1);
if(title.offsetHeight > this.height * 3) {
textDom.innerText = text = text.substring(0, Math.floor(text.length / 2));
} else {
textDom.innerText = text = text.substring(0, text.length-1);
}
n--;
}
this.$emit('hide');
Expand Down

0 comments on commit aa827fe

Please sign in to comment.