From 62be1213285a8eb1c4e8375fe6c0bda4f0ca49c7 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 31 Mar 2017 13:00:52 -0400 Subject: [PATCH] FIX: On long browsers, you could get a double title --- .../discourse/components/discourse-topic.js.es6 | 7 ++++--- app/assets/javascripts/discourse/lib/lock-on.js.es6 | 2 ++ app/assets/javascripts/discourse/lib/url.js.es6 | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/components/discourse-topic.js.es6 b/app/assets/javascripts/discourse/components/discourse-topic.js.es6 index 4c717b30493..ba81a63bf39 100644 --- a/app/assets/javascripts/discourse/components/discourse-topic.js.es6 +++ b/app/assets/javascripts/discourse/components/discourse-topic.js.es6 @@ -37,7 +37,7 @@ export default Ember.Component.extend(AddArchetypeClass, Scrolling, { const enteredAt = this.get('enteredAt'); if (enteredAt && (this.get('lastEnteredAt') !== enteredAt)) { this._lastShowTopic = null; - this.scrolled(); + Ember.run.schedule('afterRender', () => this.scrolled()); this.set('lastEnteredAt', enteredAt); } }, @@ -131,20 +131,21 @@ export default Ember.Component.extend(AddArchetypeClass, Scrolling, { } } + this.set('hasScrolled', offset > 0); const topic = this.get('topic'); const showTopic = this.showTopicInHeader(topic, offset); if (showTopic !== this._lastShowTopic) { - this._lastShowTopic = showTopic; - if (showTopic) { this.appEvents.trigger('header:show-topic', topic); + this._lastShowTopic = true; } else { if (!DiscourseURL.isJumpScheduled()) { const loadingNear = topic.get('postStream.loadingNearPost') || 1; if (loadingNear === 1) { this.appEvents.trigger('header:hide-topic'); + this._lastShowTopic = false; } } } diff --git a/app/assets/javascripts/discourse/lib/lock-on.js.es6 b/app/assets/javascripts/discourse/lib/lock-on.js.es6 index d6b95945840..10c3542670e 100644 --- a/app/assets/javascripts/discourse/lib/lock-on.js.es6 +++ b/app/assets/javascripts/discourse/lib/lock-on.js.es6 @@ -55,6 +55,8 @@ export default class LockOn { const interval = setInterval(() => { let top = this.elementTop(); + if (top < 0) { top = 0; } + const scrollTop = $(window).scrollTop(); if (typeof(top) === "undefined" || isNaN(top)) { diff --git a/app/assets/javascripts/discourse/lib/url.js.es6 b/app/assets/javascripts/discourse/lib/url.js.es6 index 80dbdef6d2a..84d319a6a9d 100644 --- a/app/assets/javascripts/discourse/lib/url.js.es6 +++ b/app/assets/javascripts/discourse/lib/url.js.es6 @@ -108,6 +108,10 @@ const DiscourseURL = Ember.Object.extend({ } lockon.lock(); + if (lockon.elementTop() < 1) { + _transitioning = false; + return; + } }); },