Commit 97f65071 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Replace jQuery's outerHeight with vanilla implementation

parent 0bdfe446
...@@ -151,11 +151,24 @@ export const isMetaKey = (e) => e.metaKey || e.ctrlKey || e.altKey || e.shiftKey ...@@ -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) // 3) Middle-click or Mouse Wheel Click (e.which is 2)
export const isMetaClick = (e) => e.metaKey || e.ctrlKey || e.which === 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 = () => { export const contentTop = () => {
const isDesktop = breakpointInstance.isDesktop(); const isDesktop = breakpointInstance.isDesktop();
const heightCalculators = [ const heightCalculators = [
() => $('#js-peek').outerHeight(), () => getOuterHeight('#js-peek'),
() => $('.navbar-gitlab').outerHeight(), () => getOuterHeight('.navbar-gitlab'),
({ desktop }) => { ({ desktop }) => {
const container = document.querySelector('.line-resolve-all-container'); const container = document.querySelector('.line-resolve-all-container');
let size = 0; let size = 0;
...@@ -166,14 +179,14 @@ export const contentTop = () => { ...@@ -166,14 +179,14 @@ export const contentTop = () => {
return size; return size;
}, },
() => $('.merge-request-tabs').outerHeight(), () => getOuterHeight('.merge-request-tabs'),
() => $('.js-diff-files-changed').outerHeight(), () => getOuterHeight('.js-diff-files-changed'),
({ desktop }) => { ({ desktop }) => {
const diffsTabIsActive = window.mrTabs?.currentAction === 'diffs'; const diffsTabIsActive = window.mrTabs?.currentAction === 'diffs';
let size; let size;
if (desktop && diffsTabIsActive) { 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; return size;
...@@ -182,7 +195,7 @@ export const contentTop = () => { ...@@ -182,7 +195,7 @@ export const contentTop = () => {
let size; let size;
if (desktop) { if (desktop) {
size = $('.mr-version-controls').outerHeight(); size = getOuterHeight('.mr-version-controls');
} }
return size; 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