I have a style sheet switcher here on my site http://goo.gl/zA3Pm - the on/off link in the top right corner. Currently im turning off the jquery made animation by using !important in the css alt style sheet and and simply locking its position. I thought that was pretty good way to do it. Still do. But even though the animation is frozen the JS is still working so its a little hard on the CPU for those that want to turn it off. Is there anyway that you can think of to turn it off and on by turning the jquery animation off and on? That way the CPU usage would be restored for those that need it. Like me on my old XP. I'm thinking no but thought I'd ask.

Pullo
—
2013-02-07T21:48:11Z —
#2

Hi Eric,

Maybe you could use [.stop()](http://api.jquery.com/stop/), which stops the currently-running animation on the matched elements.To stop everything you could then do:

$("body").find('*').stop(true, true);

PicnicTutorials
—
2013-02-08T03:56:36Z —
#3

Yah the code you gave me last time (probably the same here) worked to turn it off. But then how do I turn it back on again? Thanks Pullo

chris_upjohn
—
2013-02-08T07:16:58Z —
#4

Below is a plugin I have used before which is extremely handy when you need to pause/play animations, it respects the current time in the animation so when it resumes the queue id is still the same there for it won't start again or stop completely.

However, as Chris points out with his answer, this will reset the animation to the beginning.It would probably look nicer to have some kind of pause/resume functionality, in which case you want to look at [.queue()](http://api.jquery.com/jQuery.queue/), or better still, the plugin he suggests.

PicnicTutorials
—
2013-02-08T11:01:21Z —
#6

Hey thanks guys! I just realized a important factor. Do either of those methods have cookie? So the user doesnt have to turn off the animation each time they change pages or return to the site? Thats what I do love about the style sheet switcher.

I think the starting and stopping of the animation is fairly cookie agnostic.That is to say, that you can set/unset your cookie when the user clicks on the 'animation on/off' button.You need only check for the cookie on page load.

PicnicTutorials
—
2013-02-09T03:25:07Z —
#8

Pullo said:

Hi Eric,

I think the starting and stopping of the animation is fairly cookie agnostic.That is to say, that you can set/unset your cookie when the user clicks on the 'animation on/off' button.You need only check for the cookie on page load.

Since that plugin above doesn't work in chrome ill go with what you posted Pullo. Any way you could show me how to add a cookie thingy-ma-dooger to it?

chris_upjohn
—
2013-02-09T04:25:29Z —
#9

The plugin I posted works fine in any browser, it may however break in newer versions of jQuery

PicnicTutorials
—
2013-02-09T04:32:30Z —
#10

Doesn't work in my chrome

chris_upjohn
—
2013-02-09T04:42:58Z —
#11

Which version of Chrome are you using?

Pullo
—
2013-02-09T12:24:11Z —
#12

EricWatson said:

Could show me how to add a cookie thingy-ma-dooger to it?

Just to be clear, do you mean that you want your site to remember if the user has turned the animation on or off, so that the next time they visit the site, things are how they left them?

PicnicTutorials
—
2013-02-09T17:38:11Z —
#13

Pullo said:

Just to be clear, do you mean that you want your site to remember if the user has turned the animation on or off, so that the next time they visit the site, things are how they left them?

Exactly

PicnicTutorials
—
2013-02-09T17:39:15Z —
#14

chris_upjohn said:

Which version of Chrome are you using?

The latest - v23 something

Pullo
—
2013-02-09T20:56:29Z —
#15

Hey man,Here's a demo of the stop/start thing with cookies.To see what I've done, just have a look at the source.Any questions, just let me know.

BTW, regarding the plugin: could it be a problem with testing locally (Chrome can be a bit picky sometimes)? Did you try running it on a server?

PicnicTutorials
—
2013-02-09T22:14:40Z —
#16

Awesome - your the man Pullo! Just a couple issues. When you turn it off the images move off screen. That can be fixed prob by moving the position into the css. And in FX (at least) after I turn it off it turns back on after about 1 minute all by it self.

Pullo
—
2013-02-09T22:19:06Z —
#17

EricWatson said:

When you turn it off the images move off screen. That can be fixed prob by moving the position into the css.

Yeah, they just shoot back to their starting positions.

EricWatson said:

And in FX (at least) after I turn it off it turns back on after about 1 minute all by it self.

Not sure about this.You will need to make the cookie valid across your whole domain if you want to use it on more than one page.Try this: