Add id=top to body and add auto scroll when details block is closed

This commit is contained in:
2025-07-24 12:25:15 -04:00
parent 55f6cae954
commit faa54c8238
2 changed files with 6 additions and 2 deletions

6
app.js
View File

@@ -1,10 +1,14 @@
// Set expanded value block to a variable
const valueBlock = document.getElementById("value-expanded");
const bodyTop = document.getElementById("top");
// Watch for the details element to be toggled
document.querySelector('.value-block').addEventListener('toggle', function() {
if (this.open) {
// Scroll to contents of value block when it is opened
valueBlock.scrollIntoView({ behavior: "smooth" });
}
} else {
// Scroll to top of button list when value block is closed
bodyTop.scrollIntoView({ behavior: "smooth" });
}
});