Created
December 10, 2018 13:04
-
-
Save cagartner/cd01d7e4802312dd604c2fbd5db3ce3f to your computer and use it in GitHub Desktop.
Mudar ação do dropdown de click para hover na versão 4.1+ Change action of dropdown of click to hover in version 4.1+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function toggleDropdown (e) { | |
| let _d = $(e.target).closest('.dropdown'), | |
| _m = $('.dropdown-menu', _d); | |
| setTimeout(function(){ | |
| let shouldOpen = e.type !== 'click' && _d.is(':hover'); | |
| _m.toggleClass('show', shouldOpen); | |
| _d.toggleClass('show', shouldOpen); | |
| $('[data-toggle="dropdown"]', _d).attr('aria-expanded', shouldOpen); | |
| }, e.type === 'mouseleave' ? 300 : 0); | |
| } | |
| $('body') | |
| .on('mouseenter mouseleave', '.dropdown', toggleDropdown) | |
| .on('click', '.dropdown-menu a', toggleDropdown); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment