0.0.3 • Published 4 years ago

smooth-input v0.0.3

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

smooth-input

Library for imitate human input

Installation

npm i smooth-input

Simple example

Demo Animation

import {SmoothInput} from 'smooth-input';
const h1 = document.getElementById('title')
const si = new SmoothInput(h1, {
    symbolsPerSecond: 10,
    delay: 5000,
    symbolsDelay: {' ': 500},
    text: 'Hello, World!'
})

Initialization

import {SmoothInput} from 'smooth-input';
const si = new SmoothInput(htmlElement, {...})

If you want to use default carriage you have to import css:

import 'smooth-input/css/style.css'

And set special class to text container:

smooth-text-container

Options

NameTypeDefaultDescription
symbolsPerSecondnumber10Count of symbols per second
delaynumber0Time before start
symbolsDelayObject{}Delay for certain symbols
textstring or nullnullContent of target element. If there isn't take textContent of element
carriageCarriageOptions-Config for default carriage

#####CarriageOptions |Name|Type|Default|Description| |---|---|---|---| |visible|boolean|true|Visibility of carriage| |hideAfterInput|boolean|true|Hide carriage after all text input| |hideDelay|boolean|true|Time before hide carriage after input|

Methods

Methods of SmoothInput instance


setText(text: string): void

Removing old text and start input new one

Parameters:

NameTypeDescription
textstring-

Returns: void


addTextToEnd(text: string): void

Adding text to enter at the end

Parameters:

NameTypeDescription
textstring-

Returns: void

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago