更好的 Jquery Clone-Remove item 动画,内存使用量更少
我正在尝试创建 DOM 对象的旋转列表。我尝试运行该应用程序,对于 IE 8,任务管理器上的内存正在增加,但又恢复到动画之前的相同数量。我尝试使用 Chrome 16.0.912.75 进行测试,我注意到内存每 10 秒就会持续增加。我是否正确使用 API?当我执行remove()时,它会删除实际的dom对象吗?
var rotateAnimationTime = 10000;
setTimeout(animateList, rotateAnimationTime);
function animateList() {
// At least two items
if ($('#divParent div.divRow').size() > 1) {
var parentDiv = $('#divParent');
// Clone the original item to be placed on bottom of list.
var clonedDiv = $($('#divParent div.divRow').eq(0).clone());
$('#divParent div.divRow').eq(0).fadeOut(itemFadeTime,
function(){
$(this).remove();
clonedDiv.appendTo(parentDiv).hide().fadeIn('slow');
setTimeout(animateList, rotateAnimationTime);
}
);
}
}
I am trying to create a rotating list of DOM object. I tried to run the application and for IE 8, the memory on the task manager is increasing but is returning to the same amount before animation. I tried to test using my Chrome 16.0.912.75 and I noticed that the memory just keeps on increasing every 10 seconds. Am I using the API correctly? When I do a remove() does it delete the actual dom object?
var rotateAnimationTime = 10000;
setTimeout(animateList, rotateAnimationTime);
function animateList() {
// At least two items
if ($('#divParent div.divRow').size() > 1) {
var parentDiv = $('#divParent');
// Clone the original item to be placed on bottom of list.
var clonedDiv = $($('#divParent div.divRow').eq(0).clone());
$('#divParent div.divRow').eq(0).fadeOut(itemFadeTime,
function(){
$(this).remove();
clonedDiv.appendTo(parentDiv).hide().fadeIn('slow');
setTimeout(animateList, rotateAnimationTime);
}
);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论