Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #340 from tms/post-scroll-peekaboo

Position the selected post more reliably below the header
  • Loading branch information...
commit 09e9e34b8bb8ea27e2f413bb9983be8914d3abcc 2 parents 35d5c89 + fba50c3
@eviltrout eviltrout authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 app/assets/javascripts/discourse/views/topic_view.js
View
12 app/assets/javascripts/discourse/views/topic_view.js
@@ -494,14 +494,22 @@ window.Discourse.TopicView.reopenClass({
// Scroll to a given post, if in the DOM. Returns whether it was in the DOM or not.
scrollTo: function(topicId, postNumber, callback) {
// Make sure we're looking at the topic we want to scroll to
- var existing;
+ var existing, header, title, expectedOffset;
if (parseInt(topicId, 10) !== parseInt($('#topic').data('topic-id'), 10)) return false;
existing = $("#post_" + postNumber);
if (existing.length) {
if (postNumber === 1) {
$('html, body').scrollTop(0);
} else {
- $('html, body').scrollTop(existing.offset().top - 55);
+ header = $('header');
+ title = $('#topic-title');
+ expectedOffset = title.height() - header.find('.contents').height();
+
+ if (expectedOffset < 0) {
+ expectedOffset = 0;
+ }
+
+ $('html, body').scrollTop(existing.offset().top - (header.outerHeight(true) + expectedOffset));
}
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.