Created
November 10, 2011 23:44
-
-
Save dawnerd/1356646 to your computer and use it in GitHub Desktop.
short Ticker.js
This file contains hidden or 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
#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; } |
This file contains hidden or 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
#newsBlocks.FLC | |
#news.FLC | |
.overflow | |
.container | |
- each item in news_items | |
span.item #{item} | |
span.item · |
This file contains hidden or 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
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