扫一扫分享
TheaterJS是一款模拟打字机效果的js打字机效果插件。
安装
bower install theaterjs
npm install theaterjs
例子
<div id="vader"></div>
<div id="luke"></div>
<script src="path/to/theater.min.js"></script>
<script>
var theater = theaterJS()
theater
.on('type:start, erase:start', function () {
// add a class to actor's dom element when he starts typing/erasing
var actor = theater.getCurrentActor()
actor.$element.classList.add('is-typing')
})
.on('type:end, erase:end', function () {
// and then remove it when he's done
var actor = theater.getCurrentActor()
actor.$element.classList.remove('is-typing')
})
theater
.addActor('vader')
.addActor('luke')
theater
.addScene('vader:Luke...', 400)
.addScene('luke:What?', 400)
.addScene('vader:I am', 200, '.', 200, '.', 200, '. ')
.addScene('Your father!')
.addScene(theater.replay)
</script>
手机预览