-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
38 lines (24 loc) · 858 Bytes
/
script.js
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
/*
TOUT COPIER DANS LA PARTI "JS"
*/
document.addEventListener('goalLoad', function(obj) {
console.log(obj.detail);
let OBJECTIF = obj.detail.amount.target
let VALUE = obj.detail.amount.current
const TEXT_VALUE = document.querySelector('.subtext');
TEXT_VALUE.innerHTML = VALUE
setSpinnerValue(VALUE, OBJECTIF);
});
document.addEventListener('goalEvent', function(obj) {
console.log(obj.detail);
});
function setSpinnerValue(value, objectif) {
if(value > objectif){ value = objectif }
const circle = document.querySelector('.spinner-circle');
const radius = circle.r.baseVal.value;
const circumference = 2 * Math.PI * radius;
const progress = value / objectif;
const dashoffset = circumference * (1 - progress);
circle.style.strokeDashoffset = dashoffset;
circle.parentNode.setAttribute('data-value', value);
}