Remove deferred installation of scroll handler.

This is no longer required, now that we're no longer scrolling the
main body of the page.

(imported from commit c2aa0d403c8fd0679b3110fe8e7684d46a7557fa)
This commit is contained in:
Tim Abbott
2014-01-30 18:00:33 -05:00
parent 70df0b933c
commit 6e5e5596fd
2 changed files with 5 additions and 44 deletions

View File

@@ -1810,18 +1810,16 @@ function scroll_finish() {
scroll_timer = setTimeout(scroll_finished, 100); scroll_timer = setTimeout(scroll_finished, 100);
} }
exports.register_scroll_handler = function () {
viewport.message_pane.scroll($.throttle(50, function (e) {
process_visible_unread_messages();
scroll_finish();
}));
};
// Save the compose content cursor position and restore when we // Save the compose content cursor position and restore when we
// shift-tab back in (see hotkey.js). // shift-tab back in (see hotkey.js).
var saved_compose_cursor = 0; var saved_compose_cursor = 0;
$(function () { $(function () {
viewport.message_pane.scroll($.throttle(50, function (e) {
process_visible_unread_messages();
scroll_finish();
}));
$('#new_message_content').blur(function () { $('#new_message_content').blur(function () {
saved_compose_cursor = $(this).caret().start; saved_compose_cursor = $(this).caret().start;
}); });

View File

@@ -37,8 +37,6 @@ var unread_messages_read_in_narrow = false;
var pointer_update_in_flight = false; var pointer_update_in_flight = false;
var suppress_unread_counts = true; var suppress_unread_counts = true;
var waiting_on_browser_scroll = true;
function within_viewport(row_offset, row_height) { function within_viewport(row_offset, row_height) {
// Returns true if a message is fully within the effectively visible // Returns true if a message is fully within the effectively visible
// part of the viewport. // part of the viewport.
@@ -839,12 +837,6 @@ function process_result(messages, opts) {
} }
function get_old_messages_success(data, opts) { function get_old_messages_success(data, opts) {
if (waiting_on_browser_scroll) {
setTimeout(function () {
get_old_messages_success(data, opts);
}, 25);
return;
}
if (tutorial.is_running()) { if (tutorial.is_running()) {
// Don't actually process the messages until the tutorial is // Don't actually process the messages until the tutorial is
// finished, but do disable the loading indicator so it isn't // finished, but do disable the loading indicator so it isn't
@@ -1126,35 +1118,6 @@ function main() {
}); });
} }
function install_main_scroll_handler() {
waiting_on_browser_scroll = false;
// Unregister this special un-throttled scroll handler.
$(window).unbind("scroll");
// Register the normal throttled scroll handler.
ui.register_scroll_handler();
}
$(function () { $(function () {
// On a page load or reload, the browser will, at an idle time, scroll to
// the top of the page. We can't intercept this browser-induced scroll, so
// to make sure it doesn't in interfere with our scrolling to the correct
// place in your message feed, we let the browser scroll happen first.
// After some time, if we haven't seen the browser scroll, give up
// and call main.
var browser_scroll_timer = setTimeout(function () {
install_main_scroll_handler();
}, 500);
$(window).scroll(function () {
if (viewport.scrollTop() < viewport.height()) {
// This is the browser-induced scroll to the top of the
// page that we were waiting for. It only happens once,
// so stop waiting and call main.
install_main_scroll_handler();
clearTimeout(browser_scroll_timer);
}
});
main(); main();
}); });