GreedyNav
GreedyNav copied to clipboard
UX - clicking off the dropdown menu to close, instead of having to click button to close.
Would be great for UX. Attempting this feature, but having difficulty getting it working. Using stopPropagation and preventDefault
Good suggestion. I will look into it. Feel free to PR if you get something working 👍
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 :)
What do you think to this PR @Arwilliams95 https://github.com/lukejacksonn/GreedyNav/pull/12 ?
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.
Does addClass
allow for duplicates though? For example if you do element.addClass('hidden')
twice then will the element have class="hidden hidden"
.
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. :)