mdbootstrap / bootstrap-hover-dropdown

An unofficial Bootstrap plugin to enable Bootstrap dropdowns to activate on hover and provide a nice user experience.
http://cameronspear.com/demos/bootstrap-hover-dropdown/
MIT License
1.26k stars 502 forks source link

Padding and margin prevents openDropdown event #161

Open webprogrammierer opened 7 years ago

webprogrammierer commented 7 years ago

On my navbar anchor elements I have some padding and margin like this:

  .navbar-nav > li > a {
    padding-top: 16px;
    padding-bottom: 0px;
    padding-left: 5px;
    padding-right: 5px;
    margin-left: 8px;
    margin-right: 8px;
  }

This seems to be the reason why the openDropdown event is not called anymore in any cases: So you move your mouse over the menu items (hover) and sometimes the menu items open and sometimes they do not open.

The following code should be removed or improved to get the hover menu work proper also with padding and margin:

                // so a neighbor can't open the dropdown
                if(!$parent.hasClass('open') && !$this.is(event.target)) {
                    // stop this event, stop executing any code
                    // in this callback but continue to propagate
                    return true;
                }
                // this helps prevent a double event from firing.
                // see https://github.com/CWSpear/bootstrap-hover-dropdown/issues/55
                if(!$parent.hasClass('open') && !$parent.is(event.target)) {
                    // stop this event, stop executing any code
                    // in this callback but continue to propagate
                    return true;
                }