So, I am familiar with the fact that you cannot use a callback function on jQuery's .css function. Instead, I used the setTimeout function:
$('#header-nav').css({'left': leftBstr});
posBstr = '.level' + posB.toString();
setTimeout(function(e){
$('#header-nav ul' + posBstr).removeClass('menu-active');
}, 300);
This code is meant for a mobile menu animation. There are two typed of buttons:
- go further into the menu (child categories)
- go back (parent category)
But, when using the setTimeout function, when I click too fast, the menu disappears, because of the removed class menu-active.
I already tried putting the setTimeout function inside a var, and use the clearTimeout function, but that did not work.
My question: is there another way to recreate the callback function on the .css function, without using setTimeout?
.animate, therefore animate it using JS rather than css classes?