I agree with the comment of Machiee.
You can do it this way :
$(function () {
$(window).scroll(function (e) {
if($('#box').hasClass('minimized'))
return;
var height = $(window).height() /2;
if ($(this).scrollTop() >= height) {
$("#box").animate({'bottom':'0px'},300);
}
else {
$("#box").stop(true).animate({'bottom':'-150px'},100);
}
}); });
$('.minimize').toggle(function() {
$('#box').animate({'bottom':'-80px'},200);
$('#box').addClass('minimized');
},
function() { $('#box').animate({'bottom':'0px'},200);
$('#box').removeClass('minimized');
});
check the demo fiddle