Remove js size animation and only use the opacity one

This commit is contained in:
Antoine Bartuccio 2025-06-10 15:06:59 +02:00
parent 4774a7b741
commit 36d4a02a45
Signed by: klmp200
GPG Key ID: E7245548C53F904B
2 changed files with 0 additions and 34 deletions

View File

@ -1,33 +0,0 @@
const updateMaxHeight = (element: HTMLDetailsElement) => {
const content = element.querySelector(".accordion-content") as HTMLElement | null;
if (!content) {
return;
}
if (element.hasAttribute("open")) {
content.style.maxHeight = `${content.scrollHeight}px`;
} else {
content.style.maxHeight = "0px";
}
};
// Initialize max-height at load
window.addEventListener("DOMContentLoaded", () => {
for (const el of document.querySelectorAll("details.accordion")) {
updateMaxHeight(el as HTMLDetailsElement);
}
});
// Accordion opened
new MutationObserver((mutations: MutationRecord[]) => {
for (const mutation of mutations) {
const target = mutation.target as HTMLDetailsElement;
if (target.tagName !== "DETAILS" || !target.classList.contains("accordion")) {
continue;
}
updateMaxHeight(target);
}
}).observe(document.body, {
attributes: true,
attributeFilter: ["open"],
subtree: true,
});

View File

@ -27,7 +27,6 @@
<script type="module" src="{{ static('bundled/htmx-index.js') }}"></script>
<script type="module" src="{{ static('bundled/country-flags-index.ts') }}"></script>
<script type="module" src="{{ static('bundled/core/tooltips-index.ts') }}"></script>
<script type="module" src="{{ static('bundled/core/accordion-index.ts') }}"></script>
<!-- Jquery declared here to be accessible in every django widgets -->
<script src="{{ static('bundled/vendored/jquery.min.js') }}"></script>