-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
96 lines (82 loc) · 3.21 KB
/
Copy pathscript.js
File metadata and controls
96 lines (82 loc) · 3.21 KB
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
const menuToggle = document.querySelector(".menu-toggle");
const navLinks = document.querySelector(".nav-links");
menuToggle.addEventListener("click", () => {
navLinks.classList.toggle("active");
});
document.addEventListener('DOMContentLoaded', () => {
// Header Scroll Effect
const header = document.getElementById('header');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
header.classList.add('scrolled');
} else {
header.classList.remove('scrolled');
}
});
// Image Carousel Logic
const carouselItems = document.querySelectorAll('.carousel-item');
let currentSlide = 0;
const slideInterval = 5000; // 5 seconds
function nextSlide() {
carouselItems[currentSlide].classList.remove('active');
currentSlide = (currentSlide + 1) % carouselItems.length;
carouselItems[currentSlide].classList.add('active');
}
setInterval(nextSlide, slideInterval);
// Smooth Scroll for Navigation
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
window.scrollTo({
top: target.offsetTop - 70, // Adjust for fixed header
behavior: 'smooth'
});
navLinks.classList.toggle("active");
}
});
});
// Simple Scroll Reveal Animation
const observerOptions = {
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
const revealElements = document.querySelectorAll('.feature-card, .about-text, .about-image, .contact-item');
revealElements.forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(30px)';
el.style.transition = 'all 0.8s ease-out';
observer.observe(el);
});
// Theme Toggle Logic
const themeToggle = document.getElementById('theme-toggle');
const themeIcon = themeToggle.querySelector('i');
// Check for saved theme
const savedTheme = localStorage.getItem('theme') || 'dark';
document.documentElement.setAttribute('data-theme', savedTheme);
updateThemeIcon(savedTheme);
themeToggle.addEventListener('click', () => {
const currentTheme = document.documentElement.getAttribute('data-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
updateThemeIcon(newTheme);
});
function updateThemeIcon(theme) {
if (theme === 'dark') {
themeIcon.classList.remove('fa-sun');
themeIcon.classList.add('fa-moon');
} else {
themeIcon.classList.remove('fa-moon');
themeIcon.classList.add('fa-sun');
}
}
});