Skip to content

Commit

Permalink
Merge a79c867 into aa75f98
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-feng committed Feb 4, 2017
2 parents aa75f98 + a79c867 commit 1a06338
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions webapp/components/post_view/components/post_list.jsx
Expand Up @@ -25,6 +25,8 @@ import PreferenceStore from 'stores/preference_store.jsx';

import {FormattedDate, FormattedMessage} from 'react-intl';

import loadingGif from 'images/load.gif';

import React from 'react';
import ReactDOM from 'react-dom';

Expand Down Expand Up @@ -110,6 +112,12 @@ export default class PostList extends React.Component {
return this.refs.postlist.clientHeight + this.refs.postlist.scrollTop >= this.refs.postlist.scrollHeight - atBottomMargin;
}

isTop() {
const atTopMargin = 10;

return this.refs.postlist.scrollTop - atTopMargin < 0;
}

handleScroll() {
// HACK FOR RHS -- REMOVE WHEN RHS DIES
const childNodes = this.refs.postlistcontent.childNodes;
Expand All @@ -124,6 +132,9 @@ export default class PostList extends React.Component {
if (!this.jumpToPostNode && childNodes.length > 0) {
this.jumpToPostNode = childNodes[childNodes.length - 1];
}
if (this.isTop()) {
this.loadMorePostsTop();
}

// --- --------

Expand Down Expand Up @@ -183,9 +194,7 @@ export default class PostList extends React.Component {
}
}

loadMorePostsTop(e) {
e.preventDefault();

loadMorePostsTop() {
if (this.props.isFocusPost) {
return GlobalActions.emitLoadMorePostsFocusedTopEvent();
}
Expand Down Expand Up @@ -540,11 +549,10 @@ export default class PostList extends React.Component {
ref='loadmoretop'
className='more-messages-text theme'
href='#'
onClick={this.loadMorePostsTop}
>
<FormattedMessage
id='posts_view.loadMore'
defaultMessage='Load more messages'
<img
className='post-loading-gif'
src={loadingGif}
/>
</a>
);
Expand Down

0 comments on commit 1a06338

Please sign in to comment.