我有一些简单地放大和缩小横幅图像的Jquery。当我运行这个时,浏览器中出现堆栈限制错误。它仍然运行,但是有没有办法让它只能“及时”加载到堆栈中?在查看堆栈时,它会在初始加载中一遍又一遍地加载zoomIn()
和zoomOut()
,直到达到极限,因此页面加载非常缓慢。Jquery Animate无限循环:如何避免堆栈限制
$(document).ready(function(){
$bannerImg = $('.post-picture img')
function zoomIn(){
$bannerImg.animate({
width: 1500,
}, 50000,'linear');
$bannerImg.promise().done(zoomOut());
}
function zoomOut(){
$bannerImg.animate({
width: 1500,
}, 50000,'linear');
$bannerImg.promise().done(zoomIn());
}
zoomIn();
});
更新:感谢您的答案。使用完成(ZoomOut/ZoomIn)工作。
非常感谢伊恩 – Brandonmchu 2013-05-09 19:30:17