-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcause.js
More file actions
148 lines (129 loc) · 4.48 KB
/
cause.js
File metadata and controls
148 lines (129 loc) · 4.48 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Reasons database
const reasons = [
{
text: "You’re such a kind and wonderful person, and I feel lucky to share such a good bond with you. 💖",
emoji: "🌟",
gif: "gif1.gif"
},
{
text: "May your day be filled with love, laughter, and endless joy. 🌸 ",
emoji: "💗",
gif: "gif2.gif"
},
{
text: "Wishing you success, happiness, and everything your heart desires. ✨ ",
emoji: "💕",
gif: "gif1.gif"
},
{
text: "Stay the amazing girl you are—always spreading positivity around. Have the happiest year ahead! 🥳 ",
emoji: "🌟",
gif: "gif2.gif"
}
];
// State management
let currentReasonIndex = 0;
const reasonsContainer = document.getElementById('reasons-container');
const shuffleButton = document.querySelector('.shuffle-button');
const reasonCounter = document.querySelector('.reason-counter');
let isTransitioning = false;
// Create reason card with gif
function createReasonCard(reason) {
const card = document.createElement('div');
card.className = 'reason-card';
const text = document.createElement('div');
text.className = 'reason-text';
text.innerHTML = `${reason.emoji} ${reason.text}`;
const gifOverlay = document.createElement('div');
gifOverlay.className = 'gif-overlay';
gifOverlay.innerHTML = `<img src="${reason.gif}" alt="Friendship Memory">`;
card.appendChild(text);
card.appendChild(gifOverlay);
gsap.from(card, {
opacity: 0,
y: 50,
duration: 0.5,
ease: "back.out"
});
return card;
}
// Display new reason
function displayNewReason() {
if (isTransitioning) return;
isTransitioning = true;
if (currentReasonIndex < reasons.length) {
const card = createReasonCard(reasons[currentReasonIndex]);
reasonsContainer.appendChild(card);
// Update counter
reasonCounter.textContent = `Reason ${currentReasonIndex + 1} of ${reasons.length}`;
currentReasonIndex++;
// Check if we should transform the button
if (currentReasonIndex === reasons.length) {
gsap.to(shuffleButton, {
scale: 1.1,
duration: 0.5,
ease: "elastic.out",
onComplete: () => {
shuffleButton.textContent = "Enter Our Storylane 💫";
shuffleButton.classList.add('story-mode');
shuffleButton.addEventListener('click', () => {
gsap.to('body', {
opacity: 0,
duration: 1,
onComplete: () => {
window.location.href = 'last.html'; // Replace with the actual URL of the next page
}
});
});
}
});
}
// Create floating elements
createFloatingElement();
setTimeout(() => {
isTransitioning = false;
}, 500);
} else {
// Handle navigation to new page or section
window.location.href = "#storylane";
// Or trigger your next page functionality
}
}
// Initialize button click
shuffleButton.addEventListener('click', () => {
gsap.to(shuffleButton, {
scale: 0.9,
duration: 0.1,
yoyo: true,
repeat: 1
});
displayNewReason();
});
// Floating elements function (same as before)
function createFloatingElement() {
const elements = ['🌸', '✨', '💖', '🦋', '⭐'];
const element = document.createElement('div');
element.className = 'floating';
element.textContent = elements[Math.floor(Math.random() * elements.length)];
element.style.left = Math.random() * window.innerWidth + 'px';
element.style.top = Math.random() * window.innerHeight + 'px';
element.style.fontSize = (Math.random() * 20 + 10) + 'px';
document.body.appendChild(element);
gsap.to(element, {
y: -500,
duration: Math.random() * 10 + 10,
opacity: 0,
onComplete: () => element.remove()
});
}
// Custom cursor (same as before)
const cursor = document.querySelector('.custom-cursor');
document.addEventListener('mousemove', (e) => {
gsap.to(cursor, {
x: e.clientX - 15,
y: e.clientY - 15,
duration: 0.2
});
});
// Create initial floating elements
setInterval(createFloatingElement, 2000);