When click the dropdown hide it
This commit is contained in:
parent
a1284ca5a5
commit
c5c3ebca24
1 changed files with 14 additions and 5 deletions
19
js/navbar.js
19
js/navbar.js
|
@ -8,6 +8,8 @@ var enterAnimation = false;
|
||||||
var dropdownList = document.getElementById("navbar_text-container").children[0].children;
|
var dropdownList = document.getElementById("navbar_text-container").children[0].children;
|
||||||
//each <a> tag in the navbar
|
//each <a> tag in the navbar
|
||||||
var aTagList = getNavbarTextContainer();
|
var aTagList = getNavbarTextContainer();
|
||||||
|
//a list
|
||||||
|
var dropdownStatus = Array(aTagList.length).fill(false);
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* animjs */
|
/* animjs */
|
||||||
|
@ -104,11 +106,18 @@ document.getElementById("navbar_logo-container").addEventListener("mouseleave",
|
||||||
for (var dropdownElement of dropdownList) {
|
for (var dropdownElement of dropdownList) {
|
||||||
var dropdownLink = dropdownElement.children[0];
|
var dropdownLink = dropdownElement.children[0];
|
||||||
dropdownLink.addEventListener("click", function (e) {
|
dropdownLink.addEventListener("click", function (e) {
|
||||||
//We reset all navbar
|
if (e.target.parentNode.children.length > 1)
|
||||||
resetNavbar();
|
{
|
||||||
//we get the parent node of the <a> tag
|
var styleDropdown = e.target.parentNode.children[1].style.display;
|
||||||
var dropdownLink = e.target.parentNode;
|
//We reset all navbar
|
||||||
setDropdown("block", dropdownLink);
|
resetNavbar();
|
||||||
|
//If the dropdown was hidden, show the item
|
||||||
|
if(!(styleDropdown == "block")) {
|
||||||
|
//we get the parent node of the <a> tag
|
||||||
|
var dropdownLink = e.target.parentNode;
|
||||||
|
setDropdown("block", dropdownLink);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue