Skip to content

Fixes for some bugs #72

Description

@srlm89

Hi @STRML, your textFit came in handy for a project, and I have been using it exhaustively for the past months. In the journey I discovered some bugs, which I wanted to share as a gesture of appreciation for your great initial work.

1️⃣ Bug on reprocessing: here. As done above, the actual assignment is missing.

2️⃣ Bug on height assignment: here. The issue I found is that this assignment creates an overflow if some children has bottom padding. I ended up removing this assignment in my refactored version.

3️⃣ The mimified version lacks this improvement. I struggled with the mimified version because it uses scrollWidth and scrollHeight, and I was having different behaviors in different browsers (Safari vs Chrome). I am using clientHeight and clientWidth as it gave me better results than getBoundingClientRect() with some transformations.

4️⃣ The last issue is here. I discovered, in Safari, that with some custom fonts, the synchronous nature of the script was failing to properly read the new dimensions of the element after changing the font. I ended up creating an async version using the ResizeObserver API.

Finally, I leave current version as an attachment in case it might be useful.

text_fit.async.js

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions