Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fade in/out max items in list on prepend
- Loading branch information
Adam Coffman
committed
Jan 18, 2011
1 parent
cffb8ae
commit 82dbf21
Showing
1 changed file
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
}); | ||
|