-
Notifications
You must be signed in to change notification settings - Fork 26
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 cursor on typing completion #14
Comments
Hey, as stated on the npm page you can't update any props after the initial render:
You should be able to achieve disabling the cursor animation after some time by doing the following:
<TypeAnimation
sequence={[
typingText,
1000,
() => {
// TODO store the updated className in state to always reference the element correctly later on with the className from the state
const typeAnimationElement = document.getElementsByClassName(cssClasses.APP_TYPING_ANIMATION +
" " + cssClasses.APP_TYING_ANIMATION_BLINKING_CURSOR);
typeAnimationElement[0].classList.remove(cssClasses.APP_TYING_ANIMATION_BLINKING_CURSOR)
// the blinking animation should stop now. To turn it on again later on, simply do typeAnimationElement[0].classList.add(...)
},
]}
className={cssClasses.APP_TYPING_ANIMATION +
" " + cssClasses.APP_TYING_ANIMATION_BLINKING_CURSOR}
/> assuming the value of .type-animation-cursor::after {
content: '|';
animation: cursor 1.1s infinite step-start;
}
@keyframes cursor {
50% {
opacity: 0;
}
} I hope that works with your styling solution. |
@maxeth Yes that works! But, if you had forwarded ref and set it to the parent div, would it work for me to do the same class adding and removing with |
Hey, I'll note this down and may add a |
@maxeth Thanks! |
Hi, the
cursor
option allows us to show or hide the cursor when the text is being typed. But when I set thecursor
prop's value from a state and change the state at the end of animation, it doesn't hide the cursor.For example, I want the cursor to show up when the text is being typed but hide it after the typing completes. I guess the cursor show and hide needs to be updated using a
useEffect
when the prop changes from the consuming component. See below code for understanding.The text was updated successfully, but these errors were encountered: