且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Javascript中加载树时如何使GIF旋转

更新时间:2023-12-05 17:07:40

浏览器对图像刷新的优先级较低,因此在您的代码在 DOM 中操作/插入时,浏览器忙于处理而不会有时间重新绘制图像.

Browsers give a low priority to image refreshing, so in the time your code is manipulating/inserting in the DOM, the browser is busy with that and doesn't have time to repaint the image.

除了优化代码以减少对 ajax 数据进行的处理之外,您无能为力,或者例如,如果您获得 1000 个项目的列表,请将它们插入页面间隔为 50,每个页面之间有很小的延迟,因此浏览器有时间重新绘制.

There's not a whole lot you can do, besides optimizing your code so that the processing you're doing with the ajax data is less intensive, or for example if you're getting a list of 1000 items, insert them in the page in intervals of 50, with a small delay between each, so the browser has time to repaint.

天啊,也许它在 Chrome 中看起来很棒,但在 IE 中冻结了 5 秒.

YMMV, maybe it looks great as is in Chrome, but freezes for 5 seconds in IE.