Krish101pp's picture
**“Create a fully responsive and visually appealing Indian-themed restaurant website using HTML, CSS, and JavaScript.
072af4e verified
Raw History Blame Contribute Delete
1.82 kB
// Smooth scrolling for navigation
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Mobile menu toggle
const menuToggle = document.querySelector('.menu-toggle');
const navMenu = document.querySelector('.nav-menu');
menuToggle.addEventListener('click', () => {
navMenu.classList.toggle('active');
menuToggle.classList.toggle('active');
});
// Sticky navbar
window.addEventListener('scroll', function() {
const navbar = document.querySelector('custom-navbar');
if (window.scrollY > 100) {
navbar.classList.add('sticky');
} else {
navbar.classList.remove('sticky');
}
});
// Testimonial slider functionality
let currentTestimonial = 0;
const testimonials = document.querySelectorAll('.testimonial-card');
const totalTestimonials = testimonials.length;
function showTestimonial(index) {
testimonials.forEach((testimonial, i) => {
testimonial.style.display = i === index ? 'block' : 'none';
});
}
function nextTestimonial() {
currentTestimonial = (currentTestimonial + 1) % totalTestimonials;
showTestimonial(currentTestimonial);
}
function prevTestimonial() {
currentTestimonial = (currentTestimonial - 1 + totalTestimonials) % totalTestimonials;
showTestimonial(currentTestimonial);
}
// Initialize first testimonial
showTestimonial(0);
// Set interval for auto-rotation
setInterval(nextTestimonial, 5000);
// Scroll down arrow animation
document.querySelector('.scroll-down').addEventListener('click', function() {
window.scrollBy({
top: window.innerHeight - 100,
behavior: 'smooth'
});
});