Add an additional animate to the first function:
function ShowHide() {
if('block' == $('#slidingDiv').css('display')){
$('div.box3').animate({top: '-=300'}, 1000, function() {
$("#slidingDiv").animate({ "height": "toggle" }, { duration: 1000 });
});
}else{
$('div.box3').animate({top: '+=300'}, 1000, function() {
$("#slidingDiv").animate({ "height": "toggle" }, { duration: 1000 });
});
}
}
You can also add the animate/toggle function after the if/else and not as a callback, to save some code lines, you have to see how it works out animation wise.
If you want to use a listener and prevent overlapping actions make it like that, instead of function ShowHide ,
$(document).ready(function() {
handler = function() {
$(this).unbind('click', handler)
if ('block' == $('#slidingDiv').css('display')) {
$("#slidingDiv").animate({ "height": "toggle" }, 1000, function (){
$('div.box3').animate({ top: '-=300' }, 1000 , function() {
$("div.box1 a").click(handler);
});
});
} else {
$('div.box3').animate({ top: '+=300' }, 1000, function () {
$("#slidingDiv").animate({ "height": "toggle" }, 1000, function() {
$("div.box1 a").click(handler);
});
});
}
}
$("div.box1 a").click(handler);
});