首先js在这里:
function addAnimation(argument) {
$('.plane-outer').addClass('plane-outer-animation');
$('.plane').addClass('plane-animation');
$('.text').addClass('text-animation');
}
function removeAnimation(argument) {
$('.plane-outer').removeClass('plane-outer-animation');
$('.plane').removeClass('plane-animation');
$('.text').removeClass('text-animation');
}
addAnimation();
然后用定时来去掉动画:
var num = 0;
function timing() {
num++;
if (num % 11 == 0) {
removeAnimation();
} else if (num % 11 == 2) {
addAnimation();
}
}
setInterval("timing()", 1000);
给两个div上动画css和结束时候去掉动画,css3样式如下:
.index .plane-outer-animation {
-webkit-animation: forward 6s 1 linear;
animation: forward 6s 1 linear;
}
.index .plane-animation {
-webkit-animation: down 6s 1 ease-in;
animation: down 6s 1 ease-in;
}
.index .text-animation {
-webkit-animation: dashin 1s 5s 1 ease-in, wobble 2s 5s 2, dashout 5s 6s 1;
animation: dashin 1s 5s 1 ease-in, wobble 2s 5s 2, dashout 5s 6s 1;
}