joeldbirch / superfish

Superfish is a jQuery plugin that adds usability enhancements to existing multi-level drop-down menus.
Other
912 stars 315 forks source link

delay should be applied to hoverIntent not superfish #120

Open mjau-mjau opened 10 years ago

mjau-mjau commented 10 years ago

Just thought I'd remark that delay should be applied to the hoverIntent plugin (if enabled) instead of to superfish. Why? Because on "mouse-piloting errors", once the mouse is again over the menu element (within delay), it re-triggers hoverIntent which will not trigger "open" again until intent is determined ... this will often cause an animated menu to flash close/open while the mouse is back over the item.

To avoid this, one should be using the hoverIntent timeout setting instead, which prevents over/out handlers from firing when they shouldn't. timeout as quoted from hoverIntent docs:

A simple delay, in milliseconds, before the "out" function is called. If the user mouses back over the element before the timeout has expired the "out" function will not be called (nor will the "over" function be called). This is primarily to protect against sloppy/human mousing trajectories that temporarily (and unintentionally) take the user off of the target element... giving them time to return. Default timeout: 0

Personally, I added the hoverIntent timeout manually, and just kept superfish delay to 0:

// $menu.hoverIntent(over, out, targets);
// fixed timeout delay to work in hoverintent instead of superfish:
$menu.hoverIntent({
  over: over,
  out: out,
  selector: targets,
  timeout: 300
});
joeldbirch commented 10 years ago

Thanks for noticing this and explaining exactly what is going on. I wanted Superfish to have a built-in delay for those who don't use hoverIntent for whatever reason, but given that nowadays it is required for various touch devices to be supported maybe I should just make hoverIntent a firm requirement. Thanks for providing a workaround in the meantime.

girish-khadse commented 8 years ago

Facing this issue. Could you please give more details about this solution? Where should we add above mentioned code?

joeldbirch commented 8 years ago

I have created a branch named 'hoverintent' which has this patch in but I am not seeing any noticeable difference in behaviour. In which browsers are you seeing the "flash close/open" behaviour, and does this new branch behave any differently in it? Thanks.