forked from anshulontech/JavaScript51
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
59 lines (49 loc) · 1.38 KB
/
script.js
File metadata and controls
59 lines (49 loc) · 1.38 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
const afterBlock = document.querySelector(`.after`);
const beforeBlock = document.querySelector(`.before`);
const count = document.querySelector(`.count`);
const intro = document.querySelector(`.intro`);
const btn = document.querySelector(`#btn`);
const end = document.querySelector(`.end`);
btn.addEventListener('click', () => {
intro.classList.add(`none`);
btn.classList.add(`none`);
afterBlock.classList.remove(`none`);
beforeBlock.classList.remove(`none`);
count.classList.remove(`none`);
intervalB = setInterval(rotateB, 1000);
setTimeout(helper, 500);
intervalCount = setInterval(increaseCount, 100);
})
var intervalB;
var intervalCount;
var intervalA;
let degA = 0;
let degB = 90;
let value = 0;
function rotateB() {
degB += 180;
beforeBlock.style.transform = `rotate(${degB}deg)`;
}
function helper() {
intervalA = setInterval(rotateA, 1000);
}
function rotateA() {
degA += 180;
afterBlock.style.transform = `rotate(${degA}deg)`;
}
function increaseCount() {
value++;
if (value >= 100) {
clearInterval(intervalB);
clearInterval(intervalCount);
clearInterval(intervalA);
setTimeout(BlockAll, 1500);
}
count.innerText = `${value}%`;
}
function BlockAll() {
afterBlock.classList.add(`none`);
beforeBlock.classList.add(`none`);
count.classList.add(`none`);
end.classList.remove(`none`);
}