Skip to content

Commit

Permalink
Flyout menu: Render menu bottom-up if it exceeds the viewport height
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jun 12, 2023
1 parent 7eb6359 commit 99f6765
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions public/css/icinga/menu.less
Expand Up @@ -270,6 +270,12 @@
left: -.6em;
z-index: -1;
}

&.bottom-up:after {
top: unset;
bottom: 1em;
}

> .nav-item {
display: block;
padding-left: 0;
Expand Down
7 changes: 6 additions & 1 deletion public/js/icinga/behavior/navigation.js
Expand Up @@ -296,6 +296,8 @@
var $target = $(this);
var $flyout = $target.find('.nav-level-2');

$flyout.removeClass('down-to-up');

if (! $flyout.length) {
$layout.removeClass('menu-hovered');
$target.siblings().not($target).removeClass('hover');
Expand Down Expand Up @@ -327,10 +329,13 @@
var rect = $flyout[0].getBoundingClientRect();

if (rect.y + rect.height > window.innerHeight) {
$flyout.addClass('bottom-up');
$flyout.css({
bottom: 0,
bottom: window.innerHeight - ($target.offset().top + $target.find('> a')[0].offsetHeight),
top: 'auto'
});
} else {
$flyout.removeClass('bottom-up');
}
}, delay);
};
Expand Down

0 comments on commit 99f6765

Please sign in to comment.