From 7a97d01719496eaf66fcea3ea1a1c34f558d1a74 Mon Sep 17 00:00:00 2001 From: acrefoot Date: Fri, 28 Feb 2014 16:23:54 -0500 Subject: [PATCH] Fix broken viewport.message_viewport_info() calculations `#tab_bar_underpadding` overlaps some with `.message_header`, so adding `#tab_bar_underpadding.bottom + .message_header.height` gave us a nonsense message viewport top. Doing the calculation this way is more robust, as long as: 1) `$(".floating_recipient").offset().top` continues to give us a sensical number and is the last element just before the top of the viewport. 2) nothing appears between the composebox and viewport. In this commit I also removed the other couple of places where the #tab_bar_underpadding was being used as a viewport reference, that no longer makes sense. (imported from commit c7f35e41309900c581d5e2329c1becf161d501d3) --- static/js/ui.js | 1 - static/js/viewport.js | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/static/js/ui.js b/static/js/ui.js index 2e4db93a04..6921f7d41f 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -493,7 +493,6 @@ exports.resize_bottom_whitespace = function (h) { exports.resize_page_components = function () { var composebox = $("#compose"); var floating_recipient_bar = $("#floating_recipient_bar"); - var tab_bar_under = $("#tab_bar_underpadding"); var desired_width; if (exports.home_tab_obscured() === 'other_tab') { desired_width = $("div.tab-pane.active").outerWidth(); diff --git a/static/js/viewport.js b/static/js/viewport.js index 0ffba43bac..02dac5a553 100644 --- a/static/js/viewport.js +++ b/static/js/viewport.js @@ -20,19 +20,16 @@ exports.message_viewport_info = function () { var res = {}; - var element_just_above_us = $("#tab_bar_underpadding"); + var element_just_above_us = $(".floating_recipient"); - res.visible_top = - element_just_above_us.position().top - + element_just_above_us.height() - + $(".message_header").outerHeight(); + res.visible_top = element_just_above_us.offset().top + + element_just_above_us.outerHeight(); var element_just_below_us = $("#compose"); res.visible_height = element_just_below_us.position().top - - element_just_above_us.position().top - - $(".message_header").outerHeight(); + - res.visible_top; return res; }; @@ -133,7 +130,7 @@ function add_to_visible(candidates, visible, var top_of_feed = new util.CachedValue({ compute_value: function () { - return $("#tab_bar_underpadding")[0].getBoundingClientRect().bottom; + return $(".floating_recipient").offset().top + $(".floating_recipient").outerHeight(); } });