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
643 stars 122 forks source link

Callback after completion? #9

Closed justinfrench closed 10 years ago

justinfrench commented 10 years ago

Thanks for an awesome library, works great!

I want to use the resulting font size after textFit() has been executed, something like this:

fitText(...);
doSomethingElse();

I'm finding that doSomethingElse() is being called before fitText() has done it's thing, so the I'm getting the original font size. Wrapping doSomethingElse() in a timeout helps, but introduces a lag into the UI.

Is there a way to set-up a callback so that doSomethingElse() is only run after fitText() has finished?

STRML commented 10 years ago

If you're using the master version (and not the example script), textFit() is synchronous. It shouldn't be possible for anything to run before it's finished. Could you post a jsfiddle?