From c7690c34c2d7bff11501188266b7be7a486c1bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Mon, 19 Aug 2024 17:47:25 +0000 Subject: [PATCH] 8338190: TOC vertical offsets not updated when document size changes Reviewed-by: jjg --- .../doclets/formats/html/resources/script.js.template | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/script.js.template b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/script.js.template index 71ef8476708..633f453bc43 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/script.js.template +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/script.js.template @@ -461,7 +461,7 @@ document.addEventListener("DOMContentLoaded", function(e) { }) } // Resize handler - function handleResize(e) { + new ResizeObserver((entries) => { if (expanded) { if (windowWidth !== window.innerWidth) { collapse(); @@ -475,7 +475,5 @@ document.addEventListener("DOMContentLoaded", function(e) { handleScroll(); } setTopMargin(); - } - window.addEventListener("orientationchange", handleResize); - window.addEventListener("resize", handleResize); + }).observe(document.body); });