codecanvas-creator / script.js
Technosahid's picture
make a better stylish for developer
83c2dd3 verified
Raw History Blame Contribute Delete
2.68 kB
document.addEventListener('DOMContentLoaded', function() {
// Navbar scroll effect
const navbar = document.querySelector('custom-navbar');
window.addEventListener('scroll', function() {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Intersection Observer for section animations
const sections = document.querySelectorAll('section');
const observerOptions = {
threshold: 0.1
};
const observer = new IntersectionObserver(function(entries, observer) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('show');
observer.unobserve(entry.target);
}
});
}, observerOptions);
sections.forEach(section => {
observer.observe(section);
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
});
}
});
});
// Skill card hover effect
const skillCards = document.querySelectorAll('.skill-card');
skillCards.forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-10px)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
});
});
// Contact form submission
const contactForm = document.querySelector('form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Get form values
const name = this.querySelector('#name').value;
const email = this.querySelector('#email').value;
const subject = this.querySelector('#subject').value;
const message = this.querySelector('#message').value;
// Here you would typically send the form data to a server
console.log({ name, email, subject, message });
// Show success message
alert('Thank you for your message! I will get back to you soon.');
this.reset();
});
}
});