Start a new discussion

To start a new discussion please visit the discussions section of the GitHub home page of the project.

Discussions on GitHub

You can also search our old self-hosted forums for any useful information below but please note that posting new content here is not possible any more.

Re: Is a possible to make second level menus appear only when hovering over the triangle pointing right

Home Forums Older releases 0.9.x Is a possible to make second level menus appear only when hovering over the triangle pointing right Re: Is a possible to make second level menus appear only when hovering over the triangle pointing right

#1615
admin
Keymaster

Glad you like the script!

It’s not too difficult to achieve – e.g.:

var $mainMenu = $('#main-menu');
$mainMenu.bind('activate.smapi', function(e, item) {
		var obj = $mainMenu.data('smartmenus'),
			$item = $(item),
			$sub = $item.parent().dataSM('sub'),
			level = $sub ? $sub.dataSM('level') : -1;
		if (!obj.isTouchMode() && level > 2 && !$item.dataSM('arrow-activated')) {
			return false;
		}
		// unflag
		$item.removeDataSM('arrow-activated');
	})
	.delegate('span.sub-arrow', 'mouseenter', function(e) {
		var obj = $mainMenu.data('smartmenus'),
			$item = $(this).parent(),
			$sub = $item.parent().dataSM('sub'),
			level = $sub ? $sub.dataSM('level') : -1;
		if (!obj.isTouchMode() && level > 2) {
			// flag it so that we don't cancel the event on activate.smapi
			$item.dataSM('arrow-activated', true);
			$mainMenu.smartmenus('itemActivate', $item);
		}
	});

However, I am not sure it would be intuitive to use. I guess most users will simply click on the items if the sub menu doesn’t appear immediately on hover and will not think about hovering the sub indicator arrow instead.