-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (25 loc) · 799 Bytes
/
index.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
let changeColor = document.getElementById('changeColor');
let circle = document.getElementById('circle');
let moving = document.getElementById('moving');
let moveIt = [
{ transform: 'translate(0, 0)',},
{ transform: 'translate(0, -500px)',},
{ transform: 'translate(500px, 0)',},
{ transform: 'translate(0, 500px)',},
{ transform: 'translate(-500px, 0)',},
{ transform: 'translate(0, -500px)',},
];
function getRandomColor() {
let hex = Math.floor(Math.random() * 0xFFFFFF);
return "#" + ("000000" + hex.toString(16)).substr(-6);
};
changeColor.onclick = function() {
circle.style.backgroundColor = getRandomColor ();
};
moving.onclick = function() {
circle.animate(moveIt, {
duration: 3000,
iterations: 2,
fill: 'backwards'
});
};