diff options
Diffstat (limited to 'app/assets/javascripts/merge_request_tabs.js')
-rw-r--r-- | app/assets/javascripts/merge_request_tabs.js | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index 6e9661ea1a8..81241cd2418 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -1,7 +1,6 @@ /* eslint-disable no-new, class-methods-use-this */ import $ from 'jquery'; -import 'vendor/jquery.scrollTo'; import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import Cookies from 'js-cookie'; import createEventHub from '~/helpers/event_hub_factory'; @@ -14,6 +13,7 @@ import { handleLocationHash, isMetaClick, parseBoolean, + scrollToElement, } from './lib/utils/common_utils'; import { isInVueNoteablePage } from './lib/utils/dom_utils'; import { getLocationHash } from './lib/utils/url_utility'; @@ -128,7 +128,7 @@ export default class MergeRequestTabs { bindEvents() { $('.merge-request-tabs a[data-toggle="tabvue"]').on('click', this.clickTab); - window.addEventListener('popstate', event => { + window.addEventListener('popstate', (event) => { if (event.state && event.state.action) { this.tabShown(event.state.action, event.target.location); this.currentAction = event.state.action; @@ -177,14 +177,14 @@ export default class MergeRequestTabs { this.currentTab = action; if (this.mergeRequestTabPanesAll) { - this.mergeRequestTabPanesAll.forEach(el => { + this.mergeRequestTabPanesAll.forEach((el) => { const tabPane = el; tabPane.style.display = 'none'; }); } if (this.mergeRequestTabsAll) { - this.mergeRequestTabsAll.forEach(el => { + this.mergeRequestTabsAll.forEach((el) => { el.classList.remove('active'); }); } @@ -255,12 +255,12 @@ export default class MergeRequestTabs { this.eventHub.$emit('MergeRequestTabChange', action); } - scrollToElement(container) { + scrollToContainerElement(container) { if (location.hash) { - const offset = 0 - ($('.navbar-gitlab').outerHeight() + $('.js-tabs-affix').outerHeight()); const $el = $(`${container} ${location.hash}:not(.match)`); + if ($el.length) { - $.scrollTo($el[0], { offset }); + scrollToElement($el[0]); } } } @@ -339,7 +339,7 @@ export default class MergeRequestTabs { document.querySelector('div#commits').innerHTML = data.html; localTimeAgo($('.js-timeago', 'div#commits')); this.commitsLoaded = true; - this.scrollToElement('#commits'); + this.scrollToContainerElement('#commits'); this.toggleLoading(false); initAddContextCommitsTriggers(); @@ -408,7 +408,7 @@ export default class MergeRequestTabs { this.diffsLoaded = true; new Diff(); - this.scrollToElement('#diffs'); + this.scrollToContainerElement('#diffs'); $('.diff-file').each((i, el) => { new BlobForkSuggestion({ |