From 3a9f0445bbd603887fbef76f840a78bdd51a55c0 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 28 Aug 2014 11:57:24 +1000 Subject: [PATCH] HACK: remove jarring scroll when hitting back from topic --- .../discourse/routes/discourse_location.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/routes/discourse_location.js b/app/assets/javascripts/discourse/routes/discourse_location.js index b7125ae1da8..9dda10165a3 100644 --- a/app/assets/javascripts/discourse/routes/discourse_location.js +++ b/app/assets/javascripts/discourse/routes/discourse_location.js @@ -186,7 +186,9 @@ Ember.DiscourseLocation = Ember.Object.extend({ if (self.getURL() === self._previousURL) { return; } } var url = self.getURL(); - popstateCallbacks.forEach(function(cb) { cb(url); }); + popstateCallbacks.forEach(function(cb) { + cb(url); + }); callback(url); }); }, @@ -226,6 +228,16 @@ Ember.CloakedCollectionView.reopen({ _watchForPopState: function() { var self = this, cb = function() { + // Sam: This is a hack, but a very important one + // Due to the way we use replace state the back button works strangely + // + // If you visit a topic from the front page, scroll a bit around and then hit back + // you notice that first the page scrolls a bit (within the topic) and then it goes back + // this transition is jarring and adds uneeded rendering costs. + // + // To repro comment the hack out and wack a debugger statement here and in + // topic_route deactivate + $('.posts,#topic-title').hide(); self.cleanUp(); self.set('controller.postStream.loaded', false); };