Commit ca38cd67 authored by Andrew Shu's avatar Andrew Shu Committed by Deimos

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.
parent 33f551fb
......@@ -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() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment