mirror of https://github.com/zulip/zulip.git
scroll_util: Fix implicit use of any.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
897dffa598
commit
bde758c8ae
|
@ -1,4 +1,5 @@
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
|
import assert from "minimalistic-assert";
|
||||||
import SimpleBar from "simplebar";
|
import SimpleBar from "simplebar";
|
||||||
|
|
||||||
// This type is helpful for testing, where we may have a dummy object instead of an actual jquery object.
|
// This type is helpful for testing, where we may have a dummy object instead of an actual jquery object.
|
||||||
|
@ -6,9 +7,10 @@ type JQueryOrZJQuery = {__zjquery?: true} & JQuery;
|
||||||
|
|
||||||
export function get_content_element($element: JQuery): JQuery {
|
export function get_content_element($element: JQuery): JQuery {
|
||||||
const element = $element.expectOne()[0];
|
const element = $element.expectOne()[0];
|
||||||
const sb = SimpleBar.instances.get(element);
|
const sb: unknown = SimpleBar.instances.get(element);
|
||||||
if (sb) {
|
if (sb) {
|
||||||
return $(sb.getContentElement());
|
assert(sb instanceof SimpleBar); // https://github.com/Grsmto/simplebar/pull/689
|
||||||
|
return $(sb.getContentElement()!);
|
||||||
}
|
}
|
||||||
return $element;
|
return $element;
|
||||||
}
|
}
|
||||||
|
@ -20,9 +22,10 @@ export function get_scroll_element($element: JQueryOrZJQuery): JQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
const element = $element.expectOne()[0];
|
const element = $element.expectOne()[0];
|
||||||
const sb = SimpleBar.instances.get(element);
|
const sb: unknown = SimpleBar.instances.get(element);
|
||||||
if (sb) {
|
if (sb) {
|
||||||
return $(sb.getScrollElement());
|
assert(sb instanceof SimpleBar); // https://github.com/Grsmto/simplebar/pull/689
|
||||||
|
return $(sb.getScrollElement()!);
|
||||||
} else if ("simplebar" in element.dataset) {
|
} else if ("simplebar" in element.dataset) {
|
||||||
// The SimpleBar mutation observer hasn’t processed this element yet.
|
// The SimpleBar mutation observer hasn’t processed this element yet.
|
||||||
// Create the SimpleBar early in case we need to add event listeners.
|
// Create the SimpleBar early in case we need to add event listeners.
|
||||||
|
@ -33,9 +36,10 @@ export function get_scroll_element($element: JQueryOrZJQuery): JQuery {
|
||||||
|
|
||||||
export function reset_scrollbar($element: JQuery): void {
|
export function reset_scrollbar($element: JQuery): void {
|
||||||
const element = $element.expectOne()[0];
|
const element = $element.expectOne()[0];
|
||||||
const sb = SimpleBar.instances.get(element);
|
const sb: unknown = SimpleBar.instances.get(element);
|
||||||
if (sb) {
|
if (sb) {
|
||||||
sb.getScrollElement().scrollTop = 0;
|
assert(sb instanceof SimpleBar); // https://github.com/Grsmto/simplebar/pull/689
|
||||||
|
sb.getScrollElement()!.scrollTop = 0;
|
||||||
} else {
|
} else {
|
||||||
element.scrollTop = 0;
|
element.scrollTop = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue