Spaces:
Running
Running
File size: 6,311 Bytes
c6ace36 | 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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | // Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
// Hide loader after page loads
setTimeout(() => {
const loader = document.getElementById('loader');
loader.classList.add('hidden');
setTimeout(() => loader.remove(), 500);
}, 1000);
// 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'
});
}
});
});
// Booking form submission
const bookingForm = document.getElementById('bookingForm');
if (bookingForm) {
bookingForm.addEventListener('submit', function(e) {
e.preventDefault();
// Create success notification
const notification = document.createElement('div');
notification.className = 'fixed top-4 right-4 bg-gradient-to-r from-orange-500 to-fuchsia-500 text-white px-6 py-4 rounded-lg shadow-2xl z-50 transform translate-x-full transition-transform';
notification.innerHTML = `
<div class="flex items-center gap-3">
<i data-feather="check-circle" class="w-6 h-6"></i>
<div>
<p class="font-bold">Booking Confirmed!</p>
<p class="text-sm opacity-90">We'll send you a confirmation email soon.</p>
</div>
</div>
`;
document.body.appendChild(notification);
feather.replace();
// Animate in
setTimeout(() => {
notification.style.transform = 'translateX(0)';
}, 100);
// Remove after 5 seconds
setTimeout(() => {
notification.style.transform = 'translateX(120%)';
setTimeout(() => notification.remove(), 300);
}, 5000);
// Reset form
bookingForm.reset();
});
}
// Intersection Observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe all sections
document.querySelectorAll('section').forEach(section => {
section.style.opacity = '0';
section.style.transform = 'translateY(30px)';
section.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(section);
});
// Gallery image viewer
const galleryImages = document.querySelectorAll('#gallery img');
galleryImages.forEach(img => {
img.addEventListener('click', function() {
const viewer = document.createElement('div');
viewer.className = 'fixed inset-0 bg-black bg-opacity-90 z-50 flex items-center justify-center p-4';
viewer.innerHTML = `
<div class="relative max-w-4xl max-h-full">
<img src="${this.src}" alt="${this.alt}" class="max-w-full max-h-full rounded-lg">
<button class="absolute top-4 right-4 text-white bg-black bg-opacity-50 rounded-full p-2 hover:bg-opacity-75">
<i data-feather="x" class="w-6 h-6"></i>
</button>
</div>
`;
document.body.appendChild(viewer);
feather.replace();
viewer.addEventListener('click', function(e) {
if (e.target === viewer || e.target.closest('button')) {
viewer.remove();
}
});
});
});
// Dynamic typing effect for hero title
const heroTitle = document.querySelector('h1');
if (heroTitle) {
const text = heroTitle.textContent;
heroTitle.textContent = '';
let index = 0;
const typeWriter = () => {
if (index < text.length) {
heroTitle.textContent += text.charAt(index);
index++;
setTimeout(typeWriter, 100);
}
};
setTimeout(typeWriter, 500);
}
// Add ripple effect to buttons
document.querySelectorAll('button').forEach(button => {
button.classList.add('ripple');
});
// Parallax effect for hero section
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const parallax = document.querySelector('.hero-image');
if (parallax) {
parallax.style.transform = `translateY(${scrolled * 0.5}px)`;
}
});
// Counter animation
function animateCounter(element, target, duration = 2000) {
let start = 0;
const increment = target / (duration / 16);
const updateCounter = () => {
start += increment;
if (start < target) {
element.textContent = Math.floor(start);
requestAnimationFrame(updateCounter);
} else {
element.textContent = target;
}
};
updateCounter();
}
// Observe counter elements
const counters = document.querySelectorAll('.counter');
const counterObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting && !entry.target.classList.contains('counted')) {
const target = parseInt(entry.target.getAttribute('data-target'));
animateCounter(entry.target, target);
entry.target.classList.add('counted');
}
});
}, { threshold: 0.5 });
counters.forEach(counter => {
counterObserver.observe(counter);
});
}); |