Restore centering when using the down arrow (or "j").

This restores the feature that hitting down when you are at the
last message automatically centers the last message.  This is not
a pure revert, because some additional code now goes through
navigate.down.

(imported from commit 2db1f247692ba068613a2d6c93f18ca7c13a16b8)
This commit is contained in:
Steve Howell 2013-08-05 15:52:38 -04:00
parent 1b1f80f3d7
commit b3f60faf3f
2 changed files with 12 additions and 2 deletions

View File

@ -266,7 +266,7 @@ function process_hotkey(e) {
switch (event_name) { switch (event_name) {
case 'down_arrow': case 'down_arrow':
case 'vim_down': case 'vim_down':
navigate.down(); navigate.down(true); // with_centering
return true; return true;
case 'up_arrow': case 'up_arrow':
case 'vim_up': case 'vim_up':

View File

@ -17,12 +17,22 @@ exports.up = function () {
} }
}; };
exports.down = function () { exports.down = function (with_centering) {
last_viewport_movement_direction = 1; last_viewport_movement_direction = 1;
var next_row = rows.next_visible(current_msg_list.selected_row()); var next_row = rows.next_visible(current_msg_list.selected_row());
if (next_row.length !== 0) { if (next_row.length !== 0) {
go_to_row(next_row); go_to_row(next_row);
} }
if (with_centering && (next_row.length === 0)) {
// At the last message, scroll to the bottom so we have
// lots of nice whitespace for new messages coming in.
//
// FIXME: this doesn't work for End because rows.last_visible()
// always returns a message.
var current_msg_table = rows.get_table(current_msg_list.table_name);
viewport.scrollTop(current_msg_table.outerHeight(true) - viewport.height() * 0.1);
mark_current_list_as_read();
}
}; };
exports.to_home = function () { exports.to_home = function () {