1.1.1 • Published 4 years ago

slow-typer v1.1.1

Weekly downloads
10
License
MIT
Repository
github
Last release
4 years ago

Slow Typer

Slow Typer is an easy to use JavaScript typewriter effect class.

Installation

yarn add slow-typer

Initialization

// Import
import SlowTyper from 'slow-typer'

// Init (see "Parameters" for available options)
const typewriter = new SlowTyper('#target', { delay: 50, jitter: 0 })

Parameters

NameTypeDescription
targetMixedThe initial target. Can be either a CSS selector or an instance of HTMLElement
optionsObjectAn object overriding the default settings (see "Options")

Options

NameTypeDefaultDescription
delayNumber100The average delay between two keystrokes in milliseconds.
jitterNumber25The possible random variation in delay in milliseconds. Total delay will be delay ± jitter

Properties

NameTypeDescription
targetMixedThe element in which to output the text. Can be either a CSS selector or an instance of HTMLElement.
delayNumberThe average delay between two keystrokes in milliseconds.
jitterNumberThe possible random variation in delay in milliseconds. Total delay will be delay ± jitter

Methods

NameDescription
write(text)Outputs text to current target
writeTo(target, text)Changes current target to target and outputs text to it
clear()Clears target text

Demo

You can try a demo on Codepen (Might not be up to date)