From 07863d1c8a027788fb877805d670d1dd3e16e21b Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 27 Feb 2021 16:44:26 -0800 Subject: [PATCH] message_viewport: Move height definition before use. Signed-off-by: Anders Kaseorg --- static/js/message_viewport.js | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/static/js/message_viewport.js b/static/js/message_viewport.js index f8a81bfb04..2885ccb820 100644 --- a/static/js/message_viewport.js +++ b/static/js/message_viewport.js @@ -7,6 +7,24 @@ let jwindow; const dimensions = {}; let in_stoppable_autoscroll = false; +function make_dimen_wrapper(dimen_name, dimen_func) { + dimensions[dimen_name] = new util.CachedValue({ + compute_value() { + return dimen_func.call(exports.message_pane); + }, + }); + return function viewport_dimension_wrapper(...args) { + if (args.length !== 0) { + dimensions[dimen_name].reset(); + return dimen_func.apply(exports.message_pane, args); + } + return dimensions[dimen_name].get(); + }; +} + +exports.height = make_dimen_wrapper("height", $(exports.message_pane).height); +exports.width = make_dimen_wrapper("width", $(exports.message_pane).width); + // Includes both scroll and arrow events. Negative means scroll up, // positive means scroll down. exports.last_movement_direction = 1; @@ -279,24 +297,6 @@ exports.scrollTop = function viewport_scrollTop(target_scrollTop) { return ret; }; -function make_dimen_wrapper(dimen_name, dimen_func) { - dimensions[dimen_name] = new util.CachedValue({ - compute_value() { - return dimen_func.call(exports.message_pane); - }, - }); - return function viewport_dimension_wrapper(...args) { - if (args.length !== 0) { - dimensions[dimen_name].reset(); - return dimen_func.apply(exports.message_pane, args); - } - return dimensions[dimen_name].get(); - }; -} - -exports.height = make_dimen_wrapper("height", $(exports.message_pane).height); -exports.width = make_dimen_wrapper("width", $(exports.message_pane).width); - exports.stop_auto_scrolling = function () { if (in_stoppable_autoscroll) { exports.message_pane.stop();