-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoetry.js
26 lines (24 loc) · 1.02 KB
/
poetry.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
let poemVisible = true;
async function swapContent(poem) {
console.log("hello");
let poemChildren = poem.children
if (poemVisible) {
poemChildren[0].style.opacity = 0;
await new Promise(resolve => setTimeout(resolve, 250)); // wait .5s for transition
poemChildren[0].style.display = "none";
poemChildren[1].style.display = "block";
poemChildren[1].style.opacity = 0;
await new Promise(resolve => setTimeout(resolve, 250)); // wait .5s for transition
poemChildren[1].style.opacity = 1;
poemVisible = false;
} else {
poemChildren[1].style.opacity = 0;
await new Promise(resolve => setTimeout(resolve, 250)); // wait .5s for transition
poemChildren[1].style.display = "none";
poemChildren[0].style.display = "block";
poemChildren[0].style.opacity = 0;
await new Promise(resolve => setTimeout(resolve, 250)); // wait .5s for transition
poemChildren[0].style.opacity = 1;
poemVisible = true;
}
}