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 authored and nilmerg committed Aug 14, 2024
1 parent 4ea3beb commit cc9572d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions public/css/icinga/menu.less
Original file line number Diff line number Diff line change
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
10 changes: 7 additions & 3 deletions public/js/icinga/behavior/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,22 @@
$target.siblings().not($target).removeClass('hover');
$target.addClass('hover');

var targetHeight = $target.offset().top + $target.outerHeight();
$flyout.css({
bottom: 'auto',
top: $target.offset().top + $target.outerHeight()
top: targetHeight
});

var rect = $flyout[0].getBoundingClientRect();

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

0 comments on commit cc9572d

Please sign in to comment.