briancherne / jquery-hoverIntent

hoverIntent jQuery Plug-in

Home Page:https://briancherne.github.io/jquery-hoverIntent/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do i clear a hoverintents timeout

inquiztr opened this issue · comments

I am using hoverIntent to make a flyout menu. I wanted to give the user the option to close the flyout by clicking a "close" button as well as the normal way of hovering out.

I cant figure out how to cancel the hoverIntent_t timer as I am not sure how to access the property. I understand it would be contained within the function. I searched on stackoverflow and someone mentioned the hoverIntent timer id is saved as an attribute of the html object but every time I try to grab that property/attribute, it is undefined.

In the example below, if you click on the close button, you can see that the timeout is still running. I would like to learn a way to access that timeout id so I can clear it.
any help is appreciated.

http://codepen.io/anon/pen/ZYoJOp

commented

The timer ID is exposed on the dom element itself in the property hoverIntent_t. You may use this to clear the timer on your own, but this property isn't documented and isn't guaranteed to remain exposed in this manner in further releases. Nevertheless, you may access the property in the following manner:

$("#test")[0].hoverIntent_t;

Thanks Roydukkey,
I can see the property in chrome dev tools but I cant seem to actually grab the value. Could you take a look and see what I am doing wrong. When i click on the button it still returns undefined :

http://codepen.io/anon/pen/ZYoNRj

commented

@inquiztr the property saved on the element is used internally and cleared as soon as the plugin no longer needs it. You won't be able to access it reliably the way you're using it, and this way is not recommended as it you may leave the plugin in an unstable state. (Not to mention that the property in mention will not exist in the next version of the plugin.)

I think the way to do what you want to do requires a little more logic in the callbacks you're using--you might want to take a look at #6 for inspiration. I'm closing this issue for now, but feel free to continue to comment, or open another issue if you run into new problems.