JS instance: The waiting progress bar simulating Metro UI

Source: Internet
Author: User
Tags array comparison cos return window

Article Introduction: JS Analog Metro UI waiting for progress bar, circle round and round waiting for the general comparison is poor.

JS Analog Metro UI waiting for progress bar, circle round and round waiting for the general comparison is poor bar

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> Homepage </title>
<style>
*
{
margin:0px;
padding:0px;
border:0px;
}
#CenterLine
{
width:100%;
height:5px;
Background-color:blue;
margin-top:20%;
}
. Runlinebox
{
width:8px;
height:8px;
Background-color:blue;
Float:left;
margin:5px;
Position:absolute;

}
. Point
{
width:1px;
height:1px;
Background-color:black;
Position:absolute;
}
</style>
<script type= "Text/javascript" >
Array.prototype.remove = function (x) {
if (isNaN (x) x > This.length) {return false;}
for (var i = 0, n = 0; i < this.length; i++) {
if (This[i]!= this[x]) {
this[n++] = This[i]
}
}
This.length-= 1
}
var MAX = 0

Window.onload = function () {
var runline = null;
var runlinebox = document.getelementsbytagname ("div");
var length = Runlinebox.length;
var arrayrunlinebox = new Array;
for (var i = 0; i < length; i++) {
Arrayrunlinebox[i] = Runlinebox[i]
}
for (var i = 0; i < length; ++i) {
if (arrayrunlinebox[i].classname!= "Runlinebox") {
Arrayrunlinebox.remove (i);
--length;
I.;
}
}
var runline = function (obj, marginleft) {
var FPS = 500; The number of frames in the animation
var oldmarginleft = parseint (obj.style.marginLeft);
var line = function (X, allwidth) {//v-t formula for animation
var E = allwidth/(1.408823456862077 * FPS); The constant of this calculus changes with the other variables
var h1 = 236;
var h2 = 382;
var h3 = 236;
var h4 = 146;
var x = X/fps;
if (x < 0.236) {
y = E * (Math.Cos (MATH.PI * x * 500/h1 + MATH.PI/2) + 1);
}
else if (x < 0.618) {
y = 2 * E * (Math.Cos (Math.PI * (x-h1/1000) * 1000/H2 + Math.PI) + 1);
}
else if (x < 0.854) {
y = 2 * E * (Math.Cos (Math.PI * (X-(H1 + H2)/1000) * 1000/h3) + 1);
}
else {
y = E * (Math.Cos (Math.PI * (X-
(H1 + H2 +h3)/1000) * 500/h4 + Math.PI) + 1);
}
var y =-(y * 100);
document.getElementById ("Pic"). InnerHTML + + <div class= ' point ' style= ' top: + Y + "Px;left:" + X + "px" ></div > "
return y;
};
var left = 0;
(function () {
var allwidth = document.body.clientWidth; The default length is the browser window width
var allwidth_1 = allwidth * 0.62;
var allwidth_2 = (allwidth-allwidth_1)/2;
Left + = line (marginleft, allwidth);
++marginleft;
if (marginleft >= FPS) {
marginleft = 0;
Obj.style.marginLeft = "0px";
left = 0;
return 0;
}
if (left + oldmarginleft) > Allwidth) {
Obj.style.display = "None";
}
else {
Obj.style.display = "";
}
Obj.style.marginLeft = (left + oldmarginleft) + "px";
if (left + oldmarginleft) > MAX) {
MAX = left + oldmarginleft;
}
document.getElementById ("Contore"). InnerHTML = MAX;
Runline = settimeout (Arguments.callee, 10);
})()
};

settimeout (function () {runline (arrayrunlinebox[3], 0)}, 0);
settimeout (function () {runline (arrayrunlinebox[2], 0)}, 500);
settimeout (function () {runline (arrayrunlinebox[1], 0)}, 1000);
settimeout (function () {runline (arrayrunlinebox[0], 0)}, 1500);

};
</script>
<body>
<div id= "pic" >
<div class= "point" style= "top:10px;left:10px;" ></div>
</div>
<p id= "Centerline" >
</p>
<div>
<div class= "Runlinebox" style= "margin-left:5px" >
</div>
<div class= "Runlinebox" style= "margin-left:20px" >
</div>
<div class= "Runlinebox" style= "margin-left:35px" >
</div>
<div class= "Runlinebox" style= "margin-left:50px" >
</div>
</div>
<br/>
<br/>
<div id= "Contore" >
</div>
</body>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.