Search code examples
jqueryslide

Preload jQuery slideDown animation before displaying content


I have a navigation menu that use jQuery slideUp and slideDown to show or hide sub-menus.

My page saves the state of the menu and which submenus they had expanded when the user navigates different pages. My problem is that when the page loads it loads the whole slideDown animation too, the menu starts fully collapased and the relevant sub-menu(s) expand

I do not want this as it is distracting. If loading a saved menu state I want the menu item to appear with the slideDowntransition already complete. Is there a way of preloading this?


Solution

  • In the scenario where you are restoring state, just set the animation duration to zero.