From e84c90533b2e34054ba235b0f463309119b4cdbe Mon Sep 17 00:00:00 2001 From: Deimos Date: Tue, 21 Jul 2020 15:15:57 -0600 Subject: [PATCH] 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. --- tildes/static/js/behaviors/dropdown-toggle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tildes/static/js/behaviors/dropdown-toggle.js b/tildes/static/js/behaviors/dropdown-toggle.js index b998d3c..7c20048 100644 --- a/tildes/static/js/behaviors/dropdown-toggle.js +++ b/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;