Commit a97b0d49 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'vs/replace-outer-height-with-native-impl' into 'master'

Replace jQuery's outerHeight with vanilla implementation in common_utils

See merge request gitlab-org/gitlab!67882
parents 605f2b7d 97f65071
......@@ -151,11 +151,24 @@ export const isMetaKey = (e) => e.metaKey || e.ctrlKey || e.altKey || e.shiftKey
// 3) Middle-click or Mouse Wheel Click (e.which is 2)
export const isMetaClick = (e) => e.metaKey || e.ctrlKey || e.which === 2;
/**
* Get the current computed outer height for given selector.
*/
export const getOuterHeight = (selector) => {
const element = document.querySelector(selector);
if (!element) {
return undefined;
}
return element.offsetHeight;
};
export const contentTop = () => {
const isDesktop = breakpointInstance.isDesktop();
const heightCalculators = [
() => $('#js-peek').outerHeight(),
() => $('.navbar-gitlab').outerHeight(),
() => getOuterHeight('#js-peek'),
() => getOuterHeight('.navbar-gitlab'),
({ desktop }) => {
const container = document.querySelector('.line-resolve-all-container');
let size = 0;
......@@ -166,14 +179,14 @@ export const contentTop = () => {
return size;
},
() => $('.merge-request-tabs').outerHeight(),
() => $('.js-diff-files-changed').outerHeight(),
() => getOuterHeight('.merge-request-tabs'),
() => getOuterHeight('.js-diff-files-changed'),
({ desktop }) => {
const diffsTabIsActive = window.mrTabs?.currentAction === 'diffs';
let size;
if (desktop && diffsTabIsActive) {
size = $('.diff-file .file-title-flex-parent:visible').outerHeight();
size = getOuterHeight('.diff-file .file-title-flex-parent:not([style="display:none"])');
}
return size;
......@@ -182,7 +195,7 @@ export const contentTop = () => {
let size;
if (desktop) {
size = $('.mr-version-controls').outerHeight();
size = getOuterHeight('.mr-version-controls');
}
return size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment