Skip to content

Commit

Permalink
js revert
Browse files Browse the repository at this point in the history
  • Loading branch information
macedonianluke committed Oct 25, 2024
1 parent bc931e9 commit cde1065
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 38 deletions.
93 changes: 55 additions & 38 deletions js/main.js
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);
});
55 changes: 55 additions & 0 deletions rubbish/main_copy_fail1.js
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');
});
});

0 comments on commit cde1065

Please sign in to comment.