From 4ce6a6ea25ca9f954be1ff1b1ac3402a25450de6 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 20 May 2013 12:02:44 -0400 Subject: [PATCH] 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) --- zephyr/static/js/message_list.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zephyr/static/js/message_list.js b/zephyr/static/js/message_list.js index d88a13b69c..da05a09eee 100644 --- a/zephyr/static/js/message_list.js +++ b/zephyr/static/js/message_list.js @@ -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)}); + } } },