commit 66569c7ec664fbab691b74616c02fed838b91a7d (tree)
parent 4971df857213f32b39e79f39b6e391cf76d06c3a
Author: Clement Espeute <clementespeute@shirogames.com>
Date: Thu, 12 Jan 2023 13:35:23 +0100
autodoc: use js instead of details for collapsing descriptions
Diffstat:
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git 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
@@ -2476,7 +2476,7 @@ var zigAnalysis;
short = markdown(short);
var long = markdown(docs);
tdDesc.innerHTML =
- "<details ontoggle=\"scrollOnCollapse(event);\"><summary><div class=\"sum-less\">" + short + "</div>" + "<div class=\"sum-more\">" + long + "</div></summary></details>";
+ "<div class=\"expand\" ><span class=\"button\" onclick=\"toggleExpand(event)\"></span><div class=\"sum-less\">" + short + "</div>" + "<div class=\"sum-more\">" + long + "</div></details>";
}
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