Created
October 19, 2012 18:23
-
-
Save fastdivision/3919803 to your computer and use it in GitHub Desktop.
TweetScroller Snippets
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
-webkit-mask-image: -webkit-gradient(linear, left 80%, left bottom, from(black), to(rgba(0, 0, 0, 0))); | |
-webkit-mask-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(15%, black), color-stop(85%, black), color-stop(100%, rgba(0, 0, 0, 0))); |
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
defaults = | |
tweet: '.tweet' | |
template: '#tweet-template' | |
username: 'divshot' | |
count: 50 | |
height: 600 | |
speed: 30 # ms, 30-80 ms recommended, slower = better performance | |
autoplay: false # CPU intensive |
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
getTweets: -> | |
$.getJSON "https://api.twitter.com/1/favorites.json?count=#{@options.count}&screen_name=#{@options.username}&callback=?", (data) => | |
$(@element).append('<div class="tweetscroller"></div>') | |
@board = $(@element).find('.tweetscroller') | |
$.each data, (i, tweet) => | |
tweet.created_at = new Date(Date.parse(tweet.created_at)) | |
tweet.created_at = moment(tweet.created_at).format('D MMM YY') | |
source = $(@options.template).html() | |
template = Handlebars.compile(source) | |
@board.append(template(tweet)) | |
@board.masonry | |
itemSelector: @options.tweet | |
@_initialTweetCount = @board.find(@options.tweet).length | |
@scrollTweets() |
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
scrollRefresh: (e) -> | |
_this = this | |
if @board.parent()[0].scrollHeight - @board.parent().scrollTop() <= @board.parent().height() | |
@board.find(@options.tweet).each (i) -> | |
tweet = $(this).clone() | |
_this.board.append(tweet).masonry('appended', tweet, true) | |
if i <= _this.board.find('.tweet').length - _this._initialTweetCount | |
$(this).remove() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment