开发者

jQuery Animations Causing Page to Crash in Chrome?

开发者 https://www.devze.com 2023-04-13 02:43 出处:网络
I\'m building a page with a lot of PNGs being animated by jQuery. Everything was fine up until yesterday, when I noticed that the page would crash in Chrome if I left it open for 开发者_如何转开发a fe

I'm building a page with a lot of PNGs being animated by jQuery. Everything was fine up until yesterday, when I noticed that the page would crash in Chrome if I left it open for 开发者_如何转开发a few minutes. This doesn't always happen, and I haven't had it happen yet in Firefox, Safari or IE9. I've never built anything on this scale before, so I'm not sure where to even start looking.

I'm using jQuery 1.6.1, jQuery scrollTo 1.4.2, and the jQuery UI slider 1.8.16.

You can see the page here, and my javascript here.


Turns out it was my use of setInterval() to loop animations that was causing the problem. I'm not sure about the details, but replacing all the instances of setInterval() with recursive functions using setTimeout() -- that also checked to make sure the animation wasn't already running -- solved the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号