FIX: First post wasn't rendering timeline
This commit is contained in:
parent
4963d4d624
commit
6aef2b0a59
|
@ -82,8 +82,8 @@ createWidget('timeline-scrollarea', {
|
||||||
return { style: `height: ${SCROLLAREA_HEIGHT}px` };
|
return { style: `height: ${SCROLLAREA_HEIGHT}px` };
|
||||||
},
|
},
|
||||||
|
|
||||||
defaultState() {
|
defaultState(attrs) {
|
||||||
return { percentage: null, scrolledPost: 1 };
|
return { percentage: this._percentFor(attrs.topic, attrs.topic.currentPost), scrolledPost: 1 };
|
||||||
},
|
},
|
||||||
|
|
||||||
position() {
|
position() {
|
||||||
|
@ -164,10 +164,13 @@ createWidget('timeline-scrollarea', {
|
||||||
topicCurrentPostChanged(postNumber) {
|
topicCurrentPostChanged(postNumber) {
|
||||||
// If the post number didn't change keep our scroll position
|
// If the post number didn't change keep our scroll position
|
||||||
if (postNumber !== this.state.scrolledPost) {
|
if (postNumber !== this.state.scrolledPost) {
|
||||||
const total = this.attrs.topic.get('postStream.filteredPostsCount');
|
this.state.percentage = this._percentFor(this.attrs.topic, postNumber);
|
||||||
const perc = postNumber === 1 ? 0.0 : parseFloat(postNumber) / total;
|
|
||||||
this.state.percentage = perc;
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_percentFor(topic, postNumber) {
|
||||||
|
const total = topic.get('postStream.filteredPostsCount');
|
||||||
|
return postNumber === 1 ? 0.0 : parseFloat(postNumber) / total;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue