mirror of
https://gitlab.com/tildes/tildes.git
synced 2026-04-16 06:18:34 +02:00
Push dropdown up if it's off bottom of screen/site
Use bottom: 100% to make sure the menu does not overlap the button (as with bottom: 0). If it overlaps the button then that interferes with the button click handler.
This commit is contained in:
@@ -11,6 +11,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
&.dropdown-bottom {
|
||||
.menu {
|
||||
top: auto;
|
||||
bottom: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&-toggle.btn-post-action {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,19 @@ $.onmount(".dropdown-toggle", function() {
|
||||
"dropdown-right",
|
||||
$this.offset().left + $this.width() - $menu.width() > 0
|
||||
);
|
||||
|
||||
// If the menu extends past the bottom of the viewport, or the site footer
|
||||
// overlaps the menu, push the menu above the button instead.
|
||||
var menuBottom = $this.offset().top + $this.height() + $menu.height();
|
||||
var viewportHeight = $(window).height();
|
||||
var scrollTop = $(document).scrollTop();
|
||||
var footerTop = $("#site-footer").offset().top;
|
||||
$this
|
||||
.parent()
|
||||
.toggleClass(
|
||||
"dropdown-bottom",
|
||||
menuBottom > viewportHeight + scrollTop || menuBottom > footerTop
|
||||
);
|
||||
});
|
||||
|
||||
$(this).blur(function() {
|
||||
|
||||
Reference in New Issue
Block a user