From d1c09791abc7518c13dd2c66e26ebbf3dfd13472 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 7 Jul 2025 09:47:28 -0700 Subject: [PATCH] Fix animation bug in safari When showing the sidebar, Safari was causing the sidebar to snap into place without animating. This is apparently some well-known issue where it doesn't like adding new elements (or changing display) and toggling an animated transition in the same event loop. --- src/front-end/js/book.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/front-end/js/book.js b/src/front-end/js/book.js index e188f9be..46bbacf3 100644 --- a/src/front-end/js/book.js +++ b/src/front-end/js/book.js @@ -540,6 +540,10 @@ aria-label="Show hidden lines">'; /* To allow the sidebar expansion animation, we first need to put back the display. */ if (!sidebarCheckbox.checked) { sidebar.style.display = ''; + // Workaround for Safari skipping the animation when changing + // `display` and a transform in the same event loop. This forces a + // reflow after updating the display. + sidebar.offsetHeight; } });