Animated text effects

For example, Animated text effects...

Demo

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

HTML

<div id="run-text">
    <button>Run Text</button>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div id="run-highlight-text">
    <button>Run Highlight Text</button>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>

CSS

<style>
    #run-text { 
        font: 15px monospace; 
    }
    #run-text .letter { 
        opacity: 0; 
    }
    #run-text .opacity {
        -webkit-transition: opacity .15s ease-in-out;
        -moz-transition: opacity .15s ease-in-out;
        -ms-transition: opacity .15s ease-in-out;
        -o-transition: opacity .15s ease-in-out;
        transition: opacity .15s ease-in-out;
        opacity: 1;
    }
    #run-highlight-text .bg-color {
        -webkit-transition: background .3s ease-in-out;
        -moz-transition: background .3s ease-in-out;
        -ms-transition: background .3s ease-in-out;
        -o-transition: background .3s ease-in-out;
        transition: background .3s ease-in-out;
        background: yellow;
    }
</style>

Javascript

// Animated text effects
$(function(){
    $.fn.animateText = function(delay, cls) {
        var text = this.text();
        var letters = text.split('');
        
        return this.each(function(){
            var $this = $(this);
            $this.html(text.replace(/./g, '<span class="letter">$&</span>'));
            $this.find('span.letter').each(function(i, el){
              setTimeout(function(){ $(el).addClass(cls); }, delay * i);
            });
        });
    };
    
    $('#run-text button').click(function(){
      $(this).next('p').animateText(15, 'opacity');
    });
    
    $('#run-highlight-text button').click(function(){
      $(this).next('p').animateText(8, 'bg-color');
    });
})    
  • Share
  • Copyright 2016 by WebiBeris.com. All Rights Reserved.