-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathdemo.html
85 lines (70 loc) · 2.23 KB
/
demo.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE HTML>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="src/jquery.percentageloader-0.2.js"></script>
<link rel="stylesheet" href="src/jquery.percentageloader-0.2.css">
<style>
body {
margin: 0px;
padding: 0px;
}
#topLoader {
width: 256px;
height: 256px;
margin-bottom: 32px;
}
#container {
width: 940px;
padding: 10px;
margin-left: auto;
margin-right: auto;
}
#animateButton {
width: 256px;
}
</style>
</head>
<body>
<div id="container">
<div id="topLoader">
</div>
<button id="animateButton">Animate Loader</button>
<script>
$(function() {
var $topLoader = $("#topLoader").percentageLoader({
width: 256, height: 256, controllable: true, progress: 0.5, onProgressUpdate: function (val) {
this.setValue(Math.round(val * 100.0) + 'kj');
}
});
var topLoaderRunning = false;
/* Some browsers may load in assets asynchronously. If you are using the percentage
* loader as soon as you create it (i.e. within the same execution block) you may want to
* wrap it in the below `ready` function to ensure its correct operation
*/
$topLoader.percentageLoader({onready: function () {
$("#animateButton").click(function () {
if (topLoaderRunning) {
return;
}
topLoaderRunning = true;
var kb = 0;
var totalKb = 999;
var animateFunc = function () {
kb += 17;
$topLoader.percentageLoader({progress: kb / totalKb});
$topLoader.percentageLoader({value: (kb.toString() + 'kb')});
if (kb < totalKb) {
setTimeout(animateFunc, 25);
} else {
topLoaderRunning = false;
}
};
setTimeout(animateFunc, 25);
});
}});
});
</script>
</div>
</body>
</html>