scroll_util: Remove workaround for SimpleBar type issue fixed upstream.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-05-26 19:23:35 -07:00
parent e5ee43a1fb
commit a4256012ed
1 changed files with 3 additions and 7 deletions

View File

@ -1,5 +1,4 @@
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.
@ -7,9 +6,8 @@ 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: unknown = SimpleBar.instances.get(element); const sb = SimpleBar.instances.get(element);
if (sb) { if (sb) {
assert(sb instanceof SimpleBar); // https://github.com/Grsmto/simplebar/pull/689
return $(sb.getContentElement()!); return $(sb.getContentElement()!);
} }
return $element; return $element;
@ -22,9 +20,8 @@ export function get_scroll_element($element: JQueryOrZJQuery): JQuery {
} }
const element = $element.expectOne()[0]; const element = $element.expectOne()[0];
const sb: unknown = SimpleBar.instances.get(element); const sb = SimpleBar.instances.get(element);
if (sb) { if (sb) {
assert(sb instanceof SimpleBar); // https://github.com/Grsmto/simplebar/pull/689
return $(sb.getScrollElement()!); return $(sb.getScrollElement()!);
} else if ("simplebar" in element.dataset) { } else if ("simplebar" in element.dataset) {
// The SimpleBar mutation observer hasnt processed this element yet. // The SimpleBar mutation observer hasnt processed this element yet.
@ -36,9 +33,8 @@ 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: unknown = SimpleBar.instances.get(element); const sb = SimpleBar.instances.get(element);
if (sb) { if (sb) {
assert(sb instanceof SimpleBar); // https://github.com/Grsmto/simplebar/pull/689
sb.getScrollElement()!.scrollTop = 0; sb.getScrollElement()!.scrollTop = 0;
} else { } else {
element.scrollTop = 0; element.scrollTop = 0;