bhuzera's picture
https://sitecleber.buchholz.net.br/ copie fielmente esse site
da8a375 verified
Raw History Blame Contribute Delete
3.86 kB
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for all links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
// Add animation styles dynamically
const style = document.createElement('style');
style.textContent = `
.animate {
animation: fadeInUp 0.8s ease forwards;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.success-message {
background-color: #f8f9fa;
padding: 30px;
border-radius: 8px;
text-align: center;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.success-message h3 {
color: #28a745;
margin-bottom: 15px;
}
`;
document.head.appendChild(style);
}
});
});
// Contact form handling
const contactForm = document.getElementById('contact-form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const subject = document.getElementById('subject').value;
const message = document.getElementById('message').value;
// Here you would typically send the form data to a server
// For demo purposes, we'll just show a success message
const successMessage = document.createElement('div');
successMessage.className = 'success-message';
successMessage.innerHTML = `
<h3>Obrigado, ${name}!</h3>
<p>Sua mensagem foi enviada com sucesso. Entrarei em contato em breve.</p>
`;
contactForm.parentNode.replaceChild(successMessage, contactForm);
// In a real implementation, you would use fetch() to send the data
// fetch('/api/contact', {
// method: 'POST',
// headers: { 'Content-Type': 'application/json' },
// body: JSON.stringify({ name, email, subject, message })
// })
// .then(response => response.json())
// .then(data => {
// if (data.success) {
// // Show success message
// } else {
// // Show error message
// }
// });
});
}
// Add scroll animation to elements
const animateOnScroll = function() {
const elements = document.querySelectorAll('.service-card, .about-image img');
elements.forEach(element => {
const elementPosition = element.getBoundingClientRect().top;
const windowHeight = window.innerHeight;
if (elementPosition < windowHeight - 100) {
element.classList.add('animate');
}
});
};
// Run once on load and then on scroll
animateOnScroll();
window.addEventListener('scroll', animateOnScroll);
// Add animation class to hero content
const heroContent = document.querySelector('.hero-content');
if (heroContent) {
setTimeout(() => {
heroContent.classList.add('animate');
}, 300);
}
});