Browse Source

Use "outer" sizes for checking dropdown overflow

The "outer" width/height functions also include padding and border. Not
including these didn't make a noticeable difference for the left/right
flipping (the omissions almost canceled each other out), but the
discrepancy is much more noticeable on the top/bottom flipping.
merge-requests/118/merge
Deimos 4 years ago
parent
commit
e84c90533b
  1. 4
      tildes/static/js/behaviors/dropdown-toggle.js

4
tildes/static/js/behaviors/dropdown-toggle.js

@ -32,12 +32,12 @@ $.onmount(".dropdown-toggle", function() {
.parent()
.toggleClass(
"dropdown-right",
$this.offset().left + $this.width() - $menu.width() > 0
$this.offset().left + $this.outerWidth() - $menu.outerWidth() > 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 menuBottom = $this.offset().top + $this.outerHeight() + $menu.outerHeight();
var viewportHeight = $(window).height();
var scrollTop = $(document).scrollTop();
var footerTop = $("#site-footer").offset().top;

Loading…
Cancel
Save