Textillate.js 实现文本动画

Textillate.js是一款基于jQuery和animate.css的文本动画插件,它提供了多种方式来初始化和控制文本的进出动画。在使用前,需要先引入jQuery和animate.css库。插件触发多个事件,包括开始、动画阶段结束等,还支持手动启动、停止和切换动画状态。用户可以在其官网或CSDN下载该插件进行使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

该插件基于jQuery和animate.css,在使用该插件之前,需要引入这两个文件

引入示例:

    <!-- animate.css -->
    <link rel="stylesheet" href="css/animate.css">
    <!-- jquery.js -->
    <script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
    <!-- 实现文本动画的其他3个JS文件 -->
    <script src="js/jquery.fittext.js"></script>
    <script src="js/jquery.lettering.js"></script>
    <script src="js/jquery.textillate.js"></script>

使用说明:

文本容器

<h1 class="tlt">文本容器,用jQuery的选择器选择<h1/>

插件初始化
方式一:HTML

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

方式二:JS

$('.tlt').textillate({
  // 默认的生成文本碎片的类名
  selector: '.texts',

  // 是否循环播放
  loop: false,

  // 进动画到出动画直接的时间,可以设置为0,进动画和出动画中间没有时间间隔
  minDisplayTime: 2000,

  // 动画延迟时间
  initialDelay: 0,

  // 是否自动播放
  autoStart: true,

  // 进动画特效
  inEffects: [],

  // 出动画特效
  outEffects: [ 'hinge' ],

  // 进动画各项配置
  in: {
    // 特效
    effect: 'fadeInLeftBig',

    // 延迟比例
    delayScale: 1.5,

    // 延迟
    delay: 50,

    // 每个文字碎片动画是否同步播放
    sync: false,

    // 每个文字碎片动画是否随机播放
    shuffle: false,

    // 反方向播放
    reverse: false,

    // 回调函数
    callback: function () {}
  },

  // out animation settings.
  out: {
    effect: 'hinge',
    delayScale: 1.5,
    delay: 50,
    sync: false,
    shuffle: false,
    reverse: false,
    callback: function () {}
  },

  // 整个插件的回调函数
  callback: function () {},

  // set the type of token to animate (available types: 'char' and 'word')对中文来说,word意味着这个段落
  type: 'char'
});

插件事件:

  • start.tlt- triggered when textillate starts,插件开始执行
  • inAnimationBegin.tlt - triggered when the in animation begins,进动画开始
  • inAnimationEnd.tlt - triggered when the in animation ends,进动画结束
  • outAnimationBegin.tlt - triggered when the out animation begins,出动画开始
  • outAnimationEnd.tlt - triggered when the out animation ends,出动画结束
  • end.tlt - triggered when textillate ends,整个动画结束

插件方法

  • $element.textillate(‘start’) - Manually start/restart textillate,开始动画
  • $element.textillate(‘stop’) - Manually pause/stop textillate,结束动画
  • $element.textillate(‘in’) - Trigger the current text’s in animation,开始进入动画
  • $element.textillate(‘out’) - Trigger the current text’s out animation,开始出动画

特殊例子

<!--分步进出-->
<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>

插件下载地址
http://download.csdn.net/download/qq_34095777/10270875

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值