-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
88 lines (78 loc) · 2.61 KB
/
script.js
File metadata and controls
88 lines (78 loc) · 2.61 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
// Set current year
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('year').textContent = new Date().getFullYear();
loadTab('about');
});
// Tab switching
function showTab(tabName) {
const tabs = document.querySelectorAll('.tab');
tabs.forEach(tab => tab.classList.remove('active'));
if (window.event && window.event.target) {
window.event.target.classList.add('active');
}
loadTab(tabName);
}
// Load tab content from a separate HTML file
function loadTab(tabName) {
const contentArea = document.getElementById('content-area');
contentArea.innerHTML = '<div style="text-align: center; padding: 50px; color: var(--text-muted, #888);">Loading...</div>';
fetch(`pages/${tabName}.html`)
.then(response => {
if (!response.ok) {
throw new Error('Page not found');
}
return response.text();
})
.then(html => {
contentArea.innerHTML = html;
contentArea.classList.add('active');
requestAnimationFrame(() => {
applyRevealAnimations(contentArea);
if (tabName === 'about' && window.location.hash === '#publications') {
const pub = document.getElementById('publications');
if (pub) {
setTimeout(() => pub.scrollIntoView({ behavior: 'smooth', block: 'start' }), 80);
}
}
});
})
.catch(error => {
console.error('Error loading page:', error);
contentArea.innerHTML = `<div style="text-align: center; padding: 50px; color: #999;">Content coming soon...</div>`;
});
}
// Tag eligible elements with .reveal then observe them so they fade in
// once they enter the viewport. This keeps the page feeling alive while
// remaining quiet enough for an academic homepage.
function applyRevealAnimations(root) {
const selectors = [
'.publication-item',
'.project-card',
'.cv-content h2',
'.cv-content h3',
'.cv-content p',
'.cv-content ul'
];
const targets = root.querySelectorAll(selectors.join(','));
if (targets.length === 0) return;
targets.forEach((el, idx) => {
el.classList.add('reveal');
el.style.transitionDelay = `${Math.min(idx * 70, 420)}ms`;
});
if (!('IntersectionObserver' in window)) {
targets.forEach(el => el.classList.add('is-visible'));
return;
}
const observer = new IntersectionObserver((entries, obs) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('is-visible');
obs.unobserve(entry.target);
}
});
}, {
threshold: 0.12,
rootMargin: '0px 0px -40px 0px'
});
targets.forEach(el => observer.observe(el));
}