jQuery - wording rollout animations

0 votes
242 views
added Oct 2, 2018 in jQuery by LC Marshal Captain (25,790 points)

jQuery(document).ready(function(){
  var terms = ['joyful','dream','perfect','bargain','ideal','luxury'];
  var i = 0;
  function rollerout(){

    jQuery(".roller").animate({opacity: 0, left: '-150px'}
                        , 500,function(){
                          jQuery(".roller").text(terms[i]);
                          rollin();
                        });
  }
  function rollin(){
    jQuery(".roller").css('display', 'block').animate({opacity: 1.0, left: '150px'}
                        , 500,function(){
                          i = i+1;
                          i = (terms.length == i)?0:i;
                          setTimeout(rollerout,2000);
                        });
  }
  rollin();

})

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...