Skip to content Skip to sidebar Skip to footer

Wrap Start Delay Around Jquery Animate Functions

$('.left').animate({left:'-50%'},4000); $('.center').animate({right:'-50%'},8000); $('.right').animate({right:'-50%'},4000); I would like to simply delay start all of my animation

Solution 1:

All you need is a call to delay()!

Try $(".left").delay(2000).animate({left: "-50%"}, 4000); to insert a delay of 2 seconds, for example.

Solution 2:

$(document).ready(function() {
  $('div').click(function() {
    setTimeout(function() {
      $(".left").animate({
        left: "0%"
      }, 4000);
      $(".center").animate({
        right: "0%"
      }, 8000);
      $(".right").animate({
        right: "0%"
      }, 4000);
    }, 1100);
  });
})
body {
	position: relative;
}
div {
  width: 100px;
  height: 100px;
  position: absolute;
  left: 50%;
  border: 1px solid #000;
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><body><divclass="left"></div><divclass="center"></div><divclass="right"></div></body>

Post a Comment for "Wrap Start Delay Around Jquery Animate Functions"