Skip to content

Commit 15508a1

Browse files
committed
refactor: 撤销滚动逻辑
1 parent d053870 commit 15508a1

File tree

2 files changed

+2
-39
lines changed

2 files changed

+2
-39
lines changed

src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ protected override async Task OnParametersSetAsync()
366366
_shouldRender = true;
367367

368368
_rows = null;
369-
_keyboardArrowUpDownTrigger = true;
370369
}
371370

372371
if (ShowCheckbox && (AutoCheckParent || AutoCheckChildren))

src/BootstrapBlazor/Components/TreeView/TreeView.razor.js

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,44 +28,11 @@ export function init(id, options) {
2828
});
2929
}
3030

31-
const scrollIntoView = (el, options) => {
32-
if (el) {
33-
el.scrollIntoView(options ?? { behavior: 'smooth', block: 'nearest', inline: 'start' });
34-
}
35-
}
36-
37-
const virtualScroll = (el, options) => {
38-
const searchHeight = el.querySelector('.tree-search')?.offsetHeight ?? 0;
39-
40-
el.scrollHandler = setInterval(() => {
41-
const item = el.querySelector(".tree-content.active");
42-
const root = el.querySelector(".is-virtual");
43-
if (item) {
44-
clearInterval(el.scrollHandler);
45-
scrollIntoView(item, options);
46-
return;
47-
}
48-
49-
const top = el.scrollTop + el.offsetHeight - searchHeight;
50-
if (top < root.offsetHeight) {
51-
el.scrollTo({ top: top, left: 0, behavior: "smooth" });
52-
}
53-
else {
54-
clearInterval(el.scrollHandler);
55-
}
56-
}, 80);
57-
}
58-
59-
export function scroll(id, options, find = false) {
31+
export function scroll(id, options) {
6032
const el = document.getElementById(id);
61-
6233
const item = el.querySelector(".tree-content.active");
6334
if (item) {
64-
scrollIntoView(el, options);
65-
return;
66-
}
67-
if (find) {
68-
virtualScroll(el, options);
35+
item.scrollIntoView(options ?? { behavior: 'smooth', block: 'nearest', inline: 'start' });
6936
}
7037
}
7138

@@ -146,8 +113,5 @@ export function dispose(id) {
146113

147114
if (el) {
148115
EventHandler.off(el, 'keyup', '.tree-root');
149-
if (el.scrollHandler) {
150-
clearInterval(el.scrollHandler);
151-
}
152116
}
153117
}

0 commit comments

Comments
 (0)