mirror of https://github.com/zulip/zulip.git
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:
parent
e744c0ced6
commit
64fffc5b23
|
@ -32,6 +32,37 @@ exports.focus_on = function (field_id) {
|
|||
$("#" + 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() {
|
||||
// This function returns the height of the viewable portion of the
|
||||
// message pane, so it starts with the viewport height and
|
||||
|
|
|
@ -437,10 +437,9 @@ function process_visible_unread_messages() {
|
|||
}
|
||||
|
||||
var selected = current_msg_list.selected_message();
|
||||
var top = viewport.scrollTop();
|
||||
var height = viewport.height();
|
||||
var bottom = top + height;
|
||||
var middle = top + (height / 2);
|
||||
var vp = ui.message_viewport_info();
|
||||
var top = vp.visible_top;
|
||||
var height = vp.visible_height;
|
||||
|
||||
// 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);
|
||||
|
|
Loading…
Reference in New Issue