FitText.js icon indicating copy to clipboard operation
FitText.js copied to clipboard

Add optional callback to the settings object.

Open DanielJohnsson87 opened this issue 8 years ago • 3 comments

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

DanielJohnsson87 avatar Oct 21 '16 11:10 DanielJohnsson87

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

davatron5000 avatar Oct 21 '16 14:10 davatron5000

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?

DanielJohnsson87 avatar Oct 25 '16 14:10 DanielJohnsson87

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.

davatron5000 avatar Oct 25 '16 15:10 davatron5000