From c5c3ebca243688ecd363f1e90127d2f1e95d2322 Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Mon, 19 Jun 2023 22:06:47 +0200 Subject: [PATCH] When click the dropdown hide it --- js/navbar.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/js/navbar.js b/js/navbar.js index 18ca89d..7081684 100644 --- a/js/navbar.js +++ b/js/navbar.js @@ -8,6 +8,8 @@ var enterAnimation = false; var dropdownList = document.getElementById("navbar_text-container").children[0].children; //each tag in the navbar var aTagList = getNavbarTextContainer(); +//a list +var dropdownStatus = Array(aTagList.length).fill(false); /****************************************/ /* animjs */ @@ -104,11 +106,18 @@ document.getElementById("navbar_logo-container").addEventListener("mouseleave", for (var dropdownElement of dropdownList) { var dropdownLink = dropdownElement.children[0]; dropdownLink.addEventListener("click", function (e) { - //We reset all navbar - resetNavbar(); - //we get the parent node of the tag - var dropdownLink = e.target.parentNode; - setDropdown("block", dropdownLink); + if (e.target.parentNode.children.length > 1) + { + var styleDropdown = e.target.parentNode.children[1].style.display; + //We reset all navbar + resetNavbar(); + //If the dropdown was hidden, show the item + if(!(styleDropdown == "block")) { + //we get the parent node of the tag + var dropdownLink = e.target.parentNode; + setDropdown("block", dropdownLink); + } + } }); }