I need to slightly rebuild this project. I would like to below 991px width, the menu would grow when clicked. The funny thing is that the desktop menu behaves the way I want it for mobile.
When elements have a class .nomobiledropdownhover, they behave as expected
The most important is this fragment, for mobile:
$("#navbarSupportedContent li").hover(
function(){
if (!$(this).hasClass('nomobiledropdownhover')) {
return;
}else{
$(this).children('ul').hide();
$(this).children('ul').slideDown('fast');
$(this).addClass('open ');
}
if(opmenu == 0){
menu_height($(this),'in');
opmenu = 1;
}
},
function () {
if (!$(this).hasClass('nomobiledropdownhover')) {
return;
}else{
$('ul', this).slideUp('fast');
$(this).removeClass('open ');
}
menu_height($(this),'out');
opmenu = 0;
});
}
and this for desktop:
$('.dropdown-toggle').on('click', function(e) {
if ($(this).closest('.dropdown').hasClass('nomobiledropdownhover')) {
$(this).closest('.dropdown').removeClass('open ');
return 0;
}else{
$('.dropdown').find('.dropdown-menu').attr('style', '');
var menuopen = $(this).closest('.dropdown');
// menuopen.find('.dropdown-menu').attr('style', '');
menuopen.find('.dropdown-menu').css('display', 'block');
menuopen.find('.dropdown-menu').css('top', '0');
setTimeout(function(){
$("html, body").stop().animate({scrollTop:menuopen.offset().top}, 300, 'swing', function() {
});
},120);
}
});
I glue it all because it is quite confusing https://github.com/Mikelinsky/hover-on-mibile/blob/master/assets/js/script.js
Below the width of 991px the menu opens after clicking and closes after clicking somewhere else