bind-typewriter
v1.0.0
Published
typewriter effect in html content, auto effect after text changed
Downloads
1
Maintainers
Readme
The package is present
Usage
- Install npm package:
npm i bind-typewriter
- Import in project:
import { bindTypewriter } from "bind-typewriter"
- Setting
i.const options = { start: '0.6s', attribute: `[data-typewriter="animation"]`, cursorColor: 'black' // #fff } // default options = undefined
- Usage:
a. import
b. call functionimport { bindTypewriter } from 'bind-typewriter';
bindTypewriter(options).run();
- remove library (optional)
bindTypewriter().remove();
- Happy codding!!!
Demo in React app
import React, { useState, useEffect } from 'react';
import './App.css';
import { bindTypewriter } from 'bind-typewriter';
function App() {
return (
<div className="App">
<header className="App-header">
<BindTypewriterBody />
</header>
</div>
);
}
export default App;
function BindTypewriterBody() {
const [index, setIndex] = useState(0);
useEffect(() => {
if(index > 3) bindTypewriter().remove();
else bindTypewriter({cursorColor: 'white'}).run();
setTimeout(function(){
setIndex(index + 1);
}, 6666);
});
return (
<div className="DnbBindTypewriter">
<h2 data-typewriter="animation">{index % 2 == 0 ? `Demo bind-typewriter ${index}` : `Demo ${index}`}</h2>
</div>
);
}