javascript - Changing interval of setInterval and all animations are run together -


i dealing following jquery contains multiple image animations.my query is, through setinterval, animation not run step step , doesn't maintain interval sometimes. 1st animation , 2nd animation runs together. how can resolve , run 3 animation step step in specific interval? can use settimeout? if yes how? please excuse me if wrote incorrect interval time in following jquery beginner in jquery.

$(document).ready(function() { var runanimate1 = true; var runanimate2 = false; var runanimate3 = false;  setinterval(function() {     if (runanimate1) {         $("#animate1").fadein('slow').animate({             'display': 'inline-block',             'margin-left': '220px',             'margin-bottom': '20px'         }, 500, function() {             $('.1st').animate({                 'opacity': '0'             }, 1000, function() {                 $('.1st').animate({                     'opacity': '1'                 })             })         }).fadeout();         $("#animate1").fadein('slow').animate({             'margin-bottom': '0px',             'margin-left': '-140px'         }, 1000, function() {             runanimate1 = false;             runanimate2 = true;             runanimate3 = false;         }).fadeout('slow');     }      if (runanimate2) {         $(".2nd").fadein('slow').animate({             'margin-left': '150px',             'margin-bottom': '2px'         }, 600, function() {             $('.1st').animate({                 'opacity': '0'             }, 1000, function() {                 $('.1st').animate({                     'opacity': '1'                 }, 1000)             })         }).fadeout();         $(".2nd").fadein('slow').animate({             'margin-bottom': '0px',             'margin-left': '-150px'         }, 1000, function() {             runanimate1 = false;             runanimate2 = false;             runanimate3 = true         }).fadeout('slow');     }      if (runanimate3) {         $('.3rd').fadein('slow').animate({             'display': 'inline-block',             'margin-left': '220px',             'margin-bottom': '2px'         }, 1000, function() {             $('.1st').animate({                 'opacity': '0'             }, 1000, function() {                 $('.1st').animate({                     'opacity': '1'                 })             })         }).fadeout('slow');         $('.3rd').fadein('slow').animate({             'margin-bottom': '0px',             'margin-left': '-220px'         }, 1000, function() {             runanimate1 = true;             runanimate2 = false;             runanimate3 = false;         }).fadeout('slow');     } }, 6000); }); 

my html follow:

<div id="outer-box" class="1st"> <img class="1st" src="img/sofa2.jpg"> <div id="animate1" style="display: none; position: absolute; bottom: 0; left: 0;">     <img class="1st" src="img/chotu.png" style="height:300px; width:200px;" /> </div> <div class="2nd 1st" style="display:none; position:absolute; bottom:0;   left:0">     <img src="img/hand.png" style="width:200px; height:300px;"> </div> <div class="3rd 1st" style="display:none; position:absolute; bottom:0; left:0">     <img src="img/handyh.png" style="width:180px; height: 150px;"> </div> </div> 

if store setinterval in variable able change it.

to change time 1 possible solution is:

var interval = setinterval(functionname,3000); function changetime(newtime) {     clearinterval(interval);     interval = setinterval(functionname,newtime);  } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -