Fix auto-scrolling by not calling within_viewport.

The geometry used by within_viewport() is a little off to
begin with, but we don't want to check it at all in this
situation, because if the last messages falls out of the
viewport, we still want to scroll.  The relevant thing
to check is that available_space_for_scroll exceeds zero.

(imported from commit a0a6f0d23db2eab8d9f22fc9ad523031cf7f7ec2)
This commit is contained in:
Steve Howell
2013-05-20 12:02:44 -04:00
committed by Leo Franchi
parent ecd3903007
commit 4ce6a6ea25

View File

@@ -420,9 +420,7 @@ MessageList.prototype = {
var selected_row = current_msg_list.selected_row();
var last_visible = rows.last_visible();
if (within_viewport(last_visible.offset(), last_visible.height())
&& selected_row && (selected_row.length > 0))
{
if (selected_row && (selected_row.length > 0)) {
var viewport_offset = viewport.scrollTop();
var new_messages_height = 0;
@@ -438,11 +436,13 @@ MessageList.prototype = {
var available_space_for_scroll = selected_row_offset - viewport_offset -
$("#floating_recipient_bar").height() - $("#searchbox_form").height();
suppress_scroll_pointer_update = true; // Gets set to false in the scroll handler.
// viewport (which is window) doesn't have a scrollTop, so scroll
// the closest concept that does.
$("html, body").animate({scrollTop: viewport_offset +
Math.min(new_messages_height, available_space_for_scroll)});
if (available_space_for_scroll > 0) {
suppress_scroll_pointer_update = true; // Gets set to false in the scroll handler.
// viewport (which is window) doesn't have a scrollTop, so scroll
// the closest concept that does.
$("html, body").animate({scrollTop: viewport_offset +
Math.min(new_messages_height, available_space_for_scroll)});
}
}
},