fix: maintain scroll position when toggling CV length

- Save scroll position before toggling short/long mode
- Restore scroll position after DOM updates using requestAnimationFrame
- Prevents page jump when switching between CV modes
This commit is contained in:
juanatsap
2025-11-07 22:12:05 +00:00
parent b29cae1549
commit c1d0dae725
+8
View File
@@ -333,6 +333,9 @@
const toggle = document.getElementById('lengthToggle');
const paper = document.querySelector('.cv-paper');
// Save current scroll position
const currentScrollY = window.scrollY || window.pageYOffset;
if (toggle.checked) {
paper.classList.add('cv-long');
paper.classList.remove('cv-short');
@@ -340,6 +343,11 @@
paper.classList.add('cv-short');
paper.classList.remove('cv-long');
}
// Restore scroll position after DOM updates
requestAnimationFrame(() => {
window.scrollTo(0, currentScrollY);
});
}
function toggleLogos() {