1.0.1 • Published 5 years ago

clickety v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Clickety

Make rich typewriter effects

Demo

live demo

Installation

NodeJS

npm install --save clickety

Script

Browser scripts at /dist/clickety.min.js

This library uses Promise, so you might need promise-polifill for IE.

Usage

Create a typer instance.

const typer = new Clickety('.area')

Example

<div class="area"></div>
const typer = new Clickety(".area")

//sequences of actions
typer
    .init()
    .type("Hello! ", 150)
    .type("this is ", 100)
    .type("clickety", 200)
    .prev(7, 80)
    .backspace(1, 100)
    .type("C", 200)
    .prev(9, 80)
    .enter(100)
    .end(500)
    .type(".",80)

Constructor

constructor(element, settings)

parameters

namedescriptiontypedefault
elementSet the container.DOM Eelement
settings.container_classSet the class of the container.String'clickety_container'
settings.line_classSet the class of each line.String'clickety_line'
settings.text_classSet the class of each text block.String'clickety_text'
settings.cursor_classSet the class of the cursor.String'clickety_cursor'
settings.cursorSet the innerHTML of the cursor.String'|'

Methods

Here are typer instance's methonds.

All parameters about time are using milliseconds.

methoddescriptionparameters
initInitialize the typeing area, this must be called to init the container.init()
typeType words.type(string, speed)
pausepausepause(ms)
enterPress enter.enter(delay)
backspacePress backspace.backspace(times, speed)
deletePress delete.delete(times, speed)
prevPress left.prev(times, speed)
nextPress right.next(times, speed)
endMove cursor to the end of the line.end(delay)
homeMove cursor to the start of the line.home(delay)
thenAdd callback to Promise chain.then(callback)

CSS

Css file at /dist/clickety.css,

or you can just copy belows to your custom style sheets.

.clickety_text {
    display: inline-block;
    min-height: 1rem;
}

.clickety_cursor {
    margin: 0 -0.5rem;
    display: inline-block;
    width: 1rem;
    text-align: center;
    animation: blink 1.2s infinite;
}

@keyframes blink {
    0%,60% {
        opacity: 1;
    }
    61%, 100% {
        opacity: 0;
    }
}