Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tomickigrzegorz committed Jul 15, 2023
1 parent 566ef50 commit 8e68e52
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ function showHideLi(e) {
sumOfAllWidths = sumOfAllWidths + Number(li.dataset.width);
widthAllLi += li.getBoundingClientRect().width.toFixed(0) * 1;

if (widthMenu < widthAllLi) {
// 40 this is button width show submenu
if (widthMenu - 40 < widthAllLi) {
if (li.classList.contains("sub-menu")) return;
arrayLi.push(li);
li.remove();
Expand All @@ -45,7 +46,7 @@ function showHideLi(e) {
const firstELementSubMenu = +firstElementFromSubMenu?.dataset.width;

if (firstElementFromSubMenu) {
if (firstELementSubMenu + sumOfAllWidths <= widthMenu - 45) {
if (firstELementSubMenu + sumOfAllWidths <= widthMenu) {
subMenu.insertAdjacentElement("beforebegin", firstElementFromSubMenu);
}
} else {
Expand Down

0 comments on commit 8e68e52

Please sign in to comment.