Skip to content

Commit

Permalink
Use react-lazyrender-mixin to lazily render feed items
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkueng committed Jul 26, 2015
1 parent 73a410f commit e62e215
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
12 changes: 9 additions & 3 deletions frontend/components/FeedItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

import React from 'react/addons';
import moment from 'moment';
import LazyLoad from 'react-lazy-load';
import LazyRenderMixin from 'react-lazyrender-mixin';

var FeedItem = React.createClass({
mixins: [ LazyRenderMixin ],

getDefaultProps () {
return {
placeholderClassName: 'feed-item-placeholder'
};
},

propTypes: {
showId: React.PropTypes.string.isRequired,
imdbId: React.PropTypes.string,
Expand All @@ -26,7 +34,6 @@ var FeedItem = React.createClass({
var timeAgo = moment(ts).fromNow();

return (
<LazyLoad height="400px">
<div className="feed-item">
<div className="feed-item-header emerald">{timeAgo}</div>
<div className="feed-item-body" style={localStyle}>
Expand All @@ -36,7 +43,6 @@ var FeedItem = React.createClass({
</div>
<div className="feed-item-footer emerald">Season {this.props.season}, Episode {this.props.episode}</div>
</div>
</LazyLoad>
);
}

Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var isProduction = process.env.NODE_ENV !== 'development';
var vendors = [
'react',
'react/addons',
'react-lazy-load',
'react-lazyrender-mixin',
'moment',
'axios',
'immutable',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"moment": "^2.10.3",
"rc": "^1.0.3",
"react": "^0.13.0",
"react-lazy-load": "git+https://github.com/maxkueng/react-lazy-load.git#npm-files",
"react-lazyrender-mixin": "^1.0.0",
"react-router": "1.0.0-beta3",
"request": "^2.58.0",
"yomypopcorn-dbclient": "git+https://github.com/yomypopcorn/yomypopcorn-dbclient.git#master"
Expand Down
4 changes: 2 additions & 2 deletions static/assets/app.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions static/assets/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ input[type="search"]:focus {
margin: 2em;
}

.feed-item-placeholder {
height: 400px;
}

.feed-item-header,
.feed-item-footer {
height: 60px;
Expand Down
26 changes: 14 additions & 12 deletions static/assets/vendor.js

Large diffs are not rendered by default.

0 comments on commit e62e215

Please # to comment.