STRML / textFit

A jQuery-free component that quickly fits single and multi-line text to the width (and optionally height) of its container.
https://textfit.strml.net
637 stars 123 forks source link

Use scrollWidth/Height instead of offsetWidth/Height #18

Closed lewang closed 9 years ago

lewang commented 9 years ago

We ran into a situation where the offsetWidth was capped by the parent, so the text didn't resize properly.

According to this: http://stackoverflow.com/questions/21064101/understanding-offsetwidth-clientwidth-scrollwidth-and-height-respectively , scroll* should be used in this context anyway.

STRML commented 9 years ago

That is a really nice SO answer. Thanks for this.

STRML commented 9 years ago

I believe L167 should be scrollHeight as well then, in this case?

lewang commented 9 years ago

I've force pushed an update. "offset" no longer occurs in the code.

STRML commented 9 years ago

Thanks!

STRML commented 9 years ago

You're up on 2.2.1.

STRML commented 3 years ago

@lewang To support fractional sizes / zoom, we've moved to getBoundingClientRect(). Before I release, can you recall the situation in which offsetHeight/Width was required? We can't reproduce it.

lewang commented 3 years ago

I don't recall this context, sorry.