Skip to content

Commit d1c0979

Browse files
committed
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.
1 parent 16b99be commit d1c0979

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/front-end/js/book.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ aria-label="Show hidden lines"></button>';
540540
/* To allow the sidebar expansion animation, we first need to put back the display. */
541541
if (!sidebarCheckbox.checked) {
542542
sidebar.style.display = '';
543+
// Workaround for Safari skipping the animation when changing
544+
// `display` and a transform in the same event loop. This forces a
545+
// reflow after updating the display.
546+
sidebar.offsetHeight;
543547
}
544548
});
545549

0 commit comments

Comments
 (0)