fix: Top20 dropdown floats above chart with fixed positioning

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-08 16:08:05 +08:00
parent 93b84da72e
commit 4c55932906
3 changed files with 51 additions and 8 deletions
+32
View File
@@ -92,6 +92,8 @@
const elVolRankMeta = document.getElementById("market-vol-rank-meta");
const elVolRankList = document.getElementById("market-vol-rank-list");
const elVolRankDetails = document.getElementById("market-vol-rank");
const elVolRankPanel =
elVolRankDetails && elVolRankDetails.querySelector(".market-vol-rank-panel");
const elTf = document.getElementById("market-timeframe");
const elRefresh = document.getElementById("market-refresh");
const elStatus = document.getElementById("market-status");
@@ -2616,6 +2618,32 @@
void postChartUnwatch();
}
function positionVolRankPanel() {
if (!elVolRankDetails || !elVolRankPanel || !elVolRankDetails.open) return;
const summary = elVolRankDetails.querySelector("summary");
if (!summary) return;
const rect = summary.getBoundingClientRect();
const panelW = elVolRankPanel.offsetWidth || 300;
let left = rect.right - panelW;
left = Math.max(8, Math.min(left, window.innerWidth - panelW - 8));
const top = rect.bottom + 4;
const maxH = Math.min(420, window.innerHeight - top - 12);
elVolRankPanel.style.left = left + "px";
elVolRankPanel.style.top = top + "px";
elVolRankPanel.style.maxHeight = Math.max(180, maxH) + "px";
}
function bindVolRankPanel() {
if (!elVolRankDetails) return;
elVolRankDetails.addEventListener("toggle", function () {
if (elVolRankDetails.open) {
requestAnimationFrame(positionVolRankPanel);
}
});
window.addEventListener("resize", positionVolRankPanel);
window.addEventListener("scroll", positionVolRankPanel, true);
}
function renderVolumeRank(data) {
if (!elVolRankMeta || !elVolRankList) return;
elVolRankList.innerHTML = "";
@@ -2674,6 +2702,9 @@
li.appendChild(btn);
elVolRankList.appendChild(li);
});
if (elVolRankDetails && elVolRankDetails.open) {
requestAnimationFrame(positionVolRankPanel);
}
}
async function loadVolumeRank(forceRefresh) {
@@ -2830,6 +2861,7 @@
function bind() {
bindSlDrag();
bindVolRankPanel();
if (elRefresh) {
elRefresh.addEventListener("click", function () {
loadChart(true);