Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Pause / Resume animate

This ain't working for me...

$(document).ready(function(){
    $('#h .a').animate({
        top:'-=80px'
    },90,'linear');

    $('#h .au,#h .di').animate({
        left:'-=80px'
    },50000000,'linear');

    $('#h .r').animate({
        left:'-=80px'
    },250,'linear');

    $("#h").animate('pause'); //pausing it at the start
    //resume pause switch
    $("#h").mouseover(function(){
      $(this).animate('resume');
    }).mouseout(function(){
      $(this).animate('pause');
    });

});
like image 553
Suraj Avatar asked Apr 07 '11 18:04

Suraj


2 Answers

Check out the demo here: http://api.jquery.com/clearQueue/

Looks like exactly the sort of thing you're trying to do.

like image 163
Adam Terlson Avatar answered Sep 17 '22 15:09

Adam Terlson


try this one for pause and resume: jQuery Pause / Resume animation plugin

also we $(this).stop() can pause animate but no chance to resume!

other mistake is this one: top:'-=80px'

first try to get current position like this then add position to it:

_top = $(this).offset().top;

$('#h .a').animate({
    top:_top-80
},90,'linear')
like image 43
ShirazITCo Avatar answered Sep 17 '22 15:09

ShirazITCo