Skip to content

Commit 9cdb0a9

Browse files
authored
Update default.html
1 parent a3f7025 commit 9cdb0a9

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

‎_layouts/default.html‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@
121121
height: 3px;
122122
background: var(--accent-blue);
123123
border-radius: 3px;
124-
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
124+
/* Płynna, naturalna animacja */
125+
transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
125126
z-index: 1;
126127
box-shadow: 0 0 10px rgba(0, 210, 255, 0.5);
127128
}
@@ -447,10 +448,35 @@ <h4>Follow DevLabStudy</h4>
447448
indicator.style.left = el.offsetLeft + 'px';
448449
}
449450

450-
// Ustawienie początkowe na aktywną stronę
451-
moveIndicator(activeLink);
451+
// Sprawdzamy czy w pamięci przeglądarki (sessionStorage) mamy zapisaną poprzednią pozycję wskaźnika,
452+
// dzięki czemu po kliknięciu linku animacja rusza z miejsca, w którym użytkownik aktualnie znajdował się na stronie!
453+
const savedLeft = sessionStorage.getItem('nav_indicator_left');
454+
const savedWidth = sessionStorage.getItem('nav_indicator_width');
452455

456+
if (savedLeft !== null && savedWidth !== null) {
457+
// Tymczasowo ustawiamy wskaźnik dokładnie w miejscu sprzed przeładowania bez animacji
458+
indicator.style.transition = 'none';
459+
indicator.style.left = savedLeft;
460+
indicator.style.width = savedWidth;
461+
462+
// Wymuszenie odświeżenia layoutu (reflow)
463+
void indicator.offsetHeight;
464+
465+
// Przywracamy płynne przejście i płynnie animujemy do faktycznego aktywnego elementu nowej strony
466+
indicator.style.transition = '';
467+
moveIndicator(activeLink);
468+
} else {
469+
// Jeśli brak historii sesji, ustawiamy standardowo na aktywny link
470+
moveIndicator(activeLink);
471+
}
472+
473+
// Zapisujemy pozycję po kliknięciu w jakikolwiek link nawigacji
453474
navLinks.forEach(link => {
475+
link.addEventListener('click', () => {
476+
sessionStorage.setItem('nav_indicator_left', link.offsetLeft + 'px');
477+
sessionStorage.setItem('nav_indicator_width', link.offsetWidth + 'px');
478+
});
479+
454480
link.addEventListener('mouseenter', () => {
455481
moveIndicator(link);
456482
});

0 commit comments

Comments
 (0)