-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc931e9
commit cde1065
Showing
2 changed files
with
110 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,72 @@ | ||
// Menu toggle functionality | ||
// Custom cursor | ||
const cursor = document.querySelector('.cursor'); | ||
const links = document.querySelectorAll('a, button'); | ||
|
||
document.addEventListener('mousemove', (e) => { | ||
cursor.style.left = e.clientX + 'px'; | ||
cursor.style.top = e.clientY + 'px'; | ||
}); | ||
|
||
links.forEach(link => { | ||
link.addEventListener('mouseenter', () => { | ||
cursor.classList.add('hover'); | ||
}); | ||
|
||
link.addEventListener('mouseleave', () => { | ||
cursor.classList.remove('hover'); | ||
}); | ||
}); | ||
|
||
// Menu toggle | ||
const menuToggle = document.querySelector('.menu-toggle'); | ||
const menu = document.querySelector('.menu'); | ||
const menuLinks = document.querySelectorAll('.menu-content a'); // Updated selector to match your HTML structure | ||
const menuLinks = document.querySelectorAll('.menu-nav a'); | ||
|
||
menuToggle?.addEventListener('click', () => { | ||
menu?.classList.toggle('active'); | ||
menuToggle.addEventListener('click', () => { | ||
menu.classList.toggle('active'); | ||
document.body.classList.toggle('menu-open'); | ||
}); | ||
|
||
// Smooth scrolling for anchor links | ||
menuLinks.forEach((link, index) => { | ||
// Add transition delay for menu animation | ||
link.style.transitionDelay = `${0.1 * index}s`; | ||
|
||
// Handle click events | ||
link.addEventListener('click', (e) => { | ||
link.addEventListener('click', () => { | ||
menu.classList.remove('active'); | ||
document.body.classList.remove('menu-open'); | ||
}); | ||
}); | ||
|
||
// Smooth scrolling for anchor links | ||
document.querySelectorAll('a[href^="#"]').forEach(anchor => { | ||
anchor.addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
|
||
// Get the target section id from the href | ||
const targetId = link.getAttribute('href')?.replace('#', ''); | ||
const targetSection = document.getElementById(targetId); | ||
|
||
if (targetSection) { | ||
// Close the menu | ||
menu?.classList.remove('active'); | ||
document.body.classList.remove('menu-open'); | ||
|
||
// Scroll to the section | ||
targetSection.scrollIntoView({ | ||
behavior: 'smooth', | ||
block: 'start' | ||
}); | ||
} | ||
document.querySelector(this.getAttribute('href')).scrollIntoView({ | ||
behavior: 'smooth' | ||
}); | ||
}); | ||
}); | ||
|
||
// Custom cursor update | ||
const cursor = document.querySelector('.cursor'); | ||
const links = document.querySelectorAll('a, button'); | ||
// Video lazy loading | ||
const videos = document.querySelectorAll('.fullscreen-video'); | ||
|
||
document.addEventListener('mousemove', (e) => { | ||
cursor?.style.left = e.clientX + 'px'; | ||
cursor?.style.top = e.clientY + 'px'; | ||
}); | ||
const videoOptions = { | ||
root: null, | ||
rootMargin: '0px', | ||
threshold: 0.1 | ||
}; | ||
|
||
links.forEach(link => { | ||
link.addEventListener('mouseenter', () => { | ||
cursor?.classList.add('hover'); | ||
}); | ||
|
||
link.addEventListener('mouseleave', () => { | ||
cursor?.classList.remove('hover'); | ||
const videoObserver = new IntersectionObserver((entries, observer) => { | ||
entries.forEach(entry => { | ||
if (entry.isIntersecting) { | ||
const video = entry.target; | ||
video.play(); | ||
} else { | ||
const video = entry.target; | ||
video.pause(); | ||
} | ||
}); | ||
}, videoOptions); | ||
|
||
videos.forEach(video => { | ||
videoObserver.observe(video); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Menu toggle functionality | ||
const menuToggle = document.querySelector('.menu-toggle'); | ||
const menu = document.querySelector('.menu'); | ||
const menuLinks = document.querySelectorAll('.menu-content a'); // Updated selector to match your HTML structure | ||
|
||
menuToggle?.addEventListener('click', () => { | ||
menu?.classList.toggle('active'); | ||
document.body.classList.toggle('menu-open'); | ||
}); | ||
|
||
// Smooth scrolling for anchor links | ||
menuLinks.forEach((link, index) => { | ||
// Add transition delay for menu animation | ||
link.style.transitionDelay = `${0.1 * index}s`; | ||
|
||
// Handle click events | ||
link.addEventListener('click', (e) => { | ||
e.preventDefault(); | ||
|
||
// Get the target section id from the href | ||
const targetId = link.getAttribute('href')?.replace('#', ''); | ||
const targetSection = document.getElementById(targetId); | ||
|
||
if (targetSection) { | ||
// Close the menu | ||
menu?.classList.remove('active'); | ||
document.body.classList.remove('menu-open'); | ||
|
||
// Scroll to the section | ||
targetSection.scrollIntoView({ | ||
behavior: 'smooth', | ||
block: 'start' | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
// Custom cursor update | ||
const cursor = document.querySelector('.cursor'); | ||
const links = document.querySelectorAll('a, button'); | ||
|
||
document.addEventListener('mousemove', (e) => { | ||
cursor?.style.left = e.clientX + 'px'; | ||
cursor?.style.top = e.clientY + 'px'; | ||
}); | ||
|
||
links.forEach(link => { | ||
link.addEventListener('mouseenter', () => { | ||
cursor?.classList.add('hover'); | ||
}); | ||
|
||
link.addEventListener('mouseleave', () => { | ||
cursor?.classList.remove('hover'); | ||
}); | ||
}); |