diff --git a/website/scripts/explorer/chain.js b/website/scripts/explorer/chain.js index 5d23066eb..f9a5ec08e 100644 --- a/website/scripts/explorer/chain.js +++ b/website/scripts/explorer/chain.js @@ -72,15 +72,15 @@ export function lastCube() { return /** @type {HTMLDivElement | null} */ (blocksEl.lastElementChild); } -/** @param {HTMLDivElement} cube @param {{ scroll?: boolean }} [opts] */ -export function selectCube(cube, { scroll = false } = {}) { +/** @param {HTMLDivElement} cube @param {{ scroll?: "smooth" | "instant" }} [opts] */ +export function selectCube(cube, { scroll } = {}) { const changed = cube !== selectedCube; if (changed) { if (selectedCube) selectedCube.classList.remove("selected"); selectedCube = cube; cube.classList.add("selected"); } - if (scroll) cube.scrollIntoView({ behavior: "smooth" }); + if (scroll) cube.scrollIntoView({ behavior: scroll }); const hash = cube.dataset.hash; if (hash) { const block = blocksByHash.get(hash); diff --git a/website/scripts/explorer/index.js b/website/scripts/explorer/index.js index d7f990765..cdeb04fd6 100644 --- a/website/scripts/explorer/index.js +++ b/website/scripts/explorer/index.js @@ -156,17 +156,17 @@ function route() { if (pendingTx) { const hash = pendingTx.status?.blockHash; const cube = hash ? findCube(hash) : null; - if (cube) selectCube(cube); + if (cube) selectCube(cube, { scroll: "instant" }); showTxFromData(pendingTx, secondaryPanel); showSecondaryPanel(); pendingTx = null; } else if (kind === "address" && value) { const cube = lastCube(); - if (cube) selectCube(cube); + if (cube) selectCube(cube, { scroll: "instant" }); navigateToAddr(value); } else { const cube = lastCube(); - if (cube) selectCube(cube); + if (cube) selectCube(cube, { scroll: "instant" }); } } @@ -175,7 +175,7 @@ async function navigateToBlock(hash, pushUrl = true) { if (pushUrl) history.pushState(null, "", `/block/${hash}`); const cube = findCube(hash); if (cube) { - selectCube(cube, { scroll: true }); + selectCube(cube, { scroll: "smooth" }); } else { const signal = navigate(); try { @@ -217,7 +217,7 @@ function showTxAndSelectBlock(tx) { if (tx.status?.blockHash) { const cube = findCube(tx.status.blockHash); if (cube) { - selectCube(cube, { scroll: true }); + selectCube(cube, { scroll: "smooth" }); showTxFromData(tx, secondaryPanel); showSecondaryPanel(); return;