Просмотр исходного кода

Commit 14-2: Fade items in when they are drawn.

Frederic G. MARAND 9 лет назад
Родитель
Сommit
e16aa50a15
1 измененных файлов с 9 добавлено и 0 удалено
  1. 9 0
      client/templates/posts/posts_list.js

+ 9 - 0
client/templates/posts/posts_list.js

@@ -1,5 +1,9 @@
 Template.postsList.onRendered(function () {
   this.find('.wrapper')._uihooks = {
+    insertElement: function (node, next) {
+      $(node).hide().insertBefore(next).fadeIn();
+    },
+
     moveElement: function (node, next) {
       var $node = $(node);
       var $next = $(next);
@@ -34,7 +38,12 @@ Template.postsList.onRendered(function () {
       // Reset everything to 0, animated.
       $node.addClass('animate').css('top', 0);
       $inBetween.addClass('animate').css('top', 0);
+    },
 
+    removeElement: function (node) {
+      $(node).fadeOut(function () {
+        this.remove();
+      });
     }
   };
 });