Instance Methods
These methods are the bread and butter of the animation. They all return the instance with the exception of .reset(), .restart() and .play() which kicks off the typing animation
NoteThese methods must be called before the .play() method is invoked.
// This will work
new Typeinit(".element", {
repeat: 2
})
.type("typing animation like ...")
.pause(2000)
.newLine(3)
.type("no other")
.play();
// This will not work
new Typeinit(".element", {
typingSpeed: 40
})
.play()
.type("Oops...")
.pause(2000)
.newLine(3)
.type("error");.type()
.type(text: string): TypeinitTypes the string that's passed.
.delete()
.delete(numToDel?: number | undefined, deleteOptions?: DeleteOptionsInterface | undefined): TypeinitDeletes numToDel characters or words.
It accepts two optional arguments:
numToDel: The number of characters or words to delete. Defaults to 1.deleteOptions: An object containing quick options on how the deleting should go about.Option & Default value Description delay: deleteDelaynumberThe number (in milliseconds) to wait before deleting. Defaults todeleteDelayinoptionsObjpassed to Typeinit's constructor.mode: "char""char" | "c" | "word" | "w"Sets the mode by which Typeinit should delete.speed: deletingSpeednumberSets the speed of the deletion. Defaults todeletingSpeedinoptionsObjpassed to Typeinit's constructor.
new Typeinit(".element")
.type("Hello World!")
.delete(2, {
delay: ...
mode: ...
speed: ...
})
.play().deleteAll()
.deleteAll(ease?: boolean | undefined, deleteAllOptions?: DeleteAllOptionsInterface | undefined): TypeinitDeletes all the characters in the target element.
It accepts two optional arguments:
ease: If set totrue, an effect will be applied while deleting. Defaults tofalse.deleteAllOptions: An object containing quick options on how the deleting should go about.Option & Default value Description delay: deleteDelaynumberThe number (in milliseconds) to wait before deleting. Defaults todeleteDelayinoptionsObjpassed to Typeinit's constructor.speed: deletingSpeednumberSets the speed of the deletion. Defaults todeletingSpeedinoptionsObjpassed to Typeinit's constructor.
new Typeinit(".element")
.type("Hello World!")
.deleteAll(true, {
delay: ...
speed: ...
})
.play().pause()
.pause(ms?: number | undefined): TypeinitPauses the animation for the ms(in milliseconds) passed. Defaults to pause in optionsObj passed to Typeinit's constructor.
.newLine()
.newLine(numOfLines?: number | undefined): TypeinitAdds a new line to the element.
.reset()
.reset(): voidResets the Target element and destroys the Typeinit instance.
.restart()
.restart(): voidRestarts the typing animation.
.play()
.play(): voidKicks off the animation.