Revert "drafts: Use simplebar for scrollbar."

This reverts commit f3964673e7.

It broke drafts_scroll by confusing jQuery object APIs with DOM
element APIs.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-02-28 15:25:41 -08:00
parent f3964673e7
commit f244c2eca4
3 changed files with 6 additions and 9 deletions

View File

@ -26,7 +26,6 @@ import * as rendered_markdown from "./rendered_markdown";
import * as stream_data from "./stream_data";
import * as sub_store from "./sub_store";
import * as timerender from "./timerender";
import * as ui from "./ui";
import * as ui_util from "./ui_util";
import * as util from "./util";
@ -499,22 +498,21 @@ function drafts_scroll(next_focus_draft_row) {
}
activate_element(next_focus_draft_row[0].children[0]);
const scroll_element = ui.get_scroll_element($(".drafts-list"));
// If focused draft is first draft, scroll to the top.
if ($(".draft-info-box").first()[0].parentElement === next_focus_draft_row[0]) {
scroll_element.scrollTop = 0;
$(".drafts-list")[0].scrollTop = 0;
}
// If focused draft is the last draft, scroll to the bottom.
if ($(".draft-info-box").last()[0].parentElement === next_focus_draft_row[0]) {
scroll_element.scrollTop = scroll_element.scrollHeight - scroll_element.height();
$(".drafts-list")[0].scrollTop =
$(".drafts-list")[0].scrollHeight - $(".drafts-list").height();
}
// If focused draft is cut off from the top, scroll up halfway in draft modal.
if (next_focus_draft_row.position().top < 55) {
// 55 is the minimum distance from the top that will require extra scrolling.
scroll_element.scrollTop -= scroll_element.clientHeight / 2;
$(".drafts-list")[0].scrollTop -= $(".drafts-list")[0].clientHeight / 2;
}
// If focused draft is cut off from the bottom, scroll down halfway in draft modal.
@ -523,7 +521,7 @@ function drafts_scroll(next_focus_draft_row) {
const dist_from_bottom = $(".drafts-container")[0].clientHeight - total_dist;
if (dist_from_bottom < -4) {
// -4 is the min dist from the bottom that will require extra scrolling.
scroll_element.scrollTop += scroll_element.clientHeight / 2;
$(".drafts-list")[0].scrollTop += $(".drafts-list")[0].clientHeight / 2;
}
}

View File

@ -52,7 +52,6 @@
.drafts-list {
padding: 10px 0;
overflow: auto;
height: 100%;
.no-drafts {
display: block;

View File

@ -14,7 +14,7 @@
{{t "Pro tip: You can use 'd' to open your drafts."}}
</div>
</div>
<div class="drafts-list" data-simplebar>
<div class="drafts-list">
<div class="no-drafts">
{{t 'No drafts.'}}
</div>