Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

310
Visualizações
animate's callback function (complete) executed at start?

I'm using jQuery 1.5.1 This is my code:

$('.cellcontent').animate({
   left: '-=190'}, {
   easing: alert('start ani'),
   duration: 5000,
   complete: alert('end ani')});

I get both alerts before the animation starts!? I want the complete function to start after the animation has ended. Any thoughts?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You need to pass a function to call. Instead you are calling the function.

complete:  function() { alert('end ani'); } 
over 4 years ago · Santiago Trujillo Relatório

0

I see two things wrong with this.

One, easing should be:

A string indicating which easing function to use for the transition

And complete should be a function.

http://api.jquery.com/animate

alert('start ani');
$('.cellcontent').animate({
     left: '-=190'
   },
   {
     easing: 'swing',
     duration: 5000,
     complete: function(){
        alert('end ani');
    }
});
over 4 years ago · Santiago Trujillo Relatório

0

You need to pass a function to complete.

Try this:

$('.cellcontent').animate({
    left: '-=190'}, {
    easing: alert('start ani'),
    duration: 5000,
    complete: function() { alert('end ani') }
});

Since complete expects a function, it executes the code you pass to it to get a function object that it can call back to when finished.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda