Repository navigation
Expand file tree
/
Copy pathcount.html
More file actions
127 lines (109 loc) · 3.06 KB
/
Copy pathcount.html
File metadata and controls
127 lines (109 loc) · 3.06 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./fontawesome-free-5.10.1-web/css/all.css">
<title>Timer</title>
</head>
<style>
button {
background: white;
border-radius: 10px;
border: none;
padding: 15px 30px;
font-size: 34px;
font-family: 'Muli';
display: block;
text-transform: uppercase;
letter-spacing: 2px;
cursor: pointer;
transition: 1s ease all;
line-height: 1;
display: flex;
}
button:hover {
transform: scale(1.01);
background: #aeb1df;
}
.icon {
margin-right: 8px;
}
.reset {
font-size: 12x;
padding: 8px 16px;
margin: 100px auto 0;
}
.countdown {
position: relative;
display: block;
text-indent: -999px;
overflow: hidden;
margin-left: 6px;
}
.numbers {
position: absolute;
top: 0;
left: 0;
text-align: center;
transition: 0.3s ease transform;
text-indent: 0;
}
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #3ca8de;
}
</style>
<body>
<div>
<button class="next">
<span class="icon"><i class="fas fa-angle-double-right" ></i></span>
Next Episode Starts in
<span class="countdown">
10
<span class="numbers">
<span>10</span>
<span>9</span>
<span>8</span>
<span>7</span>
<span>6</span>
<span>5</span>
<span>4</span>
<span>3</span>
<span>2</span>
<span>1</span>
<span>0</span>
</span>
</span>
</button>
<button class="reset">Reset</button>
</div>
<script>
const countdownArea = document.querySelector('.countdown');
const numbersArea = document.querySelector('.numbers');
const resetBtn = document.querySelector('.reset');
let interval;
let count = 0;
const height = countdownArea.getBoundingClientRect().height;
createTimer();
resetBtn.addEventListener('click', createTimer);
function createTimer() {
clearInterval(interval);
count = 0;
numbersArea.style.transform = `translateY(0)`
interval = setInterval(() => {
count++;
const offset = height * count;
numbersArea.style.transform = `translateY(-${offset}px)`
if (count >= 10) {
clearInterval(interval);
}
}, 1000)
}
</script>
</body>
</html>