From cd84e348a5b49ef2a07032a852881654ae00d7f5 Mon Sep 17 00:00:00 2001 From: VictoriqueMoe Date: Thu, 19 Oct 2023 23:20:32 +0100 Subject: [PATCH] use a ResizeObserver to resize the element --- src/public/assets/custom/js/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/public/assets/custom/js/index.js b/src/public/assets/custom/js/index.js index cb4de15..70b31ee 100644 --- a/src/public/assets/custom/js/index.js +++ b/src/public/assets/custom/js/index.js @@ -175,13 +175,13 @@ Site.loadPage(async function (site) { }); ((() => { const cardBody = document.getElementById("resultsCardBody"); + const resizeListener = new ResizeObserver(entries => { + const formCardBodyObserver = entries[0]; + const formCardBodyOffsetHeight = formCardBodyObserver.target.offsetHeight; + cardBody.style.maxHeight = `${formCardBodyOffsetHeight}px`; + }); const formCardBody = document.getElementById("formCardBody"); - ['load', 'resize'].forEach(evt => - window.addEventListener(evt, () => { - const cardFormBodyHeight = formCardBody.offsetHeight; - cardBody.style.maxHeight = `${cardFormBodyHeight}px`; - }, true) - ); + resizeListener.observe(formCardBody); })()); const distributableRadios = document.querySelectorAll("#authorYes,#authorNo"); if (distributableRadios) {