This is a great plugin, very nice.
I recommend that you make the arguments something like this:
either:
.hoverIntent( overFn, outFn )
or:
.hoverIntent({
sensitivity: 4,
interval: 100,
over: overFn,
out: outFn
});
Which you could then implement like this:
function( on, off ) {
var options = jQuery.extend({ sensitivity: 4, interval: 100 },
off ? { on: on, off: off } : on );
...
}
--John
On 3/13/07, Brandon Aaron <[EMAIL PROTECTED]> wrote:
> Very nice. I believe this will be getting a fair amount of usage!
>
> > - ability to override default settings (sensitivity, polling interval, etc)
> This would be great and probably should be done by passing an options
> hash as the third argument. Usually options as passed as the first
> argument in plugins but it makes sense to be the third in this case.
>
> I would imagine it looking something like this:
>
> jQuery.fn.hoverIntent = function(f,g,o) {
> o = jQuery.extend({ sensitivity: 4, interval: 100 }, o || {});
> ...
> };
>
>
> > - make it more jQuery $-friendly (first few attempts have failed)
> As already mentioned by Klaus, you can force block scope by wraping
> your code in the following self calling function.
>
> (function($) {
> ...
> })(jQuery);
>
> --
> Brandon Aaron
>
> On 3/13/07, Brian Cherne <[EMAIL PROTECTED]> 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/
> >
> >
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/