mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 05:29:17 -06:00
FIX: Keep topic list items on screen when using keyboard.
This commit is contained in:
parent
47d821cd31
commit
2681717a87
@ -269,18 +269,10 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
|
||||
},
|
||||
|
||||
_scrollList: function($article, direction) {
|
||||
var $document = $(document),
|
||||
distToElement = $article.position().top + $article.height() - $(window).height() - $document.scrollTop();
|
||||
|
||||
// cut some bottom slack
|
||||
distToElement += 40;
|
||||
|
||||
// don't scroll backwards, its silly
|
||||
if((direction > 0 && distToElement < 0) || (direction < 0 && distToElement > 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('html, body').scrollTop($document.scrollTop() + distToElement);
|
||||
// Try to keep the article on screen
|
||||
var scrollPos = $article.position().top - ($(window).height() * 0.5);
|
||||
if (scrollPos < 0) { scrollPos = 0; }
|
||||
$('html, body').scrollTop(scrollPos);
|
||||
},
|
||||
|
||||
_findArticles: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user