Skip to content

Commit

Permalink
Adds auto-adding of sticky table headers
Browse files Browse the repository at this point in the history
  • Loading branch information
bulhakovolexii committed Feb 7, 2024
1 parent 1a5599c commit f01be30
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
24 changes: 16 additions & 8 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@
{% include components/mermaid.html %}
{% endif %}
<script>
document.addEventListener('DOMContentLoaded', () => {
const tableElements = document.querySelectorAll('.js-table');

tableElements.forEach(tableElement => {
new window.StickyTable(tableElement);
})
});
</script>
const tables = document.querySelectorAll("table");
const addStickyHeaders = (tables) => {
tables.forEach((table) => {
if (table.offsetHeight >= 900) {
table.classList.add("js-table")
}
})
};
addStickyHeaders(tables);
document.addEventListener('DOMContentLoaded', () => {
const tableElements = document.querySelectorAll('.js-table');
tableElements.forEach(tableElement => {
new window.StickyTable(tableElement);
})
});
</script>
</body>
</html>
22 changes: 15 additions & 7 deletions docs/_layouts/minimal.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@
{% include components/mermaid.html %}
{% endif %}
<script>
document.addEventListener('DOMContentLoaded', () => {
const tableElements = document.querySelectorAll('.js-table');

tableElements.forEach(tableElement => {
new window.StickyTable(tableElement);
})
});
const tables = document.querySelectorAll("table");
const addStickyHeaders = (tables) => {
tables.forEach((table) => {
if (table.offsetHeight >= 900) {
table.classList.add("js-table")
}
})
};
addStickyHeaders(tables);
document.addEventListener('DOMContentLoaded', () => {
const tableElements = document.querySelectorAll('.js-table');
tableElements.forEach(tableElement => {
new window.StickyTable(tableElement);
})
});
</script>
</body>
</html>

0 comments on commit f01be30

Please sign in to comment.