Reputation: 6419
function loadIgInnerPanelMenu(panelNum){
var delayTime = 300;
if($('#igto1 .btMenuShow').length === 0){
$('#igto1 .igInnerPanelBottomMenu').append(loadIgInnerBM(panelNum)).animate({'top':419},'fast',function(){}).addClass('btMenuShow').find('.btMenu').each(function(){
$(this).stop(false,true).animate({'top':0},delayTime);
delayTime+=100;
});
}
else{
// using inuse to prevent the botton quick switch
if(inuse === false){
$('#igto1 .igInnerPanelBottomMenu').append(loadIgInnerBM(panelNum)).find('.btMenu:gt(3)').each(function(){
$(this).stop(false,true).animate({'top':0},delayTime);
delayTime+=100;
});
}
}
alert(delayTime)
}
this function is called by a 'click' event .but the value of delayTime
doesn't set back to 300
after the function was called again.The delayTime
value was cumulated.
Thank you very much!!
Upvotes: 1
Views: 158
Reputation: 3129
try this:
function loadIgInnerPanelMenu(panelNum){
var delayTime;
if($('#igto1 .btMenuShow').length === 0){
$('#igto1 .igInnerPanelBottomMenu').append(loadIgInnerBM(panelNum)).clearQueue();
delayTime = 300;
$('#igto1 .igInnerPanelBottomMenu').append(loadIgInnerBM(panelNum)).animate({'top':419},'fast',function(){}).addClass('btMenuShow').find('.btMenu').each(function(){
$(this).stop(false,true).animate({'top':0},delayTime);
delayTime+=100;
});
}
else{
// using inuse to prevent the botton quick switch
if(inuse === false){
$('#igto1 .igInnerPanelBottomMenu').append(loadIgInnerBM(panelNum)).find('.btMenu:gt(3)').each(function(){
$(this).stop(false,true).clearQueue();
delayTime = 300;
$(this).stop(false,true).animate({'top':0},delayTime);
delayTime+=100;
});
}
}
alert(delayTime)
}
Upvotes: 0
Reputation: 15835
@gin ,
you are declaring the variable but one of the if conditions are always executing right
the following code gets executed for sure and whats why it is setting to a different value
remove the below line and print , it should always print 300
delayTime+=100;
`delyaTime=delyaTime+100;`// equivalent of above code...// you might be already knowing it
Upvotes: 1