FIX: Lock keyboard controls for navigating posts to eyeline

This commit is contained in:
Robin Ward 2016-06-02 13:50:12 -04:00
parent 43e7890dcf
commit 74a454c203
No known key found for this signature in database
GPG Key ID: 0E091E2B4ED1B83D
2 changed files with 13 additions and 5 deletions

View File

@ -93,7 +93,6 @@ export default MountWidget.extend({
// $('.debug-eyeline').css({ height: '1px', width: '100%', backgroundColor: 'blue', position: 'absolute', top: `${topCheck}px` });
let allAbove = true;
let bottomView = topView;
while (bottomView < $posts.length) {
const post = $posts[bottomView];
@ -160,7 +159,8 @@ export default MountWidget.extend({
this.sendAction('bottomVisibleChanged', { post: last, refresh });
}
if (this._currentPost !== currentPost) {
const changedPost = this._currentPost !== currentPost;
if (changedPost) {
this._currentPost = currentPost;
const post = posts.objectAt(currentPost);
this.sendAction('currentPostChanged', { post });
@ -169,7 +169,7 @@ export default MountWidget.extend({
if (percent !== null) {
if (percent > 1.0) { percent = 1.0; }
if (this._currentPercent !== percent) {
if (changedPost || (this._currentPercent !== percent)) {
this._currentPercent = percent;
this.sendAction('currentPostScrolled', { percent });
}

View File

@ -1,5 +1,6 @@
import DiscourseURL from 'discourse/lib/url';
import Composer from 'discourse/models/composer';
import { scrollTopFor } from 'discourse/lib/offset-calculator';
const bindings = {
'!': {postAction: 'showFlags'},
@ -298,12 +299,19 @@ export default {
if ($article.is('.topic-post')) {
$('a.tabLoc', $article).focus();
}
this._scrollToPost($article);
this._scrollList($article, direction);
} else {
this._scrollList($article, direction);
}
}
},
_scrollToPost($article) {
const pos = $article.offset();
$(window).scrollTop(Math.ceil(pos.top - scrollTopFor(pos.top)));
},
_scrollList($article) {
// Try to keep the article on screen
const pos = $article.offset();