Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit ·
aa18243
1
Parent(s): fe0ba8c
fixed gradient bug in asc mode
Browse files- frontend/leaderboard.html +33 -9
frontend/leaderboard.html
CHANGED
|
@@ -19,8 +19,8 @@
|
|
| 19 |
<style>
|
| 20 |
#table-outer {
|
| 21 |
position: relative;
|
| 22 |
-
--
|
| 23 |
-
--
|
| 24 |
}
|
| 25 |
|
| 26 |
#table-outer::after {
|
|
@@ -29,10 +29,10 @@
|
|
| 29 |
inset: 0;
|
| 30 |
background: linear-gradient(
|
| 31 |
to bottom,
|
| 32 |
-
rgba(16, 185, 129, var(--
|
| 33 |
transparent 30%,
|
| 34 |
transparent 70%,
|
| 35 |
-
rgba(239, 68, 68, var(--
|
| 36 |
);
|
| 37 |
pointer-events: none;
|
| 38 |
z-index: 1;
|
|
@@ -40,6 +40,16 @@
|
|
| 40 |
transition: background 0.15s ease;
|
| 41 |
}
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
#table-wrapper {
|
| 44 |
max-height: 700px;
|
| 45 |
overflow-y: auto;
|
|
@@ -1601,6 +1611,13 @@
|
|
| 1601 |
currentSort = (currentSort.colId !== colId) ? { colId, dir: 'asc' } : { colId: (currentSort.dir === 'asc' ? colId : null), dir: (currentSort.dir === 'asc' ? 'desc' : 'none') };
|
| 1602 |
prepareColumns(lbData);
|
| 1603 |
applyFilters();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1604 |
};
|
| 1605 |
|
| 1606 |
window.toggleFilterPanel = function () {
|
|
@@ -1697,15 +1714,22 @@
|
|
| 1697 |
highlight.style.height = `${outer.offsetHeight}px`;
|
| 1698 |
}
|
| 1699 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1700 |
function initGradientScroll() {
|
| 1701 |
const wrapper = $('#table-wrapper');
|
| 1702 |
-
|
| 1703 |
-
|
|
|
|
|
|
|
| 1704 |
wrapper.addEventListener('scroll', () => {
|
| 1705 |
const max = wrapper.scrollHeight - wrapper.clientHeight;
|
| 1706 |
-
|
| 1707 |
-
outer.style.setProperty('--green-opacity', (0.07 * (1 - ratio)).toFixed(3));
|
| 1708 |
-
outer.style.setProperty('--red-opacity', (0.07 * ratio).toFixed(3));
|
| 1709 |
updateAvgColHighlight();
|
| 1710 |
}, { passive: true });
|
| 1711 |
}
|
|
|
|
| 19 |
<style>
|
| 20 |
#table-outer {
|
| 21 |
position: relative;
|
| 22 |
+
--gradient-opacity: 0.07;
|
| 23 |
+
--gradient-scroll: 0;
|
| 24 |
}
|
| 25 |
|
| 26 |
#table-outer::after {
|
|
|
|
| 29 |
inset: 0;
|
| 30 |
background: linear-gradient(
|
| 31 |
to bottom,
|
| 32 |
+
rgba(16, 185, 129, calc(var(--gradient-opacity) * (1 - var(--gradient-scroll)))) 0%,
|
| 33 |
transparent 30%,
|
| 34 |
transparent 70%,
|
| 35 |
+
rgba(239, 68, 68, calc(var(--gradient-opacity) * var(--gradient-scroll))) 100%
|
| 36 |
);
|
| 37 |
pointer-events: none;
|
| 38 |
z-index: 1;
|
|
|
|
| 40 |
transition: background 0.15s ease;
|
| 41 |
}
|
| 42 |
|
| 43 |
+
#table-outer[data-sort-dir="desc"]::after {
|
| 44 |
+
background: linear-gradient(
|
| 45 |
+
to bottom,
|
| 46 |
+
rgba(239, 68, 68, calc(var(--gradient-opacity) * (1 - var(--gradient-scroll)))) 0%,
|
| 47 |
+
transparent 30%,
|
| 48 |
+
transparent 70%,
|
| 49 |
+
rgba(16, 185, 129, calc(var(--gradient-opacity) * var(--gradient-scroll))) 100%
|
| 50 |
+
);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
#table-wrapper {
|
| 54 |
max-height: 700px;
|
| 55 |
overflow-y: auto;
|
|
|
|
| 1611 |
currentSort = (currentSort.colId !== colId) ? { colId, dir: 'asc' } : { colId: (currentSort.dir === 'asc' ? colId : null), dir: (currentSort.dir === 'asc' ? 'desc' : 'none') };
|
| 1612 |
prepareColumns(lbData);
|
| 1613 |
applyFilters();
|
| 1614 |
+
// Refresh gradient to reflect new sort direction
|
| 1615 |
+
setTimeout(() => {
|
| 1616 |
+
const wrapper = $('#table-wrapper');
|
| 1617 |
+
if (!wrapper) return;
|
| 1618 |
+
const max = wrapper.scrollHeight - wrapper.clientHeight;
|
| 1619 |
+
applyGradient(max > 0 ? wrapper.scrollTop / max : 0);
|
| 1620 |
+
}, 50);
|
| 1621 |
};
|
| 1622 |
|
| 1623 |
window.toggleFilterPanel = function () {
|
|
|
|
| 1714 |
highlight.style.height = `${outer.offsetHeight}px`;
|
| 1715 |
}
|
| 1716 |
|
| 1717 |
+
function applyGradient(ratio) {
|
| 1718 |
+
const outer = $('#table-outer');
|
| 1719 |
+
if (!outer) return;
|
| 1720 |
+
outer.style.setProperty('--gradient-scroll', ratio.toFixed(3));
|
| 1721 |
+
outer.dataset.sortDir = currentSort ? currentSort.dir : 'none';
|
| 1722 |
+
}
|
| 1723 |
+
|
| 1724 |
function initGradientScroll() {
|
| 1725 |
const wrapper = $('#table-wrapper');
|
| 1726 |
+
if (!wrapper) return;
|
| 1727 |
+
// Set correct initial gradient for current sort direction
|
| 1728 |
+
const initMax = wrapper.scrollHeight - wrapper.clientHeight;
|
| 1729 |
+
applyGradient(initMax > 0 ? wrapper.scrollTop / initMax : 0);
|
| 1730 |
wrapper.addEventListener('scroll', () => {
|
| 1731 |
const max = wrapper.scrollHeight - wrapper.clientHeight;
|
| 1732 |
+
applyGradient(max > 0 ? wrapper.scrollTop / max : 0);
|
|
|
|
|
|
|
| 1733 |
updateAvgColHighlight();
|
| 1734 |
}, { passive: true });
|
| 1735 |
}
|