-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
130 lines (107 loc) · 4.42 KB
/
script.js
File metadata and controls
130 lines (107 loc) · 4.42 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
document.addEventListener('DOMContentLoaded', () => {
// --- Beam of Light / Cursor Effect ---
const cursorLight = document.getElementById('cursor-light');
// Only active on desktop/mouse devices to save performance on mobile
if (matchMedia('(pointer:fine)').matches) {
document.addEventListener('mousemove', (e) => {
cursorLight.style.left = e.clientX + 'px';
cursorLight.style.top = e.clientY + 'px';
});
// Optional: Pulse effect/Intensify on hover of interactive elements
const interactiveElements = document.querySelectorAll('a, button, input, textarea, .service-card');
interactiveElements.forEach(el => {
el.addEventListener('mouseenter', () => {
cursorLight.style.width = '550px';
cursorLight.style.height = '550px';
cursorLight.style.background = 'radial-gradient(circle, rgba(212, 175, 55, 0.15) 0%, rgba(212, 175, 55, 0) 70%)';
});
el.addEventListener('mouseleave', () => {
cursorLight.style.width = '400px';
cursorLight.style.height = '400px';
cursorLight.style.background = 'radial-gradient(circle, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 70%)';
});
});
} else {
// Disable on touch devices
cursorLight.style.display = 'none';
}
// --- Scroll Reveal Animation ---
const reveals = document.querySelectorAll('.reveal');
const revealOnScroll = () => {
const windowHeight = window.innerHeight;
const elementVisible = 150;
reveals.forEach((reveal) => {
const elementTop = reveal.getBoundingClientRect().top;
if (elementTop < windowHeight - elementVisible) {
reveal.classList.add('active');
}
});
};
window.addEventListener('scroll', revealOnScroll);
// Trigger once on load
revealOnScroll();
// --- Smooth Scroll for Anchors ---
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const targetElement = document.querySelector(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth'
});
}
});
});
// --- Mobile Menu Toggle ---
const hamburger = document.querySelector('.hamburger');
const nav = document.querySelector('.nav');
const navLinks = document.querySelectorAll('.nav-list li a');
if (hamburger) {
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
nav.classList.toggle('active');
});
}
// Close menu when a link is clicked
navLinks.forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
nav.classList.remove('active');
});
});
// --- Back to Top Button ---
const backToTopBtn = document.getElementById('backToTop');
window.addEventListener('scroll', () => {
if (window.scrollY > 300) {
backToTopBtn.classList.add('show');
} else {
backToTopBtn.classList.remove('show');
}
});
backToTopBtn.addEventListener('click', (e) => {
e.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
// --- WhatsApp Form Submission ---
const contactForm = document.getElementById('contact-form');
if (contactForm) {
contactForm.addEventListener('submit', (e) => {
e.preventDefault();
const name = document.getElementById('user-name').value;
const phone = document.getElementById('user-phone').value;
const message = document.getElementById('user-message').value;
// Format phone number
const ownerPhone = '918120803821';
const formattedMessage = `*New Booking Request*\n\n*Name:* ${name}\n*Phone:* ${phone}\n*Message:* ${message}`;
const whatsappUrl = `https://wa.me/${ownerPhone}?text=${encodeURIComponent(formattedMessage)}`;
window.open(whatsappUrl, '_blank');
// Optional: Clear form
contactForm.reset();
});
}
});