Skip to content

Commit

Permalink
fade in/out max items in list on prepend
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Coffman committed Jan 18, 2011
1 parent cffb8ae commit 82dbf21
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions public/feed.js
@@ -1,17 +1,41 @@
var MAX_ITEMS = 5;
var ITEMS = 0;

function handleNewFeedItems(items){
for(item in items){

}
}

$(document).ready(function () {
function fadeInOneItem(item, list){
//add to top of list as invisible
var $inserted = $(item).css({
display: 'none',
opacity : 0,
marginBottom: 0
}).prependTo(list);

//animate in the new item
$inserted.slideDown({queue:false, duration:500})
.animate( {marginBottom:'5px'}, {queue:false, duration:500} )
.animate( {opacity:1}, {queue:false, duration:500} );

ITEMS += 1;

if(ITEMS > MAX_ITEMS){
$list.children(':last').fadeOut(function(){$(this).remove()});
ITEMS -=1;
}
}

$(document).ready(function () {
$list = $("#feed_list");
$categories = $("#category_list");

var socket = new io.Socket(null, {port: 3000});
socket.connect();
socket.on('newfeeditems', function(msg){
alert(msg);
});

socket.on('newfeeditems', handleNewFeedItems(items))
});

0 comments on commit 82dbf21

Please sign in to comment.