Pause an animation and continue later ?

62 views
Skip to first unread message

SN4KE

unread,
Sep 29, 2008, 2:30:21 AM9/29/08
to Prototype & script.aculo.us
Hi,

i wondered i it is possible to pause and continue an animation.

Like, if I have an div-layer which moves around my Page – I set an
onmouseover="javascript: $(foo).pause();" and a
onmouseout="javascript: $(foo).continue();" inside. Are there some
functions which just do the job?

Is that possible? A simple "pause" and "continue" function?

Greetings

lfortin

unread,
Sep 29, 2008, 4:28:26 PM9/29/08
to Prototype & script.aculo.us
Hi Sn4ke,


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.


Here is the documentation for Core Effects:
http://github.com/madrobby/scriptaculous/wikis/core-effects


-Laurent

lfortin

unread,
Sep 29, 2008, 4:44:00 PM9/29/08
to Prototype & script.aculo.us
Hi Sn4ke,

The core effects of Script.aculo.us(like Effect.Move) support a method
called cancel().

For example, you can do:

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

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


Here is the documentation of all core effects that support cancel()
method:
http://github.com/madrobby/scriptaculous/wikis/core-effects


Also, if you use JavaScript in a handler such as oumouseover, you
don't need to put "javascript:".
The right way: onmouseover=" ** your code here ** "


-Laurent



On Sep 29, 2:30 am, SN4KE <solidsnak...@web.de> wrote:

lfortin

unread,
Sep 29, 2008, 4:46:00 PM9/29/08
to Prototype & script.aculo.us
Oops ...

Sorry, I replied twice ... :-)

There was a problem with the reply post, so I wrote the message again.

-Laurent


On Sep 29, 2:30 am, SN4KE <solidsnak...@web.de> wrote:
Reply all
Reply to author
Forward
0 new messages