Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pietrolama authored Dec 9, 2024
1 parent a2139ee commit 3ce47a8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,41 @@ document.addEventListener('DOMContentLoaded', () => {
});
});
});

document.addEventListener('DOMContentLoaded', () => {
const parallaxSection = document.querySelector('.parallax-section');

// Controlla se .parallax-section esiste
if (parallaxSection) {
document.addEventListener("scroll", function () {
if (window.scrollY > 50) {
parallaxSection.classList.add("scroll");
} else {
parallaxSection.classList.remove("scroll");
}
});
} else {
console.log("Nessuna sezione parallax presente in questa pagina.");
}
});


document.addEventListener('DOMContentLoaded', () => {
const cards = document.querySelectorAll('.card');

cards.forEach(card => {
// Trova il link all'interno della card
const link = card.querySelector('.btn');
if (link) {
const url = link.getAttribute('href');

// Aggiungi l'event listener alla card
card.addEventListener('click', (event) => {
// Se il click non è sul link stesso, reindirizza
if (!event.target.closest('.btn')) {
window.location.href = url;
}
});
}
});
});

0 comments on commit 3ce47a8

Please sign in to comment.