|
122 | 122 | height: 3px; |
123 | 123 | background: var(--accent-blue); |
124 | 124 | border-radius: 3px; |
125 | | - transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); |
126 | 125 | z-index: 1; |
127 | 126 | box-shadow: 0 0 10px rgba(0, 210, 255, 0.5); |
128 | 127 | pointer-events: none; |
129 | 128 | opacity: 0; |
| 129 | + /* Animacja wyłączona domyślnie, włączana dynamicznie po załadowaniu */ |
| 130 | + transition: none; |
| 131 | + } |
| 132 | + |
| 133 | + .nav-indicator.animated { |
| 134 | + transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); |
130 | 135 | } |
131 | 136 |
|
132 | 137 | /* DROPDOWN APPS */ |
|
348 | 353 | <a href="/" class="nav-link-btn {% if page.url == '/' %}active-page{% endif %}">Hub</a> |
349 | 354 | <a href="/newsy" class="nav-link-btn {% if page.url contains 'newsy' %}active-page{% endif %}">Newsy</a> |
350 | 355 | <a href="/blog" class="nav-link-btn {% if page.url contains 'blog' %}active-page{% endif %}">Blog</a> |
351 | | - <a href="/homelab" class="nav-link-btn {% if page.url contains 'homelab' %}active-page{% endif %}">HomeLab</a> |
| 356 | + <a href="/homelab" class="nav-link-btn {% if page.url == '/homelab' or page.url == '/homelab/' %}active-page{% endif %}">HomeLab</a> |
352 | 357 | <a href="/sponsors" class="nav-link-btn {% if page.url contains 'sponsors' %}active-page{% endif %}">Sponsors</a> |
353 | 358 |
|
354 | 359 | <div class="dropdown" id="dropdownApps"> |
| 360 | + <!-- Wyraźny warunek dla całej grupy aplikacji w sekcji Apps --> |
355 | 361 | <a href="#" class="nav-link-btn dropbtn {% if page.url contains 'orbit' or page.url contains 'homelab-cc' or page.url contains 'phone' or page.url contains 'apps' %}active-page{% endif %}" onclick="return false;">Apps ▾</a> |
356 | 362 | <div class="dropdown-content"> |
357 | 363 | <div class="dropdown-links-wrapper"> |
@@ -464,42 +470,46 @@ <h4>Follow DevLabStudy</h4> |
464 | 470 | const indicator = document.getElementById('navIndicator'); |
465 | 471 | const activeLink = navCenter.querySelector('.nav-link-btn.active-page') || navCenter.querySelector('.nav-link-btn'); |
466 | 472 |
|
467 | | - function positionIndicator(targetEl) { |
| 473 | + function positionIndicator(targetEl, enableAnimation = true) { |
468 | 474 | if (!targetEl) return; |
| 475 | + |
469 | 476 | const parentRect = navCenter.getBoundingClientRect(); |
470 | 477 | const targetRect = targetEl.getBoundingClientRect(); |
471 | | - |
472 | 478 | const leftOffset = targetRect.left - parentRect.left; |
473 | 479 | const targetWidth = targetRect.width; |
474 | 480 |
|
| 481 | + if (enableAnimation) { |
| 482 | + indicator.classList.add('animated'); |
| 483 | + } else { |
| 484 | + indicator.classList.remove('animated'); |
| 485 | + } |
| 486 | + |
475 | 487 | indicator.style.width = `${targetWidth}px`; |
476 | 488 | indicator.style.transform = `translateX(${leftOffset}px)`; |
477 | 489 | indicator.style.opacity = '1'; |
478 | 490 | } |
479 | 491 |
|
480 | | - // Ustaw pozycję po pełnym wyrenderowaniu i załadowaniu fontów |
| 492 | + // Ustaw pozycję natychmiastowo bez animacji startowej po wyrenderowaniu |
481 | 493 | document.fonts.ready.then(() => { |
482 | | - positionIndicator(activeLink); |
| 494 | + positionIndicator(activeLink, false); |
483 | 495 | }); |
484 | 496 |
|
485 | | - // Obsługa najechania na każdy przycisk na pasku |
| 497 | + // Reagowanie na ruch myszki |
486 | 498 | const mainNavBtns = navCenter.querySelectorAll(':scope > .nav-link-btn, :scope > .dropdown'); |
487 | 499 | mainNavBtns.forEach(item => { |
488 | 500 | const buttonToHighlight = item.classList.contains('dropdown') ? item.querySelector('.dropbtn') : item; |
489 | 501 |
|
490 | 502 | item.addEventListener('mouseenter', () => { |
491 | | - positionIndicator(buttonToHighlight); |
| 503 | + positionIndicator(buttonToHighlight, true); |
492 | 504 | }); |
493 | 505 | }); |
494 | 506 |
|
495 | | - // Opuszczenie paska nawigacji -> powrót na aktywny przycisk |
496 | 507 | navCenter.addEventListener('mouseleave', () => { |
497 | | - positionIndicator(activeLink); |
| 508 | + positionIndicator(activeLink, true); |
498 | 509 | }); |
499 | 510 |
|
500 | | - // Odświeżenie pozycji przy zmianie rozmiaru okna |
501 | 511 | window.addEventListener('resize', () => { |
502 | | - positionIndicator(activeLink); |
| 512 | + positionIndicator(activeLink, false); |
503 | 513 | }); |
504 | 514 | }); |
505 | 515 | </script> |
|
0 commit comments