GreedyNav icon indicating copy to clipboard operation
GreedyNav copied to clipboard

UX - clicking off the dropdown menu to close, instead of having to click button to close.

Open Sworth opened this issue 8 years ago • 6 comments

Would be great for UX. Attempting this feature, but having difficulty getting it working. Using stopPropagation and preventDefault

Sworth avatar Apr 14 '16 21:04 Sworth

Good suggestion. I will look into it. Feel free to PR if you get something working 👍

lukejacksonn avatar May 01 '16 23:05 lukejacksonn

new to github and realize this project was created 2 years ago.... however simply adding

var $html = $('html'); $html.on('click', function(event) { var clickedOutside = $(event.target).closest('nav').length == 0; if (clickedOutside && !$hlinks.hasClass('hidden')) { $hlinks.addClass('hidden'); } });

right below the code that activates your timer will cause the nav to close on click to anything outside the nav :)

Arwilliams95 avatar Nov 13 '18 19:11 Arwilliams95

What do you think to this PR @Arwilliams95 https://github.com/lukejacksonn/GreedyNav/pull/12 ?

lukejacksonn avatar Nov 14 '18 04:11 lukejacksonn

I think it could use the .hasClass bit so that it wont add that class every time someone clicks out of the nav on their site.

Arwilliams95 avatar Nov 14 '18 05:11 Arwilliams95

Does addClass allow for duplicates though? For example if you do element.addClass('hidden') twice then will the element have class="hidden hidden".

lukejacksonn avatar Nov 14 '18 05:11 lukejacksonn

No duplicates because of JQuery. It should Auto check before adding. However there is slightly better performance speed if you use the .hasClass. It wont make a noticeable difference but I always add it. :)

Arwilliams95 avatar Nov 14 '18 06:11 Arwilliams95