chameleon icon indicating copy to clipboard operation
chameleon copied to clipboard

Auto-open menus

Open vonloxley opened this issue 7 years ago • 2 comments

This js will open the menus on mouse-over (way better ux) and still work with touch-screens:

/* Open menus on mouse over, don't do anything on touch-devices. */
$(function() {
    window.IsTouchDevice = false;
    window.addEventListener('touchstart', function onFirstTouch() {
        window.IsTouchDevice = true;
        window.removeEventListener('touchstart', onFirstTouch, false);
    }, false);

    $(".dropdown").hover(
            function(){ if (!window.IsTouchDevice) $(this).addClass('open'); },
            function(){ if (!window.IsTouchDevice) $(this).removeClass('open'); }
    );
});

vonloxley avatar Aug 18 '17 17:08 vonloxley

Thanks. Will look into it.

s7eph4n avatar Aug 19 '17 10:08 s7eph4n

for the fixedheader layout the dropdown function should have a little delay

$(function() {
    window.IsTouchDevice = false;
    window.addEventListener('touchstart', function onFirstTouch() {
        window.IsTouchDevice = true;
        window.removeEventListener('touchstart', onFirstTouch, false);
    }, false);

    $('ul.navbar-nav li.dropdown').hover(function() {
      if (!window.IsTouchDevice)
        $(this).find('.dropdown-menu').stop(true, true).delay(50).fadeIn(200);
    }, function() {
      if (!window.IsTouchDevice)
        $(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut(200);
    });
});

cbsrobot avatar Jan 18 '18 23:01 cbsrobot