From 66569c7ec664fbab691b74616c02fed838b91a7d Mon Sep 17 00:00:00 2001 From: Clement Espeute Date: Thu, 12 Jan 2023 13:35:23 +0100 Subject: [PATCH] autodoc: use js instead of details for collapsing descriptions --- lib/docs/index.html | 14 ++++++-------- lib/docs/main.js | 15 +++++++-------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/docs/index.html b/lib/docs/index.html index 972b0d65d1..76233c6376 100644 --- a/lib/docs/index.html +++ b/lib/docs/index.html @@ -266,25 +266,23 @@ font-weight: bold; } - details[open] summary .sum-less { + .expand[open] .sum-less { display: none; } - details[open] summary .sum-more { + .expand[open] .sum-more { display: block; } - details summary .sum-more { + .expand .sum-more { display: none; } - details summary { - list-style-type: none; + .expand { position: relative; - pointer-events: none; } - details summary::before { + .expand .button:before { content: "[+] "; font-family: var(--mono); color: var(--link-color); @@ -298,7 +296,7 @@ cursor: pointer; } - details[open] summary::before { + .expand[open] .button:before { content: "[-] "; } diff --git a/lib/docs/main.js b/lib/docs/main.js index d10cdde95f..f35a20f57f 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -2476,7 +2476,7 @@ var zigAnalysis; short = markdown(short); var long = markdown(docs); tdDesc.innerHTML = - "
" + short + "
" + "
" + long + "
"; + "
" + short + "
" + "
" + long + "
"; } else { tdDesc.innerHTML = markdown(short); @@ -3718,12 +3718,11 @@ 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); +function toggleExpand(event) { + const parent = event.target.parentElement; + parent.toggleAttribute("open"); + + if (!parent.open && parent.getBoundingClientRect().top < 0) { + parent.parentElement.parentElement.scrollIntoView(true); } } \ No newline at end of file