forked from bjtqti/study
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogess.html
65 lines (60 loc) · 1.21 KB
/
progess.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.oy-out-box {
position: relative;
width: 80%;
height: 10px;
margin: 0 auto;
border-radius: 5px;
background-color: #f5f5f5;
}
.oy-in-box {
position: absolute;
top: 0;
left: 0;
z-index: 2;
height: 100%;
border-radius: 5px;
background-color: green;
text-align: right;
font-size: 12px;
line-height: 10px;
color: #fff;
}
</style>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<div class="oy-out-box">
<div id="prog-bar" class="oy-in-box"></div>
</div>
<script>
$(document).ready(function(){
var innerBox = $('#prog-bar'),
complete = 0,
speed = 500,
timerId;
function progess(per){
//console.log(per,timerId)
if(per > 100){
clearTimeout(timerId);
innerBox.css('text-align','center')
return false;
}
innerBox.animate({width:per + '%'},speed,'linear',function(e){
innerBox.text(per+'%');
});
timerId = setTimeout(function(){
//ajax success callback
progess(per+10)
},speed)
}
progess(complete)
})
</script>
</body>
</html>