diff --git a/js/src/forum/components/PostStream.js b/js/src/forum/components/PostStream.js index 3ba97ef56..c2e667c0e 100644 --- a/js/src/forum/components/PostStream.js +++ b/js/src/forum/components/PostStream.js @@ -206,7 +206,7 @@ export default class PostStream extends Component { const threeQuartersVisible = visibleTop / height < 0.75; const coversQuarterOfViewport = (height - visibleTop) / viewportHeight > 0.25; if (index === undefined && (threeQuartersVisible || coversQuarterOfViewport)) { - index = parseFloat($this.data('index')) + visibleTop / height; + index = parseFloat($this.data('index')) + (visibleTop / height) * (1 / 0.75); // If this item has a time associated with it, then set the // scrollbar's current period to a formatted version of this time. const time = $this.data('time'); @@ -343,12 +343,12 @@ export default class PostStream extends Component { } return Promise.all([$container.promise(), this.state.loadPromise]).then(() => { - const index = $item.data('index'); + this.state.index = $item.data('index'); + this.updateScrubber(); m.redraw(true); - const scroll = index == 0 ? 0 : $(`.PostStream-item[data-index=${$item.data('index')}]`).offset().top - this.getMarginTop(); + const scroll = this.state.index == 0 ? 0 : $(`.PostStream-item[data-index=${$item.data('index')}]`).offset().top - this.getMarginTop(); $(window).scrollTop(scroll); this.calculatePosition(); - this.updateScrubber(); this.state.paused = false; m.redraw(); }); diff --git a/js/src/forum/components/PostStreamScrubber.js b/js/src/forum/components/PostStreamScrubber.js index 99ffad322..cc7a2a04d 100644 --- a/js/src/forum/components/PostStreamScrubber.js +++ b/js/src/forum/components/PostStreamScrubber.js @@ -17,21 +17,21 @@ export default class PostStreamScrubber extends Component { this.state = this.props.state; this.handlers = {}; - this.scrollListener = new ScrollListener(this.updateScrubberValues.bind(this)); + this.scrollListener = new ScrollListener(this.updateScrubberValues.bind(this, { fromScroll: true, forceHeightChange: true })); } view() { - const index = this.state.index; const count = this.state.count(); - const visible = this.state.visible() || 1; - const unreadCount = this.state.discussion.unreadCount(); - const unreadPercent = count ? Math.min(count - this.state.index, unreadCount) / count : 0; + // Index is left blank for performance reasons, it is filled in in updateScubberValues const viewing = app.translator.transChoice('core.forum.post_scrubber.viewing_text', count, { - index: {formatNumber(this.state.sanitizeIndex(index + 1))}, + index: , count: {formatNumber(count)}, }); + const unreadCount = this.state.discussion.unreadCount(); + const unreadPercent = count ? Math.min(count - this.state.index, unreadCount) / count : 0; + function styleUnread(element, isInitialized, context) { const $element = $(element); const newStyle = { @@ -47,15 +47,7 @@ export default class PostStreamScrubber extends Component { context.oldStyle = newStyle; } - - const percentPerPost = this.percentPerPost(); - const beforeHeight = Math.max(0, percentPerPost.index * Math.min(index, count - visible)); - const handleHeight = Math.min(100 - beforeHeight, percentPerPost.visible * visible); - const afterHeight = 100 - beforeHeight - handleHeight; - const classNames = ['PostStreamScrubber', 'Dropdown']; - if (this.state.disabled()) classNames.push('disabled'); - if (this.dragging) classNames.push('dragging'); if (this.props.className) classNames.push(this.props.className); return ( @@ -71,15 +63,15 @@ export default class PostStreamScrubber extends Component {