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

Fixed textFit working with chrome and various sizes and using % #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hovi
Copy link

@hovi hovi commented May 16, 2018

I tried to use this library, but I kept having these strange things happening - sometimes at specific width/height of my browser using Chrome, I always had textFit finishing with minimum font size although there was a lot of space.
After debugging I found out, that scrollWidth and originalWidth (or with height) was 1 and it never matched the condition. I am pretty sure this was caused by rounding error either in browser itself or somewhere in your code (I suspect it's chrome issue), because I am using different units (%, em).

Once I changed condition to accept 1 px difference, code works fine in Chrome too, but it also changes behaviour as it may detect something sooner/later, etc.

This is probably not ideal fix, but it works for me well. Not expect this to be merged, but to discuss this.

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

Successfully merging this pull request may close these issues.

1 participant