davatron5000 / FitText.js

A jQuery plugin for inflating web type
http://fittextjs.com
6.75k stars 1.39k forks source link

Add optional callback to the settings object. #160

Open DanielJohnsson87 opened 8 years ago

DanielJohnsson87 commented 8 years ago

I'v added a callback to the settings object. It will run once the $.each functions is done.

davatron5000 commented 8 years ago

Hey thanks for contributing! What's the usecase for this? That callback could get called thousands of times onresize.

DanielJohnsson87 commented 8 years ago

Sorry for the bad explanation.

The usecase for me was to add a class to the elements effected after page load once the elements font-size is set. To prevent flash of unstyled content I've hidden all titles and in the callback I will add a animate-in/show css class to display the titles after the correct font-size is set.

I'm aware that the callback would run on every 'onresize'-event and I'm handling that on my side. But it didn't make much sense to add a callback to the plugin if it only fires sometimes.

Perhaps adding a variable to the callback to control if the callback should run once or every time could be a solution? The default being that the callback only runs one time?

davatron5000 commented 8 years ago

Ah. I think I sorta understand. Might be kinda niche to your implementation. The need for a callback hasn't come up much in the last 5yrs. Do you have a CodePen or something showing what you're doing? I want to be sure I understand it completely.