Tables now automatically resize themselves to fit page height
This commit is contained in:
parent
d1af7de6fe
commit
e384c9ed6d
|
@ -1,4 +1,4 @@
|
||||||
#tracker-wrapper{
|
#tracker-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
@ -8,8 +8,7 @@
|
||||||
.table-wrapper{
|
.table-wrapper{
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 1rem;
|
||||||
max-height: 425px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#tracker-header-bar{
|
#tracker-header-bar{
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
const adjustTableHeight = () => {
|
||||||
|
const tablesContainer = document.getElementById('tables-container');
|
||||||
|
const upperDistance = tablesContainer.getBoundingClientRect().top;
|
||||||
|
|
||||||
|
const containerHeight = window.innerHeight - upperDistance;
|
||||||
|
tablesContainer.style.maxHeight = `calc(${containerHeight}px - 1rem)`;
|
||||||
|
|
||||||
|
const tableWrappers = document.getElementsByClassName('table-wrapper');
|
||||||
|
for(let i=0; i < tableWrappers.length; i++){
|
||||||
|
const maxHeight = (window.innerHeight - upperDistance) / 2;
|
||||||
|
tableWrappers[i].style.maxHeight = `calc(${maxHeight}px - 1rem)`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
const tables = $(".table").DataTable({
|
const tables = $(".table").DataTable({
|
||||||
paging: false,
|
paging: false,
|
||||||
|
@ -38,10 +52,15 @@ window.addEventListener('load', () => {
|
||||||
|
|
||||||
setInterval(update, 30000);
|
setInterval(update, 30000);
|
||||||
|
|
||||||
window.addEventListener('resize', () => tables.draw());
|
window.addEventListener('resize', () => {
|
||||||
|
adjustTableHeight();
|
||||||
|
tables.draw()
|
||||||
|
});
|
||||||
|
|
||||||
$(".table-wrapper").scrollsync({
|
$(".table-wrapper").scrollsync({
|
||||||
y_sync: true,
|
y_sync: true,
|
||||||
x_sync: true
|
x_sync: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
adjustTableHeight();
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
{%- endfor -%}">Multistream</a></span>
|
{%- endfor -%}">Multistream</a></span>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
</div>
|
</div>
|
||||||
|
<div id="tables-container">
|
||||||
{% for team, players in inventory.items() %}
|
{% for team, players in inventory.items() %}
|
||||||
<div class="table-wrapper">
|
<div class="table-wrapper">
|
||||||
<table class="table unique-item-table">
|
<table class="table unique-item-table">
|
||||||
|
@ -143,4 +144,5 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue