Skip to content

Commit

Permalink
Take letter-spacing into account when sizing container.
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-adstage committed Mar 28, 2017
1 parent 3a293cd commit f1edb23
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Truncate.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ export default class Truncate extends Component {
}

measureWidth(text) {
return this.canvas.measureText(text).width;
const targetStyles = window.getComputedStyle(this.refs.target);
const letterSpacing = parseFloat(targetStyles['letter-spacing']) || 0;
return this.canvas.measureText(text).width + (letterSpacing * text.length);
}

ellipsisWidth(node) {
Expand Down

0 comments on commit f1edb23

Please sign in to comment.