An excellent idea that works very elegantly. Well done Brian.
Might I suggest one more simple config setting... To optionally skip the
following check in your handleHover function: "if (p == this){return
false;}"
Why? Because I'm using hoverIntent in a hierarchical menu built with
*nested* <ul><li>... elements. Without the check for "p==this" I only need
to apply hoverIntent to the top level menu (instead of all the submenus too,
and I'm working on a page with many submenus - don't ask!).
So an extra config option could be something like ignoreSubElements:true by
default then you just need to change the line in handleHover() to "if
(cfg.ignoreSubElements && p == this){return false;}"
Kind regards,
George
Brian Cherne wrote:
>
> WHAT?
> hoverIntent is a function that attempts to determine the user's intent...
> like a crystal ball, only with mouse movement! It works like (and was
> derived from) jQuery's built-in hover. However, instead of immediately
> calling the onMouseOver function, it waits until the user's mouse slows
> down
> enough before calling the function.
>
> WHERE?
> My sorely out-dated web site.
> <http://cherne.net/brian/resources/jquery.hoverIntent.html>
>
> WHY?
> To delay or prevent the accidental firing of animations or ajax calls.
> Simple timers work for small areas, but if your target area is large it
> may
> execute regardless of intent. Also, because jQuery animations cannot be
> stopped once they've started it's best not to start them prematurely. ...
> and I wanted something that was easy to swap in/out with hover (so
> hoverIntent returns the same "this" and event objects as hover).
>
> WHAT'S NEXT?
> Your feedback! Tear it shreds! Tell me what you think. I would like to
> keep
> the script as small as possible, but if I could make this more useful (and
> more likely to be used) I'm happy to make some enhancements... like...
> - more compelling/verbose demo/documentation
> - ability to override default settings (sensitivity, polling interval,
> etc)
> - option of a simple onMouseOut timer
> - make it more jQuery $-friendly (first few attempts have failed)
> - suggestions for code style/commenting/optimization
>
>
> Thanks in advance,
> Brian.
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context:
http://www.nabble.com/hoverIntent-%3D-my-first-plug-in-tf3394660.html#a9610472
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/