diff options
author | Phil Hughes <me@iamphill.com> | 2017-07-24 18:14:29 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-07-24 18:14:29 +0300 |
commit | 72538b5f9f6f1be0ba421a76c2a24da4dd23db0e (patch) | |
tree | c93d1c6166d805309ded9cffa0a051634d92e23b /app/assets/javascripts/fly_out_nav.js | |
parent | 4d2be5bbec25d60a8d478bda5bc83159f2c845b1 (diff) |
improvements to positioning of the dropdown
Diffstat (limited to 'app/assets/javascripts/fly_out_nav.js')
-rw-r--r-- | app/assets/javascripts/fly_out_nav.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/assets/javascripts/fly_out_nav.js b/app/assets/javascripts/fly_out_nav.js index 1ae2e72410f..f2151396d43 100644 --- a/app/assets/javascripts/fly_out_nav.js +++ b/app/assets/javascripts/fly_out_nav.js @@ -2,7 +2,8 @@ export const calculateTop = (boundingRect, outerHeight) => { const windowHeight = window.innerHeight; const bottomOverflow = windowHeight - (boundingRect.top + outerHeight); - return bottomOverflow < 0 ? boundingRect.top - Math.abs(bottomOverflow) : boundingRect.top; + return bottomOverflow < 0 ? (boundingRect.top - outerHeight) + boundingRect.height : + boundingRect.top; }; export default () => { @@ -13,10 +14,15 @@ export default () => { if ($subitems.length) { const boundingRect = $this.getBoundingClientRect(); const top = calculateTop(boundingRect, $subitems.outerHeight()); + const isAbove = top < boundingRect.top; $subitems.css({ transform: `translate3d(0, ${top}px, 0)`, }); + + if (isAbove) { + $subitems.addClass('is-above'); + } } - }).on('mouseout', e => $('.sidebar-sub-level-items', e.currentTarget).hide()); + }).on('mouseout', e => $('.sidebar-sub-level-items', e.currentTarget).hide().removeClass('is-above')); }; |