Skip to content

Commit

Permalink
Small text fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vasturiano committed Nov 16, 2023
1 parent 90b9e70 commit 5b7b35a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const ellipsisText = (
const getCharsWidth = numChars => measureTextWidth(text.slice(0, numChars), fontSize, measureCfg);

let numChars = Math.ceil(text.length * (textSpace / fullTextWidth));
while (getCharsWidth(numChars) < textSpace) numChars++;
while (getCharsWidth(numChars) > textSpace) numChars--;
while (getCharsWidth(numChars) < textSpace && numChars < text.length) numChars++;
while (getCharsWidth(numChars) > textSpace && numChars > 0) numChars--;

return numChars <= minRealChars ? '' : `${text.slice(0, numChars)}${elChar}`;
};
Expand Down

0 comments on commit 5b7b35a

Please sign in to comment.