mirror of
https://github.com/zulip/zulip.git
synced 2025-11-20 14:38:46 +00:00
list_render: Extract get_list_scrolling_container().
We put this in `scroll_util` to make it more likely we will eventually unify this with other scrolling logic. (A big piece to move is ui.get_scroll_element, but that's for another PR.) And then the other tactical advantage is that we get 100% line coverage on it. I changed the warning to an error, since I don't think we ever expect scrolling at the `body` level, and I don't bother with the preview node.
This commit is contained in:
@@ -1,3 +1,30 @@
|
||||
exports.get_list_scrolling_container = function (container) {
|
||||
/*
|
||||
This is used for list widgets that don't
|
||||
have SimpleBar (in contrast to, say,
|
||||
ui.get_scroll_element().
|
||||
*/
|
||||
|
||||
let nearestScrollingContainer = container;
|
||||
|
||||
while (nearestScrollingContainer.length) {
|
||||
if (nearestScrollingContainer.is("body, html")) {
|
||||
blueslip.error(
|
||||
"Please wrap lists in an element with " +
|
||||
"'max-height' attribute.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (nearestScrollingContainer.css("max-height") !== "none") {
|
||||
break;
|
||||
}
|
||||
|
||||
nearestScrollingContainer = nearestScrollingContainer.parent();
|
||||
}
|
||||
|
||||
return nearestScrollingContainer;
|
||||
};
|
||||
|
||||
exports.scroll_delta = function (opts) {
|
||||
const elem_top = opts.elem_top;
|
||||
const container_height = opts.container_height;
|
||||
|
||||
Reference in New Issue
Block a user