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)
This commit is contained in:
acrefoot
2014-02-28 16:23:54 -05:00
committed by Steve Howell
parent 3450d05858
commit 7a97d01719
2 changed files with 5 additions and 9 deletions

View File

@@ -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();

View File

@@ -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();
}
});