How to change jQuery hoverIntent plugin instance settings on-the-fly?

377 Views Asked by At

I am using jQuery hoverIntent plugin like this:

$('#box').hoverIntent({ over:function_a, out:function_b, interval:0 });

However I want to change setting on-the-fly of this instance within function_a to set interval to 500. Can this be achieved and how ?

Thank you very much for any help.

1

There are 1 best solutions below

0
On BEST ANSWER

The hoverIntent plugin add two custom attributes to every DOM element it's assigned to

For example: <div id="box"> became <div id="box" hoverIntent_t="" hoverIntent_s="">

Now:

  • hoverIntent_t is the polling interval timer, or the mouseOut timer.
  • hoverIntent_s stores the state to prevent unmatched function calls.

So you can directly change the internal state of #box like this:

$("#box").attr("hoverIntent_t", "500");