fix: maintain scroll position when toggling logos

- Save scroll position before toggling logos on/off
- Restore scroll position after DOM updates using requestAnimationFrame
- Prevents page jump when switching logo visibility
This commit is contained in:
juanatsap
2025-11-07 22:13:16 +00:00
parent c1d0dae725
commit 1c93050a40
+8
View File
@@ -354,11 +354,19 @@
const toggle = document.getElementById('logoToggle');
const paper = document.querySelector('.cv-paper');
// Save current scroll position
const currentScrollY = window.scrollY || window.pageYOffset;
if (toggle.checked) {
paper.classList.add('show-logos');
} else {
paper.classList.remove('show-logos');
}
// Restore scroll position after DOM updates
requestAnimationFrame(() => {
window.scrollTo(0, currentScrollY);
});
}
function toggleTheme() {