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

Rounding issue in 'getLineHeight' method #55

Open
superelement opened this issue Sep 22, 2016 · 1 comment
Open

Rounding issue in 'getLineHeight' method #55

superelement opened this issue Sep 22, 2016 · 1 comment

Comments

@superelement
Copy link

The method getLineHeight uses parseInt, which always rounds decimal numbers down. Chrome returns a decimal when calling computeStyle, which can (in some cases) be something like 23.994. So in this case Chrome will calculate the value to be 23, but FF and IE round it up to 24. This small difference though can mean the difference between lines failing to truncate to the correct number of lines. I propose something like this Math.round(parseFloat(lh)) instead of parseInt(lh) to give consistent results across browsers.
Tested on Chrome 53.0.2785.116 m (64-bit), FireFox 48.0.2, Microsoft Edge 38.14393.0.0.

@superelement
Copy link
Author

I've done a pull request #56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant