From 54a794f2dfe88cdaa0dcc5c43f17fbc966082035 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Thu, 10 Nov 2016 17:24:57 -0600 Subject: [PATCH] adjust scrollToElement to account for fixed merge request tabs --- app/assets/javascripts/merge_request_tabs.js.es6 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/merge_request_tabs.js.es6 b/app/assets/javascripts/merge_request_tabs.js.es6 index 1a3df1bed36..10a2f8091b8 100644 --- a/app/assets/javascripts/merge_request_tabs.js.es6 +++ b/app/assets/javascripts/merge_request_tabs.js.es6 @@ -135,12 +135,14 @@ scrollToElement(container) { if (location.hash) { - const navBarHeight = $('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight() + document.querySelector('.js-tabs-affix').offsetHeight; + const offset = 0 - ( + $('.navbar-gitlab').outerHeight() + + $('.layout-nav').outerHeight() + + $('.js-tabs-affix').outerHeight() + ); const $el = $(`${container} ${location.hash}:not(.match)`); - if ($el.length) { - $.scrollTo($el[0], { - offset: -navBarHeight, - }); + if ($el.length > 0) { + $.scrollTo($el[0], { offset }); } } }