-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (27 loc) · 885 Bytes
/
script.js
File metadata and controls
35 lines (27 loc) · 885 Bytes
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
(function(){
"use strict";
console.log("reading js");
const torches = document.querySelectorAll(".torch-container");
// Recursive: torches flip at random intervals.
setTimeout(flipTorches, 1000);
function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function flipTorches() {
// Wait 1–2 second interval.
let randomInterval = 1000 * Math.random() + 1000;
// Flip.
torches.forEach(torch => {
torch.style.transform = "rotateY(180deg)";
});
// Wait.
randomInterval = 1000 * Math.random() + 1000;
await wait(randomInterval);
// Flip back.
torches.forEach(torch => {
torch.style.transform = "rotateY(0deg)";
});
// Repeat.
setTimeout(flipTorches, randomInterval);
}
})();