-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
33 lines (26 loc) · 833 Bytes
/
main.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
let ball = document.getElementById('float-circle');
let counter = document.getElementById('counter');
let bounceNumber = 0;
let resetButton = document.getElementById('reset');
// function lifting the ball
function up(){
ball.style.bottom = '300px';
}
//function dropping the ball
function down(){
ball.style.bottom = '50px';
}
document.addEventListener('keydown', up);
document.addEventListener('keyup', down);
//Creating the bounce counter function
function bounceCounter() {
if (ball.style.bottom == '50px') {
return counter.innerHTML = bounceNumber++;
}
};
ball.addEventListener('transitionend', bounceCounter);
//function resetting the bounceCounter implementing ECMAScript 6;
resetButton.addEventListener('click', () => {
bounceNumber = 0;
return counter.innerHTML = 0;
});