Willem Ellis
Willem Ellis

Reputation: 5016

How do I get an event to keep triggering while hover?

Okay so here's my small snippet of code:

base.$el.delegate('.mb-panel', 'hover', base.hover = function(){
    base.change( base.$panels.index($(this)) + base.adj );          
});

Basically I want base.change( base.$panels.index($(this)) + base.adj ); to keep executing as long as the user hovers over .mb-panel. So right now that event is firing once on mouseenter() and once on mouseleave() because I'm using hover().

I've tried adding base.hover(); to make it a sort of recursive function, but this just isn't working. I'm assuming because of some infinite loop occurring. Can anyone help me with this?

Upvotes: 0

Views: 185

Answers (2)

ShankarSangoli
ShankarSangoli

Reputation: 69905

I think mousemove event will help you to some extent. Alternatively you can use setInterval on hover and execute the required code at a specified interval and then on mouseout clear the interval.

Upvotes: 2

Chris
Chris

Reputation: 3162

Can you not use the mouseover event? Im not sure i understand your code exactly but below is my attempt at interpretation.

 $(el).mouseover(function() {

        base.change( base.$panels.index($(this)) + base.adj );
 });

Upvotes: 0

Related Questions