panicbus
10/20/2016 - 6:34 PM

Script to create a little delay when mousing on/off an hover-only element to prevent the annoying accidental hover state

Script to create a little delay when mousing on/off an hover-only element to prevent the annoying accidental hover state

var setTimeoutDelay;
$('.myDropdown').mouseover(function(){
	setTimeoutDelay = setTimeout(function(){
		$('.myDropdown-expanded').show();
		$('.myDropdown-header').addClass('myDropdown-hover');
	}, 300);
}).mouseout(function(){
	clearTimeout(setTimeoutDelay);
	setTimeout(function(){
		var isHover = $('.myDropdown-expanded').is(':hover');
		if (isHover !== true) {
			$('.myDropdown-expanded').hide();
			$('.myDropdown-header').removeClass('myDropdown-hover');
		}
	}, 300);
});