calculate the stickyTop instead of hard coding a variable

This commit is contained in:
Phil Hughes 2017-10-23 10:21:38 +01:00
parent 016e750308
commit 35daaa36e0
No known key found for this signature in database
GPG Key ID: 32245528C52E0F9F
3 changed files with 13 additions and 4 deletions

View File

@ -239,7 +239,8 @@ import Diff from './diff';
break;
case 'projects:compare:show':
new Diff();
initChangesDropdown();
const paddingTop = 16;
initChangesDropdown(document.querySelector('.navbar-gitlab').offsetHeight - paddingTop);
break;
case 'projects:branches:new':
case 'projects:branches:create':

View File

@ -1,7 +1,7 @@
import stickyMonitor from './lib/utils/sticky';
export default () => {
stickyMonitor(document.querySelector('.js-diff-files-changed'), 76);
export default (stickyTop) => {
stickyMonitor(document.querySelector('.js-diff-files-changed'), stickyTop);
$('.js-diff-stats-dropdown').glDropdown({
filterable: true,

View File

@ -67,6 +67,9 @@ import Diff from './diff';
class MergeRequestTabs {
constructor({ action, setUrl, stubLocation } = {}) {
const mergeRequestTabs = document.querySelector('.js-tabs-affix');
const paddingTop = 16;
this.diffsLoaded = false;
this.pipelinesLoaded = false;
this.commitsLoaded = false;
@ -76,6 +79,11 @@ import Diff from './diff';
this.setCurrentAction = this.setCurrentAction.bind(this);
this.tabShown = this.tabShown.bind(this);
this.showTab = this.showTab.bind(this);
this.stickyTop = document.querySelector('.navbar-gitlab').offsetHeight - paddingTop;
if (mergeRequestTabs) {
this.stickyTop += mergeRequestTabs.offsetHeight;
}
if (stubLocation) {
location = stubLocation;
@ -278,7 +286,7 @@ import Diff from './diff';
const $container = $('#diffs');
$container.html(data.html);
initChangesDropdown();
initChangesDropdown(this.stickyTop);
if (typeof gl.diffNotesCompileComponents !== 'undefined') {
gl.diffNotesCompileComponents();