-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript.js
More file actions
56 lines (46 loc) · 1.58 KB
/
Copy pathScript.js
File metadata and controls
56 lines (46 loc) · 1.58 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const startBtn = document.getElementById("startBtn");
const pages = ["page1", "page2", "page3", "page4", "page5"];
let currentPage = 0;
startBtn.addEventListener("click", () => {
document.querySelector(".intro").classList.add("hidden");
document.getElementById(pages[0]).classList.remove("hidden");
});
document.querySelectorAll(".nextBtn").forEach(btn => {
btn.addEventListener("click", () => {
document.getElementById(pages[currentPage]).classList.add("hidden");
currentPage++;
if (currentPage < pages.length) {
const nextPage = document.getElementById(pages[currentPage]);
nextPage.classList.remove("hidden");
window.scrollTo({ top: 0, behavior: "smooth" });
if (pages[currentPage] === "page5") {
startCelebration();
}
}
});
});
// Tap mini cards to "highlight" them
document.querySelectorAll(".miniCard").forEach(card => {
card.addEventListener("click", () => {
if (!card.innerText.includes("❤️")) {
card.innerText = "❤️ " + card.innerText + " ❤️";
}
});
});
// Falling hearts animation on final page
function startCelebration() {
const container = document.getElementById("celebration");
for (let i = 0; i < 25; i++) {
setTimeout(() => {
const heart = document.createElement("div");
heart.classList.add("heart");
heart.innerText = "❤️";
heart.style.left = Math.random() * 100 + "%";
heart.style.animationDuration = (2.5 + Math.random() * 2) + "s";
container.appendChild(heart);
setTimeout(() => {
heart.remove();
}, 4000);
}, i * 120);
}
}