refactor: Change where we initialize scrolling code.

This is a more sensible place to initialize the
the scrolling handler, plus it breaks an annoying
indirect dependency on jQuery for the unit tests.
This commit is contained in:
Steve Howell 2021-01-27 16:25:19 +00:00 committed by Tim Abbott
parent 6c4b1183f2
commit 5a27ed6a72
3 changed files with 9 additions and 12 deletions

View File

@ -4,7 +4,7 @@ const {strict: assert} = require("assert");
const _ = require("lodash");
const {set_global, stub_out_jquery, zrequire} = require("../zjsunit/namespace");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
set_global("page_params", {
@ -13,9 +13,6 @@ set_global("page_params", {
is_guest: false,
});
set_global("document", null);
stub_out_jquery();
zrequire("color_data");
zrequire("hash_util");
zrequire("stream_topic_history");

View File

@ -415,12 +415,4 @@ exports.all = new MessageList({
muting_enabled: false,
});
// We stop autoscrolling when the user is clearly in the middle of
// doing something. Be careful, though, if you try to capture
// mousemove, then you will have to contend with the autoscroll
// itself generating mousemove events.
$(document).on("message_selected.zulip wheel", () => {
message_viewport.stop_auto_scrolling();
});
window.message_list = exports;

View File

@ -457,6 +457,14 @@ exports.initialize = function () {
$(document).on("compose_started compose_canceled compose_finished", () => {
bottom_of_feed.reset();
});
// We stop autoscrolling when the user is clearly in the middle of
// doing something. Be careful, though, if you try to capture
// mousemove, then you will have to contend with the autoscroll
// itself generating mousemove events.
$(document).on("message_selected.zulip wheel", () => {
exports.stop_auto_scrolling();
});
};
window.message_viewport = exports;