Skip to content

Instantly share code, notes, and snippets.

@dawnerd
Created November 10, 2011 23:44
Show Gist options
  • Save dawnerd/1356646 to your computer and use it in GitHub Desktop.
Save dawnerd/1356646 to your computer and use it in GitHub Desktop.
short Ticker.js
#news { background: #666; color: #fff; padding: 4px 0; width: 100%; height: 30px; line-height: 30px; overflow: hidden; }
#news .container { float: left; }
#news .overflow { width: 900000px; }
#news .item { padding: 0 20px; }
#newsBlocks.FLC
#news.FLC
.overflow
.container
- each item in news_items
span.item #{item}
span.item ·
var ticker = $('#news .container'),
ticker_width = ticker.width();
$('#news .overflow').append(ticker[0].cloneNode(true));
function animateTicker() {
$('#news .container').first().animate({
marginLeft: ~ticker_width,
duration: ticker_width/40*1000,
easing: function (t) {
return t;
},
complete: function() {
$('#news .container').first().css({
'margin-left': 0
});
animateTicker();
}
});
}
animateTicker();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment