Open king112ola opened 1 year ago
Yes, you can track it with the onCreateTextNode
function. This function is called when the typewriter is about to add some nodes to the DOM.
Note: This function has two parameters:
character
:string
type andtextNode
:Text
type. With the string "A very long message
", thecharacter
is:A
,`,
v,... You can use the function
createTextNodeto construct a
Textnode just like in the example below or return directly the
textNode`.
Example:
<Typewriter
onInit={(typewriter) => {
typewriter.typeString('A very long message').start();
}}
options={{
onCreateTextNode: (character) => {
bottomRef.current?.scrollIntoView({
behavior: 'smooth',
});
return document.createTextNode(character);
},
}}
/>;
Thx a lot! i will give it a try asap!
how about checking if it's completed @DuckyMomo20012 ?
I had this TypeWriter as component and pass the function of Scrolltobottom as props
Sorry for the late reply, with the example in the doc:
<Typewriter
onInit={(typewriter) => {
typewriter
.typeString('Hello World!')
.callFunction(() => {
console.log('String typed out!');
})
.pauseFor(2500)
.deleteAll()
.callFunction(() => {
console.log('All strings were deleted');
})
.start();
}}
/>;
After the typeString
function, you can call function callFunction
to do an action based on typing completion, the same for function deleteAll
.
I hope all of you are doing Well :)
I need this function to track if a