autodoc: scroll up when collapsing long fn description

This commit is contained in:
Loris Cro 2023-01-11 18:14:56 +01:00
parent a88679453a
commit 0e66df2094
2 changed files with 11 additions and 4 deletions

View File

@ -290,7 +290,7 @@
color: var(--link-color);
position: sticky;
float: left;
top: 0px;
top: 0.5em;
right: -16px;
z-index: 1;
margin-left: -2em;

View File

@ -2476,7 +2476,7 @@ var zigAnalysis;
short = markdown(short);
var long = markdown(docs);
tdDesc.innerHTML =
"<details><summary><div class=\"sum-less\">" + short + "</div>" + "<div class=\"sum-more\">" + long + "</div></summary></details>";
"<details ontoggle=\"scrollOnCollapse(event);\"><summary><div class=\"sum-less\">" + short + "</div>" + "<div class=\"sum-more\">" + long + "</div></summary></details>";
}
else {
tdDesc.innerHTML = markdown(short);
@ -3718,5 +3718,12 @@ var zigAnalysis;
})();
function scrollOnCollapse(event) {
const details = event.target;
if (!details.open && details.getBoundingClientRect().top < 0) {
console.log("scrolling!")
details.parentElement.parentElement.scrollIntoView(true);
} else {
console.log("not scrolling!", details.open, details.top);
}
}