autotyperjs是一款打字机动画特效js插件js。使用autotyperjs可以轻松的实现控制台打字效果,配合CSS3动画,可以制作漂亮的自动打字动画特效。
安装
NPM
npm install autotyperjs --save
使用方法
在页面中引入下面的文件。
<link href="css/placeholder-loading.css" rel="stylesheet">
HTML结构
<div> <h1 class="typer-target"> AutoTyper<span>.js</span> </h1> </div>
初始化插件
var options = { selector: ".content > h1", words: ["hello", "world"] }; // start auto typer var typer = new autoTyper(options); typer.start();
停止打字动画。
// stop autoTyper typer.stop();
光标闪烁动画
<div class="typerTarget"></div>
@-webkit-keyframes blink-caret { 50% { border-color: transparent; } } .typerTarget { border-right: 1px solid #404145; -webkit-animation: blink-caret 0.5s step-end infinite alternate; animation: blink-caret 0.5s step-end infinite alternate; }
配置参数
// available custom options var options = { selector: ".typerTarget", // target element selector words: [], // words/sentences that will be auto typed charSpeed: 85, // letter typing animation speed delay: 2100, // word/sentence typing animation delay loop: true, // if loop is activated, autoTyper will start over flipflop: true // if flipflop is activated, letters which are typed animated will be removed ony by one animated };
autotyperjs插件的github网址为:https://github.com/hsynlms/autotyperjs