-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathscript.js
More file actions
95 lines (84 loc) · 2.63 KB
/
script.js
File metadata and controls
95 lines (84 loc) · 2.63 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
// Cursor following effect
const cursor = document.querySelector('.cursor');
document.addEventListener('mousemove', (e) => {
cursor.style.left = e.clientX + 'px';
cursor.style.top = e.clientY + 'px';
});
// Typing effect for greeting
const greetingText = "Hey You Know What! You're the most adorable human i ever met! 💖";
const greetingElement = document.querySelector('.greeting');
let charIndex = 0;
function typeGreeting() {
if (charIndex < greetingText.length) {
greetingElement.textContent += greetingText.charAt(charIndex);
charIndex++;
setTimeout(typeGreeting, 100);
}
}
// Create floating elements
const floatingElements = ['💖', '✨', '🌸', '💫', '💕'];
function createFloating() {
const element = document.createElement('div');
element.className = 'floating';
element.textContent = floatingElements[Math.floor(Math.random() * floatingElements.length)];
element.style.left = Math.random() * 100 + 'vw';
element.style.top = Math.random() * 100 + 'vh';
element.style.fontSize = (Math.random() * 20 + 20) + 'px';
document.body.appendChild(element);
gsap.to(element, {
y: -500,
x: Math.random() * 100 - 50,
rotation: Math.random() * 360,
duration: Math.random() * 5 + 5,
opacity: 1,
ease: "none",
onComplete: () => element.remove()
});
}
// Initialize animations
window.addEventListener('load', () => {
// Title animation
gsap.to('h1', {
opacity: 1,
duration: 1,
y: 20,
ease: "bounce.out"
});
// Button animation
gsap.to('.cta-button', {
opacity: 1,
duration: 1,
y: -20,
ease: "back.out"
});
// Start typing effect
typeGreeting();
// Create floating elements periodically
setInterval(createFloating, 1000);
});
// Hover effects
// Hover effects
document.querySelectorAll('.cta-button').forEach(button => {
button.addEventListener('mouseenter', () => {
gsap.to(button, {
scale: 1.1,
duration: 0.3
});
});
button.addEventListener('mouseleave', () => {
gsap.to(button, {
scale: 1,
duration: 0.3
});
});
// Smooth page transition on click
button.addEventListener('click', () => {
gsap.to('body', {
opacity: 0,
duration: 1,
onComplete: () => {
window.location.href = 'cause.html'; // Replace with the actual URL of the next page
}
});
});
});