Is there a way how to add unload animations?

12 views
Skip to first unread message

Vojtěch Kusý

unread,
Aug 7, 2014, 11:06:16 AM8/7/14
to seren...@googlegroups.com
Hello,

thanks to this answer from Jonas I'm able to add some animations and decorate templates with jQuery tweaks.

So it turns out that there are two yet undocumented lifecycle events, load and unload.

tbody[on:load=someControllerCallback]

I'm using load event to apply e.g. loading animation or jQuery Sortable, however I failed when I tried to use the unload event to do any kind of unloading animation (e.g. simple jQuery.slideUp), since template is replaced immediately after unload event is processed.

Is there a way how I can make unloading animation to work? Or can I replace/change the default replace operation when template is rerendered?



Jonas Nicklas

unread,
Aug 15, 2014, 8:53:06 AM8/15/14
to seren...@googlegroups.com
The reason this isn't going to work is because the element is removed immediately after the `unload` callback is called. You might have an easier time if you use a CSS animation, but even then it'll require some tricky timing to get right.

/Jonas


--
You received this message because you are subscribed to the Google Groups "Serenade.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to serenadejs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vojtěch Kusý

unread,
Aug 15, 2014, 9:27:14 AM8/15/14
to seren...@googlegroups.com
Yeah, I know, I described that in my original question:


since template is replaced immediately after unload event is processed.

So there is no workaround or a way how to hook up to this except hacking Serenade core I suppose?

Vojta

Sergey Makridenkov

unread,
Aug 15, 2014, 3:37:40 PM8/15/14
to seren...@googlegroups.com
Hi Vojta,

In case you would like show the animation let say on the table row deletion.
I would do it like

class Controller
  ...
  delete: (item, elem_table_row) ->
    $(elem_table_row).slideUp('normal', => @items.delete(item))

/msa

Vojtěch Kusý

unread,
Aug 18, 2014, 4:57:50 PM8/18/14
to seren...@googlegroups.com
Thanks Sergey, this is probably the only way how to achieve this now. However it is bit shame that we cannot to hookup to unload event with some effects just before it is removed. I wish to bind the presentation layer effects (such as slide up of the old search results) to the business logic events and not the vice versa.

Sergey Makridenkov

unread,
Aug 19, 2014, 1:23:09 AM8/19/14
to seren...@googlegroups.com
I think it danger to put animation on unload, since unload can happen from few places.
In one place animation should be, but in two other not.

My opinion, direct way to apply animation is better.
Reply all
Reply to author
Forward
0 new messages