-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide text before resize finishes #18
Comments
I am starting with the text transparent and then using the useFitText({onFinish}) callback to make it opaque after resizing completes. It's a bit of a pain to do this everywhere manually, but it works. |
Thanks for the idea @masonlee... I'm using this custom hook:
Edit: Ok, now I'm getting wacky with it... considering this method so I don't have to explicitly handle hiding outside of the hook:
|
I made this custom hook. It uses import { useState } from 'react';
import useFitText, { TOptions } from 'use-fit-text';
const useBetterFitText = (options?: TOptions) => {
const [color, setColor] = useState<'transparent' | undefined>('transparent');
const { ref, fontSize } = useFitText({
...options,
onFinish: (finishedFontSize: number) => {
setColor(undefined);
if (options?.onFinish) options?.onFinish(finishedFontSize);
},
});
return { ref, fontSize, color };
};
export default useBetterFitText; |
Is it possible to hide the text before the resize finishes, in order to prevent the flickering effect? What would you recommend?
Steps to reproduce:
The text was updated successfully, but these errors were encountered: