问题是,当第二次鼠标单击时,您正在重置变量“left”和“right”。这和你要找的更接近吗?
function getMouseXYUp(e) {
$("body").die('mousemove');
var h = (document.height - e.pageY + 17);
var left = id-1;
var right = id+1;
setTimeout(function() { moveleft(left, h); }, 100);
setTimeout(function() { moveright(right, h); }, 100);
return true;
}
...
function moveleft(left, h) {
if (left >= 0){
$("#div"+left).animate({'height': h}, 400);
left--;
setTimeout(function() { moveleft(left, h); }, 50);
}
}
function moveright(right, h) {
if (right < divs){
$("#div"+right).animate({'height': h}, 400);
right++;
setTimeout(function () { moveright(right, h); }, 50);
}
}