THEK
THEK

Reputation: 782

jQuery Rotate lags after a few uses

I've created a compass like feature on my site but it points to menu items. I'm using the jQuery rotate plugin.

However, when I first load the site the compass works flawlessly, but after a few turns it starts skipping rather than a smooth animation.

I clear the queue for the element once each transition is done as that seemed to smooth it a bit but it still skips. Anyone know what could cause this? It works fine again once I refresh the page.

Edit: Sorry, of course code would be helpful. http://sitetest.kdmdesign.net

Upvotes: 0

Views: 146

Answers (1)

Barney
Barney

Reputation: 16456

This happens a lot with any jQuery animation in which the animation triggers can fire a large number of times in short succession — using stop() is a good safety net but it's often still not enough.

I would 'throttle' the event to stop it firing unmanageably often. Ben Alman wrote an excellent explanation of throttling as a preface to his equally excellent jQuery plugin for throttling and debouncing.

Oh — and...

A reason your code in particular would be slow is that the event handlers are re-attached (and never detached) every time the user hovers over the inner page wrapper. I tweaked that here:

http://jsbin.com/welcome/59800/edit

Upvotes: 1

Related Questions