@@ -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