Skip to content
Snippets Groups Projects
Commit 4f993285 authored by Sascha Eggenberger's avatar Sascha Eggenberger
Browse files

sticky enabled tables: remove layout shift

parent 19166856
Branches
Tags
No related merge requests found
Pipeline #194863 passed
......@@ -1439,6 +1439,10 @@ table.position-sticky thead {
position: static;
}
table.position-sticky.--is-processed thead tr {
border-color: transparent;
}
table thead {
background: transparent;
border-radius: var(--gin-border-m);
......
......@@ -20,10 +20,12 @@
},
updateTableHeader: function(el) {
const tableHeader = document.querySelector(".gin--sticky-table-header");
tableHeader && (tableHeader.style.marginBottom = `-${el.querySelector("thead").getBoundingClientRect().height + 1}px`,
tableHeader.querySelectorAll("thead th").forEach(((th, index) => {
if (!tableHeader) return;
const offset = el.classList.contains("sticky-enabled") ? -7 : 1;
tableHeader.style.marginBottom = `-${el.querySelector("thead").getBoundingClientRect().height + offset}px`,
el.classList.add("--is-processed"), tableHeader.querySelectorAll("thead th").forEach(((th, index) => {
th.style.width = `${el.querySelectorAll("thead th")[index].getBoundingClientRect().width}px`;
})));
}));
}
};
})(Drupal, once);
\ No newline at end of file
......@@ -38,7 +38,9 @@
const tableHeader = document.querySelector('.gin--sticky-table-header');
if (!tableHeader) { return; }
tableHeader.style.marginBottom = `-${el.querySelector('thead').getBoundingClientRect().height + 1}px`;
const offset = el.classList.contains('sticky-enabled') ? -7 : 1;
tableHeader.style.marginBottom = `-${el.querySelector('thead').getBoundingClientRect().height + offset}px`;
el.classList.add('--is-processed');
tableHeader.querySelectorAll('thead th').forEach((th, index) => {
th.style.width = `${el.querySelectorAll('thead th')[index].getBoundingClientRect().width}px`;
......
......@@ -73,6 +73,10 @@ table.position-sticky {
thead {
position: static;
}
&.--is-processed thead tr {
border-color: transparent;
}
}
table {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment