Remove class before page-change?

Hi,

I have a sidebar menu that is revealed upon click of a button. I am using add/removeClass to toggle the menu which has a fixed position.

Atm, if I open the menu and click a link, you come to the new page instantly. Is it possible to use removeClass and add a delay to the page-change? I would like to slideout the meny and then fade in the new page for a more seamless navigation.

Anyone know how to do this?

I currently just use a simple

$('#toggle-menu').click(function(){
    $('.sidebar').toggleClass('show-sidebar');
});

And some css transitions.

Yes, you can do that by preventing the default behaviour of the link.

jQuery’s preventDefault documentation page gives a good example on how to do that.