This is a common problem since the turbo router caches a snapshot of the page with all its “drawers” open. In the backend, it is solved by detecting the cached preview and closing the drawers with CSS. Here you can see we hide the dropdowns and their overlays when the cache is shown:
Regarding your exact requirement, the only events you can use preventDefault with are page:click and page:before-visit. The page:click event works best, so you would need to stop the process, animate everything out and then use oc.visit(...); to revisit the location afterwards.
Ok, this has been added to the documentation and should be available in v3.0.67…
Pausing Rendering
If you would like to close some elements like dropdowns or off-canvas menus before loading a new page, you can pause the page:before-render event by preventing the default behavior and resuming it with the resume() function in the event detail.
I confirm this feature has been included in the latest v3 build of October CMS. The documentation has not been updated yet, though. If you try the example given here, it should work.
Hey @daft,
it works so far. However, the page:render-before event is fired twice on previously visited pages which leads to other problems. Can this be fixed?