mirror of https://github.com/zulip/zulip.git
ui.get_scroll_element: Set up SimpleBar if it’s expected but missing.
Although SimpleBar automatically sets itself up on elements with a `data-simplebar` attribute, sometimes we try to set event listeners before that happens. Create the SimpleBar early in that case. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
48526b1fd6
commit
f0e0fe1c15
|
@ -16,6 +16,7 @@ function init_simulated_scrolling() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var elem = {
|
var elem = {
|
||||||
|
dataset: {},
|
||||||
scrollTop: 0,
|
scrollTop: 0,
|
||||||
scrollHeight: 0,
|
scrollHeight: 0,
|
||||||
};
|
};
|
||||||
|
|
|
@ -340,6 +340,9 @@ run_test('zoom_in_and_zoom_out', () => {
|
||||||
f.call(elem(stream_li1));
|
f.call(elem(stream_li1));
|
||||||
f.call(elem(stream_li2));
|
f.call(elem(stream_li2));
|
||||||
};
|
};
|
||||||
|
$('#stream-filters-container')[0] = {
|
||||||
|
dataset: {},
|
||||||
|
};
|
||||||
stream_list.set_event_handlers();
|
stream_list.set_event_handlers();
|
||||||
|
|
||||||
stream_list.zoom_in_topics({stream_id: 42});
|
stream_list.zoom_in_topics({stream_id: 42});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var ui = (function () {
|
var ui = (function () {
|
||||||
|
|
||||||
require("simplebar");
|
var SimpleBar = require("simplebar").default;
|
||||||
|
|
||||||
var exports = {};
|
var exports = {};
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ exports.get_scroll_element = function (element_selector) {
|
||||||
var element = element_selector.expectOne()[0];
|
var element = element_selector.expectOne()[0];
|
||||||
if (element.SimpleBar) {
|
if (element.SimpleBar) {
|
||||||
return $(element.SimpleBar.getScrollElement());
|
return $(element.SimpleBar.getScrollElement());
|
||||||
|
} else if ('simplebar' in element.dataset) {
|
||||||
|
// The SimpleBar mutation observer hasn’t processed this element yet.
|
||||||
|
// Create the SimpleBar early in case we need to add event listeners.
|
||||||
|
return $(new SimpleBar(element).getScrollElement());
|
||||||
}
|
}
|
||||||
return element_selector;
|
return element_selector;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue