🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

js-type-text

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-type-text

A lightweight & fun typing animation built with vanilla JavaScript. Framework agnostic so it works with Vue.js, React, and everything else.

2.0.6
latest
Source
npm
Version published
Weekly downloads
3
-90.32%
Maintainers
1
Weekly downloads
 
Created
Source

js-type-text

A framework agnostic typing animation package built with vanilla JavaScript. Works with Vue.js, React, and everything else.

screen recording of js-type-text typing its own url, npmjs.com/js-type-text

This animation works with any font! However you will find that it looks its best when paired with Monospaced fonts as their letters have a fixed width.

Installation

npm install js-type-text

Usage

// import the package
import jsTypeText from 'js-type-text';

// start typing
jsTypeText.start(config, callback);

// stop typing and/or cursor.
jsTypeText.stop();

Configuration

jsTypeText.start({
  text: "Your Text Here",
  speed: 110,
  cursor: true,
  cursorSpeed: 350,
  cursorStyle: "vertical"
}, callback);
ValueTypeRequiredDescriptionDefault
textStringRequiredThe string to be typed.N/A
speedNumberOptionalTime in ms per character typed.110
cursorBooleanOptionalShow or hide cursorTRUE
cursorSpeedNumberOptionalTime in ms per cursor blink. Set to 0 to disable blink.350
cursorStyleStringOptional"vertical" or "horizontal" or any html character you'd like. For example "▗"."horizontal" (ie. the underscore symbol _ )

Note: Avoid jitter with custom HTML cursors by setting a CSS line-height value.

Examples

Vanilla JS

jsTypeText.start({
  text: "Welcome to my site"
}, function (result) {
  document.getElementById('myElement').innerHTML = result;
});

// optionally stop the typing and/or cursorpoint.
jsTypeText.stop();


Vue.js

data() {
  return: {
    myTitle: ''
  }
},
created: function () {
  jsTypeText.start({
    text: "Welcome to my site"
  }, (result) => {
    this.myTitle = result;
  })
},
beforeDestroy: function () {
  jsTypeText.stop();
}

React.js

class myPage extends React.Component{
  state = {
    myTitle:""
  }
  componentDidMount () {
    jsTypeText.start({
      text: "Welcome to my site"
    }, (result) => {
      this.setState({myTitle: result})
    }
  }
  componentWillUnmount () {
    jsTypeText.stop()
  }
  render(){
    return(<h1>{this.state.myTitle}</h1>)
  }
}

SIC © Jared Krause

Keywords

type

FAQs

Package last updated on 07 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts