superfish
superfish copied to clipboard
Bit of a tweak: click outside to close
This is not an issue as such. It's just something I thought of as a convenience, for anyone who wants to provide a long mouseout delay for less physically capable users, while still allowing open menus to be cleared quickly when necessary.
I adapted the close routine from Superclick and inserted it in the same location in Superfish. It functions perfectly on the browsers I have available, and I assume it will generally work as well in SF as it does in SC. If anyone is interested, code is below.
Find:
var methods = (function () {
// private properties and methods go here
var c = {
bcClass: 'sf-breadcrumb',
menuClass: 'sf-js-enabled',
anchorClass: 'sf-with-ul',
menuArrowClass: 'sf-arrows'
},
Add after:
outerClick = (function() {
$(window).load(function() {
$('body').children().on('click.superfish', function() {
var $allMenus = $('.sf-js-enabled');
$allMenus.superfish('hide');
});
});
})(),
:+1:
This is also a great improvement for a mobile solution I used. With this code it's possible to close a menu by touching the root element of an open submenu again on mobile devices.
Hmm, as far as I remember the submenus should behave in this way in Superfish (although not quite as @larsbo described) without the above code due to focus being removed (the blur event) which should trigger the close handler. Have you found this not to be the case?