npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

text-effect

v1.0.1

Published

textillate with vanilla javascript

Downloads

113

Readme

text-effect

textillate纯js实现版本,提供了lettering(文字分离)和textillate(文字动画)两种功能。

实际效果可参考textillate的官网

兼容性

IE8+

Usage

basic markup:

<h1 class="tlt">My Title</h1>
new TextEffect('.tlt').textillate();
or
new TextEffect(document.querySelector('.tlt')).textillate();

if you just want to use lettring function,proveide a static function for you to use

TextEffect.lettring('.tlt');

Dependencies

only animate.css

Options

new TextEffect('.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

触发事件类型跟textillate相同,只是有的事件名称不同:

  • effectStart - triggered when textillate starts
  • inAnimationBegin - triggered when the in animation begins
  • inAnimationEnd - triggered when the in animation ends
  • outAnimationBegin - triggered when the out animation begins
  • outAnimationEnd - triggered when the out animation ends
  • effectFinish - triggered when textillate ends

text-effct的调用方式稍有不同,事件监听没有绑定在元素上,用户通过effect实例去监听事件。

var te = new TextEffect('.tlt').textillate();
te.on('effectStart', function() {
    console.log('文字效果开始了');
})

Methods

var te = new TextEffect('.tlt').textillate();
  • te.textillate('start') - Manually start/restart textillate
  • te.textillate('stop') - Manually pause/stop textillate
  • te.textillate('setOption') - change the current text's option
  • te.textillate('init')

Example

实际的调用方式可以参考目录example/