HACK: hold back on loading more topics for a bit while we are repositioning the page for Safari

This commit is contained in:
Sam 2013-08-20 11:25:01 +10:00
parent 341a28402d
commit d43bd55e5b

View file

@ -228,6 +228,11 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
var info = Discourse.Eyeline.analyze(rows); var info = Discourse.Eyeline.analyze(rows);
if(!info) { return; } if(!info) { return; }
// We disable scrolling of the topic while performing initial positioning
// This code needs to be refactored, the pipline for positioning posts is wack
// Be sure to test on safari as well when playing with this
if(!Discourse.TopicView.disableScroll) {
// are we scrolling upwards? // are we scrolling upwards?
if(info.top === 0 || info.onScreen[0] === 0 || info.bottom === 0) { if(info.top === 0 || info.onScreen[0] === 0 || info.bottom === 0) {
var $body = $('body'); var $body = $('body');
@ -239,6 +244,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
}); });
}); });
} }
}
// are we scrolling down? // are we scrolling down?
var currentPost; var currentPost;
@ -247,6 +253,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
this.get('postStream').appendMore(); this.get('postStream').appendMore();
} }
// update dock // update dock
this.updateDock(Ember.View.views[rows[info.bottom].id]); this.updateDock(Ember.View.views[rows[info.bottom].id]);
@ -352,6 +359,7 @@ Discourse.TopicView.reopenClass({
// Scroll to a given post, if in the DOM. Returns whether it was in the DOM or not. // Scroll to a given post, if in the DOM. Returns whether it was in the DOM or not.
jumpToPost: function(topicId, postNumber, avoidScrollIfPossible) { jumpToPost: function(topicId, postNumber, avoidScrollIfPossible) {
this.disableScroll = true;
Em.run.scheduleOnce('afterRender', function() { Em.run.scheduleOnce('afterRender', function() {
var rows = $('.topic-post.ready'); var rows = $('.topic-post.ready');
@ -428,6 +436,8 @@ Discourse.TopicView.reopenClass({
$contents.removeClass('highlighted'); $contents.removeClass('highlighted');
}); });
} }
setTimeout(function(){Discourse.TopicView.disableScroll = false;}, 500);
} }
}); });
} }