javascript - Is it possible to define settimeout intervals in array? -


here's situation:

var firefliptimer = ''; var unfliptimer = []; $('.categorybox').on('mouseenter', '.box', function() {     cleartimeout(firefliptimer);     var $t = $(this);     var = $t.index();     cleartimeout(unfliptimer[i]);     bht = settimeout(function() { flipcat($t); }, 250); }).on('mouseleave', '.box', function() {     cleartimeout(firefliptimer);     var $t = $(this);     var = $t.index();     unfliptimer[i] = settimeout(function() { unflipcat($t); }, 600); }); 

basically there div, on:

  • mouseenter - animates
  • mouseleave - after 600ms comes previous state before animation.

i'm trying thing, if leave mouse , enters div in 600ms interval, div not come previous state :)

as there multiple div's i'm trying handle settimeout intervals array, not successfully...

is possible define intervals in array? or should use different method task.

p.s. problem in case last element reacts mouseleave event, if go div div, previous divs not comming normal state.

it's becausethe bht variable holding 1 timer (i.e. not array of timers). , timer of first element (as stored in bht variable) overwritten next timer if hover on multiple elements.

what need make bht variable array, , use bht2 variable.

so like

var firefliptimer = []; var unfliptimer = []; $('.categorybox').on('mouseenter', '.box', function() {     var $t = $(this);     var = $t.index();     cleartimeout(firefliptimer[i]);     cleartimeout(unfliptimer[i]);     firefliptimer[i] = settimeout(function() { flipcat($t); }, 250); }).on('mouseleave', '.box', function() {     var $t = $(this);     var = $t.index();     cleartimeout(firefliptimer[i]);     unfliptimer[i] = settimeout(function() { unflipcat($t); }, 600); }); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -