diff --git a/zephyr/static/js/notifications_bar.js b/zephyr/static/js/notifications_bar.js index 931f77fe1d..fc26522e0d 100644 --- a/zephyr/static/js/notifications_bar.js +++ b/zephyr/static/js/notifications_bar.js @@ -29,8 +29,10 @@ function hide() { // If there's a custom message, or if the last message is off the bottom of the // screen, then show the notifications bar. exports.update = function (num_unread) { - if (rows.last_visible().offset() !== null // otherwise the next line will error - && rows.last_visible().offset().top + rows.last_visible().height() > viewport.scrollTop() + viewport.height() - $("#compose").height() + var last_row = rows.last_visible(); + if (last_row + && last_row.offset() !== null // otherwise the next line will error + && viewport.is_below_visible_bottom(last_row.offset().top + last_row.height()) && num_unread > 0) show(); else diff --git a/zephyr/static/js/viewport.js b/zephyr/static/js/viewport.js index f7a4353a06..6a73b83e5d 100644 --- a/zephyr/static/js/viewport.js +++ b/zephyr/static/js/viewport.js @@ -49,6 +49,10 @@ exports.at_bottom = function () { return bottom + 2 >= window_size; }; +exports.is_below_visible_bottom = function (offset) { + return offset > viewport.scrollTop() + viewport.height() - $("#compose").height(); +}; + exports.set_message_position = function (message_top, message_height, viewport_info, ratio) { // message_top = offset of the top of a message that you are positioning // message_height = height of the message that you are positioning