-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
How to deal with dynamic strings #595
Comments
Right now, I don't think this is possible with Typed.js without resetting. I started a draft PR playing around with some options: #596 The main hurdle here is that Typed.js assumes it should backspace every sentence it types before moving into the next one. This doesn't work when streaming new data in, like ChatGPT. I'll need to come up with a better way to append without deleting the previous text. However, if you do want to backspace the previous text, and just begin typing the newly appended sentence, that's a much easier lift, and I could get that in a branch fairly quickly. I just wasn't sure if that's a real use-case. |
changing the text being typed without resetting the entire animation, you'll need to update the strings array of the Typed instance. but you can try creating a function that updates the strings array and then destroys the current Typed instance and creates a new one with the updated strings |
Unfortunately, destroying the instance will cause it to start typing from scratch again. If you don't destroy it, it will keep typing with the new data, but unfortunately, you get a bunch of cursors for each time it re-renders. |
I have the same scene with ChatGPT stream output . Hope typed js can support this scene. thanks |
@BoBoooooo did you manage to do it? I am wondering how do you make it to render DOM elements not just simple texts? |
Please @mattboldt add this feature, It would be a great step for typed.js, I have this site: www.progreferon.com where songs and albums info load dynamically, I did everything and came to the same conclusions that are mentioned here, please! |
Description
I am implementing an AI dialogue function, strings,i need to dynamically change the value of strings,since my data is being streamed, it may need to change while typing.
After 2 days of trying,I found that it seems that such a function cannot be achieved.
when i try to change strings value
Now, not providing a way to continue typing, I have to reset, like this
The problem with this is that all the text is printed from scratch, which doesn't satisfy my expectations.
I hope that when I receive new text, I can continue to print
like this
this demo shows print 'test1', after xxx s, print 'test2'
Do you have any good suggestions, because currently it seems that strings cannot be accepted with a state
The text was updated successfully, but these errors were encountered: