jQuery

【jQuery】CSS3のテキストアニメーションTextillate

May 4, 2017
textillate

TextillateはCSS3のテキストアニメーションのためのシンプルなプラグイン。

Usage

<h1 class="tlt">My Title</h1>
$(function () {
    $('.tlt').textillate();
})
<h1 class="tlt" data-in-effect="rollIn">Title</h1>
$('.tlt').textillate({ in: { effect: 'rollIn' } });
<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();

Dependencies

  1. jQuery
  2. lettering.js
  3. animate.css

Options

$('.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'
});

Events

  1. start.tlt
  2. inAnimationBegin.tlt
  3. inAnimationEnd.tlt
  4. outAnimationBegin.tlt
  5. outAnimationEnd.tlt
  6. end.tlt
$('.tlt').on('inAnimationBegin.tlt', function () {
  // do something
});

Methods

  1. $element.textillate('start')
  2. $element.textillate('stop')
  3. $element.textillate('in')
  4. $element.textillate('out')

MIT