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): Typeinit

Types the string that's passed.

.delete()

.delete(numToDel?: number | undefined, deleteOptions?: DeleteOptionsInterface | undefined): Typeinit

Deletes 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 valueDescription
    delay: deleteDelaynumber The number (in milliseconds) to wait before deleting. Defaults to deleteDelay in optionsObj passed to Typeinit's constructor.
    mode: "char""char" | "c" | "word" | "w" Sets the mode by which Typeinit should delete.
    speed: deletingSpeednumber Sets the speed of the deletion. Defaults to deletingSpeed in optionsObj passed to Typeinit's constructor.
new Typeinit(".element")
    .type("Hello World!")
    .delete(2, {
        delay: ...
        mode: ...
        speed: ...
    })
    .play()

.deleteAll()

.deleteAll(ease?: boolean | undefined, deleteAllOptions?: DeleteAllOptionsInterface | undefined): Typeinit

Deletes all the characters in the target element.

It accepts two optional arguments:

  • ease: If set to true, an effect will be applied while deleting. Defaults to false.
  • deleteAllOptions: An object containing quick options on how the deleting should go about.
    Option & Default valueDescription
    delay: deleteDelaynumber The number (in milliseconds) to wait before deleting. Defaults to deleteDelay in optionsObj passed to Typeinit's constructor.
    speed: deletingSpeednumber Sets the speed of the deletion. Defaults to deletingSpeed in optionsObj passed to Typeinit's constructor.
new Typeinit(".element")
    .type("Hello World!")
    .deleteAll(true, {
        delay: ...
        speed: ...
    })
    .play()

.pause()

.pause(ms?: number | undefined): Typeinit

Pauses the animation for the ms(in milliseconds) passed. Defaults to pause in optionsObj passed to Typeinit's constructor.

.newLine()

.newLine(numOfLines?: number | undefined): Typeinit

Adds a new line to the element.

.reset()

.reset(): void

Resets the Target element and destroys the Typeinit instance.

.restart()

.restart(): void

Restarts the typing animation.

.play()

.play(): void

Kicks off the animation.