-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (20 loc) · 759 Bytes
/
script.js
File metadata and controls
30 lines (20 loc) · 759 Bytes
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
const durationInput = document.getElementById("duration");
const startBtn = document.getElementById("start");
const pauseBtn = document.getElementById("pause");
const circle = document.querySelector("circle");
const perimeter = circle.getAttribute("r") * 2 * Math.PI;
const arguments = [durationInput, startBtn, pauseBtn];
circle.setAttribute('stroke-dasharray', perimeter);
let duration;
let offset = perimeter / durationInput.value;
const t1 = new Timer(...arguments, {
onStart(totalDuration) {
duration = totalDuration;
},
onTick(timeRemaining) {
circle.setAttribute("stroke-dashoffset", perimeter * timeRemaining / duration - perimeter);
},
onComplete() {
console.log("Timer is completed");
}
});