-
-
Notifications
You must be signed in to change notification settings - Fork 342
Expand file tree
/
Copy pathprogress-ring.html
More file actions
67 lines (59 loc) · 1.48 KB
/
Copy pathprogress-ring.html
File metadata and controls
67 lines (59 loc) · 1.48 KB
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
<html>
<head>
<script type="module" src="../lib/wired-progress-ring.js"></script>
<script type="module" src="../lib/wired-button.js"></script>
<style>
body {
margin: 0;
padding: 10px;
font-family: sans-serif;
line-height: 1.5;
}
wired-progress-ring {
margin: 16px 0;
}
#wp2 {
--wired-progress-color: red;
}
wired-button {
margin: 0 10px;
}
</style>
</head>
<body>
<wired-progress-ring value="25" hideLabel></wired-progress-ring>
<br>
<wired-progress-ring id="wp2" min="-100" max="100" value="0"></wired-progress-ring>
<br>
<section style="margin-top: 16px;">
<wired-progress-ring id="progress" showLabelAsPercent></wired-progress-ring>
<div style="margin-top: 16px;">
<wired-button id="btns">Start</wired-button>
<wired-button id="btnr">Stop</wired-button>
</div>
</section>
<script>
const prog = document.getElementById('progress')
let timer = 0;
document.getElementById('btns').addEventListener('click', () => {
if (timer) {
window.clearInterval(timer);
}
timer = window.setInterval(() => {
if (prog.value >= 100) {
prog.value = 0;
} else {
prog.value = prog.value + 1;
}
}, 100);
});
document.getElementById('btnr').addEventListener('click', () => {
if (timer) {
window.clearInterval(timer);
timer = 0;
}
prog.value = 0;
});
</script>
</body>
</html>