Skip to content

Commit cc9572d

Browse files
sukhwinder33445nilmerg
authored andcommitted
Flyout menu: Render menu bottom-up if it exceeds the viewport height
1 parent 4ea3beb commit cc9572d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

public/css/icinga/menu.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@
270270
left: -.6em;
271271
z-index: -1;
272272
}
273+
274+
&.bottom-up:after {
275+
top: unset;
276+
bottom: 1em;
277+
}
278+
273279
> .nav-item {
274280
display: block;
275281
padding-left: 0;

public/js/icinga/behavior/navigation.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,18 +319,22 @@
319319
$target.siblings().not($target).removeClass('hover');
320320
$target.addClass('hover');
321321

322+
var targetHeight = $target.offset().top + $target.outerHeight();
322323
$flyout.css({
323324
bottom: 'auto',
324-
top: $target.offset().top + $target.outerHeight()
325+
top: targetHeight
325326
});
326327

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

329-
if (rect.y + rect.height > window.innerHeight) {
330+
if (rect.bottom > window.innerHeight) {
331+
$flyout.addClass('bottom-up');
330332
$flyout.css({
331-
bottom: 0,
333+
bottom: window.innerHeight - targetHeight,
332334
top: 'auto'
333335
});
336+
} else {
337+
$flyout.removeClass('bottom-up');
334338
}
335339
}, delay);
336340
};

0 commit comments

Comments
 (0)