From 3d49a83d7a793034d859e14472f6eca8d888aefd Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 1 Jun 2016 13:10:33 -0400 Subject: [PATCH] FIX: Scrollbar wouldn't reach the bottom if you scrolled too fast --- .../discourse/components/scrolling-post-stream.js.es6 | 10 +++++++++- .../discourse/components/site-header.js.es6 | 2 -- .../discourse/components/topic-timeline.js.es6 | 5 ----- .../discourse/widgets/topic-timeline.js.es6 | 1 - 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/discourse/components/scrolling-post-stream.js.es6 b/app/assets/javascripts/discourse/components/scrolling-post-stream.js.es6 index 5a46a83a4..b2cf0119d 100644 --- a/app/assets/javascripts/discourse/components/scrolling-post-stream.js.es6 +++ b/app/assets/javascripts/discourse/components/scrolling-post-stream.js.es6 @@ -92,6 +92,8 @@ export default MountWidget.extend({ // uncomment to debug the eyeline // $('.debug-eyeline').css({ height: '1px', width: '100%', backgroundColor: 'blue', position: 'absolute', top: `${topCheck}px` }); + let allAbove = true; + let bottomView = topView; while (bottomView < $posts.length) { const post = $posts[bottomView]; @@ -103,6 +105,8 @@ export default MountWidget.extend({ const postHeight = $post.height(); const viewBottom = Math.ceil(viewTop + postHeight); + allAbove = allAbove && (viewTop < topCheck); + if (viewTop > viewportBottom) { break; } if (viewBottom >= windowTop && viewTop <= windowBottom) { @@ -115,10 +119,14 @@ export default MountWidget.extend({ } nearby.push(bottomView); - bottomView++; } + if (allAbove) { + if (percent === null) { percent = 1.0; } + if (currentPost === null) { currentPost = bottomView - 1; } + } + const posts = this.posts; const refresh = cb => this.queueRerender(cb); if (onscreen.length) { diff --git a/app/assets/javascripts/discourse/components/site-header.js.es6 b/app/assets/javascripts/discourse/components/site-header.js.es6 index 0cac49b19..bf66453c6 100644 --- a/app/assets/javascripts/discourse/components/site-header.js.es6 +++ b/app/assets/javascripts/discourse/components/site-header.js.es6 @@ -68,8 +68,6 @@ const SiteHeaderComponent = MountWidget.extend(Docking, { willDestroyElement() { this._super(); $('body').off('keydown.header'); - this.appEvents.off('notifications:changed'); - this.appEvents.off('header:keyboard-trigger'); $(window).off('resize.discourse-menu-panel'); this.appEvents.off('header:show-topic'); diff --git a/app/assets/javascripts/discourse/components/topic-timeline.js.es6 b/app/assets/javascripts/discourse/components/topic-timeline.js.es6 index c5f17c106..e9d697b78 100644 --- a/app/assets/javascripts/discourse/components/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-timeline.js.es6 @@ -55,10 +55,5 @@ export default MountWidget.extend(Docking, { didInsertElement() { this._super(); this.dispatch('topic:current-post-scrolled', 'timeline-scrollarea'); - }, - - willDestroyElement() { - this._super(); - this.appEvents.off('topic:current-post-scrolled'); } }); diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 index cbbf55688..e552c1e23 100644 --- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 @@ -171,7 +171,6 @@ createWidget('timeline-scrollarea', { topicCurrentPostScrolled(event) { const { postIndex, percent } = event; - this.state.percentage = this._percentFor(this.attrs.topic, parseFloat(postIndex) + percent); },