-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.js
26 lines (20 loc) · 968 Bytes
/
form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(function randomCake() {
const cake = document.querySelector('.cake');
const container = document.querySelector('.container');
const randoButton = document.querySelector('#rando-button');
const cakes = ['default-cake', 'chocolate-cake', 'strawberry-cake', 'pistachio-cake', 'red-velvet-cake'];
setInterval(()=>randomInit(),1300)
// randoButton.addEventListener('click', function() {
// randomInit();
// }, false);
function randomInit() {
cake.classList.add("bounce-cake");
let currentCake = container.classList[1];
setTimeout(() => container.classList.replace(currentCake, getRandomCake()), 820);
setTimeout(() => cake.classList.remove("bounce-cake"), 1200);
function getRandomCake() {
let random = cakes[Math.floor(Math.random()*cakes.length)];
return random === currentCake ? getRandomCake() : random;
}
}
})();