8


I have a css3 animation with the following:

@-webkit-keyframes rotate {
    from {
    -webkit-transform: rotate(0deg);
    }
    to { 
    -webkit-transform: rotate(360deg);
    }
}

.animated {
-webkit-animation-name: rotate;
-webkit-animation-duration: 2.4s;
-webkit-animation-iteration-count: infinite;
-webkit-transition-timing-function: ease-in-out;
}

It works flawlessly, well..., I want to make it wait between the loops:
animation-start, animation-finish, wait(about 0.5s), animation start, animation end, wait(about 0.5s)...

PS: I've tried -webkit-animation-delay, it does not work.

Any help?

Cihad Turhan
  • 2,749
  • 6
  • 28
  • 45

3 Answers3

24

Add 0.5 seconds to your animation duration, then create an extra frame in your keyframes that doesn't change the rotation amount;

@-webkit-keyframes rotate {
    0% {
    -webkit-transform: rotate(0deg);
    }
    83% { /*2.4 / 2.9 = 0.827*/
    -webkit-transform: rotate(360deg);
    }
    100% {
    -webkit-transform: rotate(360deg);
    }
}
.animated {
...
-webkit-animation-duration: 2.9s; /*note the increase*/
...
}

Little demo: little link.

Chris
  • 26,544
  • 5
  • 58
  • 71
0

Disabling the css class on element for a specified time by javascript might solve your problem.

function delayAnimation () {
    var animatedEl = document.getElementById('whatever');
    animatedEl.className = '';
    setTimeout(function () {
        animatedEl.className = 'animated'
        setTimeout(delayAnimation, 2400);// i see 2.4s is your animation duration
    }, 500)// wait 0.5s
}

Hope this helps.

Edit : I updated this answer to fix the code. You can see a fully working example on jsfiddle. Thanks to @Fabrice for pointing out the code was not working.

Community
  • 1
  • 1
frkn
  • 324
  • 1
  • 2
  • 5
0

You may use a transition. For example:

transition: all 0.6s ease-in-out;

where transition-delay:0.6s;

raam86
  • 6,785
  • 2
  • 31
  • 46
Bimba
  • 1