Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bit of a tweak: click outside to close #118

Open
StealthWombat opened this issue Jun 20, 2014 · 2 comments
Open

Bit of a tweak: click outside to close #118

StealthWombat opened this issue Jun 20, 2014 · 2 comments
Labels

Comments

@StealthWombat
Copy link

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');
                    });
                });
            })(),
@larsbo
Copy link

larsbo commented Sep 15, 2014

👍

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.

@joeldbirch
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants