Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb18030 ">
<title>Spiral</title>
<script type= "Text/javascript" src= "Js/jquery-1.5.js" ></script>
<body>
<script type= "Text/javascript" >
var spiral;
var yjq;
(function () {
YJQ = function (name,turns,duration,frame,count,decrease_time) {
$ (' style.enable_remove '). Remove ();
$ (' [id^=test] '). css ({' position ': ' absolute ', ' width ': ' Height ': ten, ' top ': +, ' Left ': +, ' background ': ' Black '});
Spiral (name+ ' 1 ', 600,300,300,300,turns,duration,frame);
Spiral (name+ ' 2 ', 300,0,300,300,turns,duration,frame);
Spiral (name+ ' 3 ', 0,300,300,300,turns,duration,frame);
Spiral (name+ ' 4 ', 300,600,300,300,turns,duration,frame);
$ (' # ' +name+ ' 1 '). CSS ({"-webkit-animation": name+ "1" +duration+ "Ms Linear" +count});
$ (' # ' +name+ ' 2 '). CSS ({"-webkit-animation": name+ "2" +duration+ "Ms Linear" +count});
$ (' # ' +name+ ' 3 '). CSS ({"-webkit-animation": name+ "3" +duration+ "Ms Linear" +count});
$ (' # ' +name+ ' 4 '). CSS ({"-webkit-animation": name+ "4" +duration+ "Ms Linear" +count});
var arg = arguments;
$ ("#" +name+ "4"). One (' Webkitanimationend ', function () {
if (duration<=0) {
Return
}
Arg.callee (Name,turns,duration-=decrease_time,frame,count,decrease_time);
});
}
Spiral = function (name,w1,h1,w2,h2,n,t,frame) {
var interval = t/frame;//per frame interval
var n;//circle Number
var i = 0;
var k;//initial Quadrant
var R = math.sqrt (Math.pow (w2-w1,2) +math.pow (h2-h1,2), 2);//Radius
var style= "@-webkit-keyframes" +name+ "{";
var styledom=$ ("<style class= ' Enable_remove ' ></style>");
if (w1>w2 && h1<=h2) {
K = 1;
}else if (w1<=w2 && h1K = 2;
}else if (w1<w2 && h1>=h2) {
K = 3;
}else {
K = 4;
}
for (Var t=0;t<t;t+=interval) {
var T1 = t% (t/n);
n = Math.floor (t/(t/n));
x = h2-r* (1-t1/t-n/n) *math.cos (2*math.pi*t1*n/t+math.pow ( -1,k) *math.atan (math.abs) w2-w1 (/Math.abs)) + (h2-h1 2?1:0) * (k%2?-1:1) *math.pi);
y = w2-r* (1-t1/t-n/n) *math.sin (2*math.pi*t1*n/t+math.pow ( -1,k) *math.atan (math.abs) w2-w1 (/Math.abs)) + (h2-h1 2?1:0) * (k%2?-1:1) *math.pi);
style+= (i++) *100/frame+ '%{top: ' +x+ ' px;left: ' +y+ ' px;} ';
}
style+= ' 100%{top: ' +w2+ ' px;left: ' +h2+ ' px;} ';
Styledom.html (style);
$ ("Head"). Append (Styledom);
};
})();
$ (function () {
var name = ' Test ';
var turns = Number of 5;//rotation rings
var duration = 2000;//Child animation time consuming
var decrease_time = 100;//time consuming reduction per child animation
var frame = 1000;//Child Animation frame number
var count = 2;//number of child animations performed
YJQ (Name,turns,duration,frame,count,decrease_time);
});
</script>
<div id= "Test1" ></div>
<div id= "Test2" ></div>
<div id= "Test3" ></div>
<div id= "Test4" ></div>
</body>