-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
161 lines (140 loc) · 5.22 KB
/
Copy pathscript.js
File metadata and controls
161 lines (140 loc) · 5.22 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
149
150
151
152
153
154
155
156
157
158
159
160
161
// Mobile Menu Toggle
const mobileMenuBtn = document.getElementById('mobile-menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
mobileMenuBtn.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
});
// Close mobile menu when clicking on a link
document.querySelectorAll('#mobile-menu a').forEach(link => {
link.addEventListener('click', () => {
mobileMenu.classList.add('hidden');
});
});
// Navbar background on scroll
const navbar = document.getElementById('navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('shadow-lg');
navbar.querySelector('.glass-card').style.background = 'rgba(15, 23, 42, 0.95)';
} else {
navbar.classList.remove('shadow-lg');
navbar.querySelector('.glass-card').style.background = 'rgba(30, 41, 59, 0.4)';
}
});
// Scroll Reveal Animation
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('active');
}
});
}, observerOptions);
document.querySelectorAll('.scroll-reveal').forEach((el) => observer.observe(el));
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Preview Modal Functions
function showPreview(type) {
const modal = document.getElementById('previewModal');
const title = document.getElementById('previewTitle');
const description = document.getElementById('previewDescription');
const previews = {
gym: {
title: 'PowerFit Gym - Preview',
desc: 'Features: Class schedules, Trainer profiles, Membership signup, Contact forms'
},
coaching: {
title: 'Success Coaching - Preview',
desc: 'Features: Course listings, Success stories, Enrollment forms, Testimonials'
},
cafe: {
title: 'Brew & Bite Café - Preview',
desc: 'Features: Digital menu, Reservation system, Photo gallery, Location map'
}
};
title.textContent = previews[type].title;
description.textContent = previews[type].desc;
modal.classList.remove('hidden');
document.body.style.overflow = 'hidden';
// Re-initialize icons in modal
if (typeof lucide !== 'undefined') {
lucide.createIcons();
}
}
function closePreview() {
const modal = document.getElementById('previewModal');
modal.classList.add('hidden');
document.body.style.overflow = 'auto';
}
// Close modal on escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
closePreview();
}
});
// Add glow effect to buttons on mouse move
document.querySelectorAll('.glow-button').forEach(button => {
button.addEventListener('mousemove', (e) => {
const rect = button.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
button.style.setProperty('--x', `${x}px`);
button.style.setProperty('--y', `${y}px`);
});
});
// Counter animation for stats
function animateCounter(element, target, duration = 2000) {
let start = 0;
const increment = target / (duration / 16);
const timer = setInterval(() => {
start += increment;
if (start >= target) {
element.textContent = target + '+';
clearInterval(timer);
} else {
element.textContent = Math.floor(start) + '+';
}
}, 16);
}
// Trigger counter animation when stats section is visible
const statsObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting && !entry.target.classList.contains('counted')) {
entry.target.classList.add('counted');
const counter = entry.target.querySelector('.text-3xl');
if (counter && counter.textContent.includes('50')) {
animateCounter(counter, 50);
}
}
});
}, { threshold: 0.5 });
// Observe stats card if it exists
document.querySelectorAll('.glass-card .text-3xl').forEach(el => {
if (el.textContent.includes('50')) {
statsObserver.observe(el.closest('.glass-card'));
}
});
// Form validation for contact (if forms are added later)
function validateEmail(email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(email);
}
// Console welcome message
console.log('%c❄️ Snow Web Development', 'color: #3b82f6; font-size: 24px; font-weight: bold;');
console.log('%cPremium websites delivered in 2 days!', 'color: #94a3b8; font-size: 14px;');
console.log('%cContact us: contact@snowweb.dev', 'color: #60a5fa; font-size: 12px;');