fix close lang menu click outside
This commit is contained in:
parent
9989413cd5
commit
d4b709dfc5
2 changed files with 19 additions and 8 deletions
|
|
@ -204,6 +204,10 @@ header.sticky-header .header-lang-small {
|
|||
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.63);
|
||||
}
|
||||
|
||||
header.sticky-header .header-lang-small .dropdown .dropdown-content {
|
||||
top: 54px;
|
||||
}
|
||||
|
||||
.header-lang-small .dropdown .dropdown-content li:not(.active) {
|
||||
display: block;
|
||||
padding: 5px 0;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,19 @@
|
|||
document.getElementsByClassName("header-lang-small")[0].addEventListener("click", function(){
|
||||
document.addEventListener("click", function(){
|
||||
var langSelector = document.getElementsByClassName("header-lang-small")[0];
|
||||
var dropdown = document.getElementById("dropdown");
|
||||
var dropdownIcon = document.querySelector('.header-lang-small .icon');
|
||||
console.log(dropdownIcon);
|
||||
if (dropdown.style.display === "block") {
|
||||
dropdown.style.display = "none";
|
||||
dropdownIcon.classList.toggle('active');
|
||||
var isClickInside = langSelector.contains(event.target);
|
||||
if (isClickInside) {
|
||||
if (dropdown.style.display === "block") {
|
||||
dropdown.style.display = "none";
|
||||
dropdownIcon.classList.toggle('active');
|
||||
} else {
|
||||
dropdown.style.display = "block";
|
||||
dropdownIcon.classList.toggle('active');
|
||||
}
|
||||
} else {
|
||||
dropdown.style.display = "block";
|
||||
dropdownIcon.classList.toggle('active');
|
||||
}
|
||||
dropdown.style.display = "none";
|
||||
dropdownIcon.classList.remove('active');
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue