File size: 3,864 Bytes
da8a375 c12dcfa da8a375 c12dcfa da8a375 c12dcfa da8a375 c12dcfa da8a375 0e18e3c da8a375 c12dcfa da8a375 c12dcfa 0e18e3c da8a375 0e18e3c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
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);
}
}); |