jquery - .animate callback in other .animate load 2 times -
i want this:
- scroll 440 top
- open
#detail
animation - load
id.html
inside#detail
- 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
Post a Comment