I made a menu on a joomla website with a basic menu module. I animate it with a slide up effect and that's okay for now, except one thing on the resize of the window : The effect is repeated numerous time if i resize the window while I use the menu. I try to stop the propagation of the click event but I can't. Even with e.stopPropagation()
There you can try my menu : https://jsfiddle.net/fgctp81v/
And th JS code is below :
winWidth = $( window ).width();
if( winWidth < 1007 ){
$('li.deeper > span.deploylist').click(function(e){
e.preventDefault();
menuClicked = $(this).next('a');
if( menuClicked.parents('li.active-menu').length ){
if( menuClicked.hasClass("clicked") ){
menuClicked.removeClass('clicked').next('ul').slideUp(200);
}
else{
menuClicked.addClass('clicked').siblings('ul').slideDown(400);
}
}
else{
menuClicked.addClass('clicked').parents('li.parent').addClass("active-menu");
menuClicked.siblings('ul').slideDown(400);
}
winWidth = $( window ).width();
});
}
Any idea ? Thank you
You have to remove any existing
click
events withoff
.updated fiddle