Stopping Fx.Morph animation

21 views
Skip to first unread message

3demax

unread,
Aug 17, 2011, 9:32:16 AM8/17/11
to RightJS
I was trying to stop morphing animation and preserve state of element
with interrupted animation
http://jsfiddle.net/QRxj7/
Maybe I'm doing something wrong?

3demax

unread,
Aug 17, 2011, 9:46:58 AM8/17/11
to RightJS
found error in setTimeout http://jsfiddle.net/QRxj7/1/
works as intended, sorry for disturbing :/
well, i'll try to dig further my code.

On Aug 17, 4:32 pm, 3demax <3de...@gmail.com> wrote:
> I was trying to stop morphing animation and preserve state of element
> with interrupted animationhttp://jsfiddle.net/QRxj7/

Nikolay Nemshilov

unread,
Aug 17, 2011, 9:51:54 AM8/17/11
to rig...@googlegroups.com
Hey Max,

Nope, you were doing awright. The problem though that native CSS transformations (which RightJS uses in modern browsers by default) cannot be stopped in the middle. Technically there is no API to stop them at all, so we use a hack which stops the animation but the state of the element jumps straight to the end of the animation.

If you're really need to stop it in the middle use the `engine: 'javascript'` option with your effect, kinda like that

$('box').morph({
  duration: 500,
  transition: 'Sin',
  engine: 'javascript'
});

In this case RightJS will use it's internal purely JavaScript engine to make the style transition and when you call it to stop it will freeze in the middle

--
Thanks,
Nikolay

--
You received this message because you are subscribed to the Google Groups "RightJS" group.
To post to this group, send email to rig...@googlegroups.com.
To unsubscribe from this group, send email to rightjs+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rightjs?hl=en.


3demax

unread,
Aug 17, 2011, 10:56:38 AM8/17/11
to RightJS
A minute before your reply I remembered of this problem of css
transitions, and tried to use engine: "js" and it also works:)
BTW, don't you plan on making dirty hack for stopping css transitions?
(I can imagine only computing current state based on initial and
ending states and time last from animation initiation start to the
moment of stopping)
Anyway thanks for quick reply.

Nikolay Nemshilov

unread,
Aug 17, 2011, 10:59:46 AM8/17/11
to rig...@googlegroups.com
I could make a hack around it, but the case is so rare and workaround is so simple that the overhead just doesn't worth of it


--
Thanks,
Nikolay
Reply all
Reply to author
Forward
0 new messages