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