Account for navbar/composebox/etc. in determining visible messages.

Created a function message_viewport_info() to return more accurate
effective viewport info and called it from process_visible_unread_messages().
Also killed off a tiny bit of dead code in process_visible_unread_messages().

(imported from commit 985fcf2fb447dbf1026e2de37574c255a9bd6196)
This commit is contained in:
Steve Howell 2013-05-16 14:13:42 -04:00 committed by Leo Franchi
parent e744c0ced6
commit 64fffc5b23
2 changed files with 34 additions and 4 deletions

View File

@ -32,6 +32,37 @@ exports.focus_on = function (field_id) {
$("#" + field_id).focus(); $("#" + field_id).focus();
}; };
exports.message_viewport_info = function () {
// see also: effective_page_size()
// Return a structure that tells us details of the viewport
// accounting for fixed elements like the top navbar.
//
// The message_header is NOT considered to be part of the visible
// message pane, which should make sense for callers, who will
// generally be concerned about whether actual message content is
// visible.
var res = {};
res.top_hidden_height =
$("#top_navbar").height()
+ $(".message_header").height();
res.bottom_hidden_height =
$("#compose").height();
res.visible_height =
viewport.height()
- res.top_hidden_height
- res.bottom_hidden_height;
res.visible_top =
viewport.scrollTop()
+ res.top_hidden_height;
return res;
};
function effective_page_size() { function effective_page_size() {
// This function returns the height of the viewable portion of the // This function returns the height of the viewable portion of the
// message pane, so it starts with the viewport height and // message pane, so it starts with the viewport height and

View File

@ -437,10 +437,9 @@ function process_visible_unread_messages() {
} }
var selected = current_msg_list.selected_message(); var selected = current_msg_list.selected_message();
var top = viewport.scrollTop(); var vp = ui.message_viewport_info();
var height = viewport.height(); var top = vp.visible_top;
var bottom = top + height; var height = vp.visible_height;
var middle = top + (height / 2);
// Being simplistic about this, the smallest message is 30 px high. // Being simplistic about this, the smallest message is 30 px high.
var selected_row = rows.get(current_msg_list.selected_id(), current_msg_list.table_name); var selected_row = rows.get(current_msg_list.selected_id(), current_msg_list.table_name);