文本特效-jQuery和CSS3多种文字动画特效库

textillate.js是一款效果炫酷的jQuery和css3文字动画特效库插件。它通过结合其它一些动画库来制作各种CSS3文字动画特效。

如何使用

基本的html结构如下:

<h1 class="tlt">My Title</h1>

在页面的头部引入jQuery和jquery.textillate.js文件。

<script src="http://libs.useso.com/js/jquery/1.9.1/jquery.min.js"></script>
<script src="jquery.textillate.js"></script>

然后就可以如下调用插件。

$(function () {
    $('.tlt').textillate();
})

上面的方法将会使用默认参数来调用插件。要改变默认参数,你可以使用data-属性来设置新参数。

<h1 class="tlt" data-in-effect="rollIn">Title</h1>

或者在初始化插件时设置参数:

$('.tlt').textillate({ in: { effect: 'rollIn' } });

你可以通过下面的方式来使 textillate.js 动画整个列表内容。

<h1 class="tlt">
    <ul class="texts">
        <li data-out-effect="fadeOut" data-out-shuffle="true">Some Title</li>  
        <li data-in-effect="fadeIn">Another Title</li>
    </ul>
</h1>
$('.tlt').textillate();

你可以使用data-属性来控制么一个列表项上的文本的动画效果。

插件依赖

textillate.js文字动画库插件依赖于下面的一些库文件:

可用参数

$('.tlt').textillate({
  // the default selector to use when detecting multiple texts to animate
  selector: '.texts',
  // enable looping
  loop: false,
  // sets the minimum display time for each text before it is replaced
  minDisplayTime: 2000,
  // sets the initial delay before starting the animation
  // (note that depending on the in effect you may need to manually apply
  // visibility: hidden to the element before running this plugin)
  initialDelay: 0,
  // set whether or not to automatically start animating
  autoStart: true,
  // custom set of 'in' effects. This effects whether or not the
  // character is shown/hidden before or after an animation 
  inEffects: [],
  // custom set of 'out' effects
  outEffects: [ 'hinge' ],
  // in animation settings
  in: {
    // set the effect name
    effect: 'fadeInLeftBig',
    // set the delay factor applied to each consecutive character
    delayScale: 1.5,
    // set the delay between each character
    delay: 50,
    // set to true to animate all the characters at the same time
    sync: false,
    // randomize the character sequence
    // (note that shuffle doesn't make sense with sync = true)
    shuffle: false,
    // reverse the character sequence
    // (note that reverse doesn't make sense with sync = true)
    reverse: false,
    // callback that executes once the animation has finished
    callback: function () {}
  },
  // out animation settings.
  out: {
    effect: 'hinge',
    delayScale: 1.5,
    delay: 50,
    sync: false,
    shuffle: false,
    reverse: false,
    callback: function () {}
  },
  // callback that executes once textillate has finished
  callback: function () {},
  // set the type of token to animate (available types: 'char' and 'word')
  type: 'char'
});

事件

Textillate 会触发下面的事件。

  • start.tlt:当textillate 开始动画时触发。
  • inAnimationBegin.tlt:当 in 动画开始时触发。
  • inAnimationEnd.tlt:当 in 动画结束时触发。
  • outAnimationBegin.tlt:当 out 动画开始时触发。
  • outAnimationEnd.tlt:当 out 动画结束时触发。
  • end.tlt:当textillate 结束动画时触发。

方法

  • $element.textillate(‘start’):手动开始/重置textillate动画。
  • $element.textillate(‘stop’):手动暂停/停止textillate动画。
  • $element.textillate(‘in’):触发当前文字的 in 动画。
  • $element.textillate(‘out’):触发当前文字的 out 动画。

在线预览 网盘下载

郑重声明:

1 本资源来源于互联网,资源的版权归资源原作者所持有,受《中华人民共和国著作权法》等相关法律保护。

2 由于无法和原作者取得联系,所以上传的部分资源无法先通过原作者的同意就分享给大家了,如本资源侵犯了您(原作者)的权益,请联系我们(微信号 xiaohaimei1989),我们会立马删除您的资源,并向您表达诚挚的歉意!

3 本站是一个公益型网站,分享资源的目的在于传播知识,分享知识,收取一点点打赏的辛苦费是用于网站的日常运营开支,并非用于商业用途。

4 本站资源只提供学习和参考研究使用,使用过后请在第一时间内删除。本站不承担资源被单位或个人商用带来的法律责任。

发表评论