Merge pull request #1969 from riking/scroll-position
Put requested post in middle of page
This commit is contained in:
commit
887e835a9b
|
@ -127,7 +127,13 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
|
||||||
if ($article.size() > 0) {
|
if ($article.size() > 0) {
|
||||||
$articles.removeClass('selected');
|
$articles.removeClass('selected');
|
||||||
$article.addClass('selected');
|
$article.addClass('selected');
|
||||||
this._scrollList($article);
|
|
||||||
|
var rgx = new RegExp("post-cloak-(\\d+)").exec($article.parent()[0].id);
|
||||||
|
if (rgx === null || typeof rgx[1] === 'undefined') {
|
||||||
|
this._scrollList($article);
|
||||||
|
} else {
|
||||||
|
Discourse.TopicView.jumpToPost(rgx[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,8 @@ Discourse.TopicView.reopenClass({
|
||||||
new LockOn(holderId, {offsetCalculator: function() {
|
new LockOn(holderId, {offsetCalculator: function() {
|
||||||
var $header = $('header'),
|
var $header = $('header'),
|
||||||
$title = $('#topic-title'),
|
$title = $('#topic-title'),
|
||||||
expectedOffset = $title.height() - $header.find('.contents').height();
|
windowHeight = $(window).height() - $title.height(),
|
||||||
|
expectedOffset = $title.height() - $header.find('.contents').height() + (windowHeight / 5);
|
||||||
|
|
||||||
return $header.outerHeight(true) + ((expectedOffset < 0) ? 0 : expectedOffset);
|
return $header.outerHeight(true) + ((expectedOffset < 0) ? 0 : expectedOffset);
|
||||||
}}).lock();
|
}}).lock();
|
||||||
|
|
Loading…
Reference in New Issue