Arun Krishnan
Arun Krishnan

Reputation: 1958

CSS3 & Jquery Animation - Repeat after some seconds

I have created a css3 animation following like this

http://jsfiddle.net/WXHjN/

I am using the following Jquery to control time interval

$(document).ready(function(){
    $('#web').addClass("fadeInLeft");
    window.setTimeout(function(){
        $('#development').addClass("fadeInLeft");
    },300)
});

In the above example the animation happening at once only. I need this animation to repeat after some seconds. Also it must be repeat at infinity times.

Upvotes: 0

Views: 466

Answers (2)

Chirag Vidani
Chirag Vidani

Reputation: 2577

You can also try below logic

$(document).ready(function(){
    animateItems();
});

var animationRef;

function animateItems()
{
    $('#web').removeClass("fadeInLeft");
    $('#development').removeClass("fadeInLeft");

    window.setTimeout(function(){
        $('#web').addClass("fadeInLeft");},300);

  window.setTimeout(function(){
      $('#development').addClass ("fadeInLeft");
  },600);

     animationRef = window.setTimeout(animateItems,2000);
};

The logic says remove fadeInLeft class and setTimeout to execute function that displays text.

I have stored reference of timeout in animationRef variable to clear timeout, which should not be used in your code.

Fiddle Demo

Upvotes: 1

Bharathi D
Bharathi D

Reputation: 1013

Please use the below code

animation-iteration-count: infinite;

Demo: fiddle link

Upvotes: 0

Related Questions