jquery - .animate callback in other .animate load 2 times -


i want this:

  1. scroll 440 top
  2. open #detail animation
  3. load id.html inside #detail
  4. made css animation on html content

i want step step:

step 2/ executed after step 1/

step 3/ executed after step 2/

step 4/ executed after step 3/

but have 1 problem : .load function executed twice. don't understand why.

$('html,body').animate({scrolltop:(440)}, 1300,'easeinsine', function() {     $('#detail').animate({height: detail_height}, 800, function() {         $('#detail').load('pages/web/' + id + '.html', function() {             //do     });     }); }); 

when animate n elements, callback happen n times. that's intended behavior.

if wish single callback animating multiple elements, use promise object.

$('html,body').animate({scrolltop:(440)}, 1300,'easeinsine').promise().done(function() {     $('#detail').animate({height: detail_height}, 800, function() {         $('#detail').load('pages/web/' + id + '.html', function() {             //do         });     }); }); 

the alternative select html or body, not both.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -