Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript allow one animation at a time with jQuery?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30987
    soap
    Participant

    How do you allow one animation to be going at a time with jQuery? Otherwise you can just go crazy with your mouse and things will be animating forever. Here’s my code.

    $(document).ready(function() {
    //slides animations
    $(".slide").width(161);
    $(".s1").width(380);
    $(".slide").hover(function() {
    $(this).animate({
    width: "380px"
    }, 200);
    },
    function () {
    $(this).animate({
    width: "161px"
    }, 200);
    });
    });
    #69948
    Rob MacKay
    Participant

    what you have to do is chain the animations:

    $(".slide").hover(function(){
    $(this).animate( { width:"380px"}, 200 )
    .animate( { width:"161px" }, 200 );
    });

    Have a look here and at the examples towards the bottom of the page :)

    http://api.jquery.com/animate/

    #69950
    jamygolden
    Member

    Check out this article.

    #63345
    soap
    Participant

    Thanks!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.