Skip to content

Commit

Permalink
Fixed menu bug
Browse files Browse the repository at this point in the history
Fixed a menu bug in the desktop version. When a user clicks on a section link in the desktop version menu on the Getting Started page, it is hidden, just like in the phone version.
  • Loading branch information
edmishchenko authored Feb 5, 2024
1 parent 05b666d commit 5816404
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions docs/getStarted.html
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ <h2>Go Further</h2>
</div>
</footer>
<script>
let screenWidth = window.innerWidth;
window.addEventListener("resize", () => {
screenWidth = window.innerWidth;
})


<!-- Hamburger animation -->
const btn = document.getElementById("btn");
const hamburger = document.getElementById("hamburger");
Expand All @@ -466,11 +472,13 @@ <h2>Go Further</h2>
function onClickHamburgerMenu(){
const isActive = hamburger.classList.contains("is-active");

hamburger.classList.toggle("is-active", !isActive);
thirdColumn.classList.toggle("show", !isActive);
thirdColumn.classList.toggle("hide", isActive);
if (screenWidth < 992) {
hamburger.classList.toggle("is-active", !isActive);
thirdColumn.classList.toggle("show", !isActive);
thirdColumn.classList.toggle("hide", isActive);

checkThirdColumn();
checkThirdColumn();
}
}

btn.onclick = onClickHamburgerMenu;
Expand All @@ -481,17 +489,12 @@ <h2>Go Further</h2>
: thirdColumn.style.display = 'block';
}
function toggleThirdColumnVisibility() {
const screenWidth = getScreenWidth();

// Check if the screen width is more than 992px
(screenWidth >= 992)
? (btn.style.display = 'none', thirdColumn.style.display = 'block')
: (btn.style.display = 'block', thirdColumn.style.display = 'none',
hamburger.classList.remove("is-active"));
}
function getScreenWidth() {
return window.innerWidth;
}

window.addEventListener('resize', toggleThirdColumnVisibility);
toggleThirdColumnVisibility();
Expand Down

0 comments on commit 5816404

Please sign in to comment.