1.6.2 • Published 5 years ago

react-typing-animation v1.6.2

Weekly downloads
1,848
License
MIT
Repository
github
Last release
5 years ago

React-typing-animation

npm version Licence

A fully-featured typing animation in React that supports any valid JSX.

Motivation

There were other JS typing animations that existed when I created this, but they were all lacking in robust features. This component aims to support all of the following features:

✅ Type text from any valid JSX

✅ Preserve DOM structure/styling

✅ Change typing speed anywhere in tree

✅ Add a delay anywhere in tree

✅ Backspace animation

✅ Reset lines / full tree

✅ Loop functionality

✅ No dependencies (CSS or JS)

Demo

View the live demo

or

git clone https://github.com/adamjking3/react-typing-animation
cd react-typing-animation
npm install
npm start

Then open http://localhost:3000/ in a browser.

Feature requests and pull requests welcome

Installation

npm i --save react-typing-animation

Usage

import Typing from 'react-typing-animation';

const AnimatedTypingComponent = () => (
  <Typing>
    <span>This span will get typed.</span>
  </Typing>
);

Documentation

PropertyTypeDefaultRequired
childrenReact nodeyes
classNamestringno
cursorClassNamestringno
cursorReact node<Cursor />no
hideCursorbooleanfalseno
speednumber50 (ms)no
startDelaynumber0 (ms)no
loopbooleanfalseno
onStartedTypingfunction() => {}no
onBeforeTypefunction() => {}no
onAfterTypefunction() => {}no
onFinishedTypingfunction() => {}no

Backspace Component

import Typing from 'react-typing-animation';
...
  <Typing>
    <span>This span will get typed, then erased.</span>
    <Typing.Backspace count={20} />
  </Typing>
PropertyTypeDefaultRequiredDescription
countnumber1false
delaynumber0false
speednumber-1false

Delay Component

import Typing from 'react-typing-animation';
...
  <Typing>
    <div>
      There will be a 1000ms delay here,
      <Typing.Delay ms={1000} />
      then this will be typed.
    </div>
  </Typing>
PropertyTypeDefaultRequiredDescription
msnumberyes

Speed Component

import Typing from 'react-typing-animation';
...
  <Typing speed={50}>
    This line will be typed at 50ms/character,
    <Typing.Speed ms={200} />
    then this will be typed at 200ms/character.
  </Typing>
PropertyTypeDefaultRequiredDescription
msnumberyes

Reset Component

import Typing from 'react-typing-animation';
...
  <Typing>
    <span>This line will stay.</span>
    <span>This line will get instantly removed after a 500 ms delay</span>
    <Typing.Reset count={1} delay={500} />
  </Typing>
PropertyTypeDefaultRequiredDescription
countnumber0false
delaynumber0false
speednumber-1false

Contributing

After cloning the repository and running npm install inside, you can use the following commands to develop and build the project.

# Starts a webpack dev server that hosts the demo at http://localhost:3000
npm start

# Lints the code with eslint
npm run lint

# Lints and builds the code, placing the result in the dist directory.
npm run build

Pull requests are welcome!

License

MIT

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago