Dynamic dropdown menu placement based on the toggle location

This commit is contained in:
Sodbileg Gansukh
2023-11-13 19:29:41 +08:00
parent 946e063117
commit 78ff9df4ea
6 changed files with 13 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -717,9 +717,9 @@ Search LOGO Login Subscribe
transform: translate3d(0, 6px, 0);
}
.is-middle-logo .gh-dropdown {
.gh-dropdown.is-left {
right: auto;
left: -24px;
left: -16px;
}
.is-dropdown-mega .gh-dropdown {

View File

@@ -56,6 +56,13 @@ function dropdown() {
toggle.appendChild(wrapper);
nav.appendChild(toggle);
const toggleRect = toggle.getBoundingClientRect();
const documentCenter = window.innerWidth / 2;
if (toggleRect.left < documentCenter) {
wrapper.classList.add('is-left');
}
head.classList.add('is-dropdown-loaded');
window.addEventListener('click', function (e) {