-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
132 lines (95 loc) · 3.17 KB
/
script.js
File metadata and controls
132 lines (95 loc) · 3.17 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
const yesBtn = document.getElementById("yesBtn");
const noBtn = document.getElementById("noBtn");
const navbar = document.querySelector('.navbar');
let scale = 1;
noBtn.addEventListener("click", () => {
scale += 0.4;
yesBtn.style.transform = `scale(${scale})`;
});
const thanks = document.querySelector(".thanks");
yesBtn.addEventListener("click", () => {
navbar.classList.add("active"); // hide first card
thanks.classList.add("active"); // show next card
});
const letter = document.querySelector('.letter');
const check = document.querySelector('.check');
check.addEventListener("click", () => {
letter.style.display = "flex";
})
const seeurmem = document.querySelector('.seeurmemories');
const memories = document.querySelector('.memories');
// const letter = document.querySelector('.letter');
seeurmem.addEventListener("click", () => {
memories.classList.add('active');
});
const dates = document.querySelector('.dates');
const showdate = document.querySelector('.show-date');
showdate.addEventListener("click", () => {
dates.classList.add('active');
})
document.querySelector('.play-quiz-btn').addEventListener('click', () => {
document.querySelector('.quiz').classList.add('active');
document.querySelector('.quiz').classList.remove('hide');
});
const wishes = document.querySelector('.spin-section');
const wishbtn = document.querySelector('.wishbutton');
wishbtn.addEventListener("click", () => {
//document.querySelector('.quiz').classList.add('hide');
wishes.classList.add('active'); // show wishes
});
// change
let container = document.querySelector(".container");
let btn = document.getElementById("spin");
let resultsBox = document.getElementById("results");
let rotation = 0;
let turn = 0;
const maxTurns = 3;
// wishes list (shrinks after each spin)
let messages = [
"Trampoline Date",
"Movie date 🎬",
"Temple Visit ",
"Trecking Togther❤️",
"Shopping Together",
"Go Kartikng ",
"Beach Date 😘",
"Food Date",
"Spending Time with you"
];
btn.onclick = function () {
if (turn >= maxTurns) return;
turn++;
let randomSpin = Math.floor(Math.random() * 360) + 720;
rotation += randomSpin;
container.style.transform = `rotate(${rotation}deg)`;
setTimeout(() => {
// pick random wish index
let index = Math.floor(Math.random() * messages.length);
let selectedWish = messages[index];
// remove selected wish (NO REPEAT)
messages.splice(index, 1);
let div = document.createElement("div");
div.className = "result-item";
div.innerText = `Turn ${turn}: ${selectedWish}`;
resultsBox.appendChild(div);
if (turn === maxTurns) {
btn.innerText = "Done";
btn.style.cursor = "not-allowed";
btn.style.opacity = "0.6";
}
}, 5000);
};
const herbtn = document.querySelector('.herbtn');
const her = document.querySelector('.her');
herbtn.addEventListener("click",()=>{
her.classList.add('active');
})
const section = document.querySelector(".up");
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
section.classList.add("show");
}
});
}, { threshold: 0.5 });
observer.observe(section);