views:

35

answers:

1

Is it possible to pause all script.aculo.us effects? So when I need I can just resume them from state where they were paused.

+1  A: 

It wouldn't appear so, but I've found a post that has an interesting take on it, I don't know if the parameters of the effect would remain at the state where they were cancelled or if they are in the original state but it might be worth tinkering around with.

From: http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/f37ea88cba01c8a5

It seems that, for core effects with Script.aculo.us(including Effect.Move), the method cancel() works.

Core effects include: Effect.Highlight, Effect.Morph, Effect.Move, Effect.Opacity, Effect.Scale, Effect.Parallel, Effect.Tween

So you can do something like:

var myEffect = new Effect.Move(object, { duration: 5.0, x: 20, y: -30, mode: 'relative' });
myEffect.cancel();

You can keep the effect reference object(in this example, myEffect) to stop it whenever you want, and start over again later with a new move effect.

Quintin Robinson
I also found that post, but `cancel` really cancels the effect, removing it from queue and this means that I also need to cancel all following effects in queue. And there is no resume. I surely can cancel all effects and try to recreate them, but this is not pause/resume.
tig
@tig The other alternative is to modify the scriptaculous source you should be able to add your own pause method that won't dequeue all the effects. Basically add line in the `Effect.Base.prototype.loop` that references a `isPaused` variable before executing. This way you could always pause and unpause effects. Then your pause method could just flip that bool.
Quintin Robinson