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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user