I want to run an animation in another animation's step. Somehow the second animation behaves like it would queued.
var checkTop = function(){
if( $(window).scrollTop() > 0 && $("#navigation").not(":animated") ){
$("#navigation").animate({backgroundColor: "rgb(20,20,20,0.95)"}, {duration: 300, queue: false})
}
else{
$("#navigation").animate({backgroundColor: "transparent"}, {duration: 300, queue: false})
}
}
$(document).ready(function(){
var $window = $(window);
$(".btn").click(function(){
var btnname = $(this).attr('id');
var section = btnname.replace('btn-','');
$('html, body').stop().animate(
{ scrollTop: $('#' + section).offset().top - 30},
{
duration: 700,
queue: false,
step:function(now, fx){
checkTop();
}
}
);
});
});
Any help will be greatly appreciated.