-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
62 lines (52 loc) · 2.27 KB
/
Copy pathscript.js
File metadata and controls
62 lines (52 loc) · 2.27 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
document.addEventListener('DOMContentLoaded', () => {
// --- Set Current Year in Footer ---
const currentYearSpan = document.getElementById('current-year');
if (currentYearSpan) {
currentYearSpan.textContent = new Date().getFullYear();
}
// --- Intersection Observer for Reveal Animations ---
const revealElements = document.querySelectorAll('.reveal');
const observerOptions = {
root: null, // Use the viewport as the root
rootMargin: '0px',
threshold: 0.1 // Trigger when 10% of the element is visible
};
const observerCallback = (entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
// Optional: Unobserve after revealing to save resources
// observer.unobserve(entry.target);
} else {
// Optional: Remove 'visible' class to re-animate if scrolling up
// entry.target.classList.remove('visible');
// Consider performance implications if you enable this.
// For a minimal portfolio, animating only once is often better.
}
});
};
const intersectionObserver = new IntersectionObserver(observerCallback, observerOptions);
revealElements.forEach(el => {
intersectionObserver.observe(el);
});
// --- Optional: Smooth Scroll for internal links (if CSS scroll-behavior isn't enough) ---
// This provides more control but CSS `scroll-behavior: smooth` is simpler.
// Uncomment if needed:
/*
const scrollLinks = document.querySelectorAll('a[href^="#"]');
scrollLinks.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'start' // Adjust alignment if needed ('center', 'end')
});
}
});
});
*/
console.log("Abstract portfolio script loaded.");
});