@@ -50,6 +50,10 @@ export const defaultProps = {
5050 * The visible space of the list. It is only used before DOM created(SSR).
5151 */
5252 listSize : 1000 ,
53+ /**
54+ * Whether to enable the virtual list feature.
55+ */
56+ virtual : true ,
5357}
5458
5559export interface VirtualListHandle {
@@ -72,7 +76,7 @@ export const VirtualList = forwardRef(function <ITEM>(
7276 const [ scrollTop , setscrollTop ] = useState ( 0 ) ;
7377 const [ listSize , setlistSize ] = useState ( props . listSize ! ) ;
7478 const [ forceRerender , setforceRerender ] = useState ( [ ] ) ; // change value to force rerender
75- const ignoreScrollOnce = useRef ( false ) ;
79+ const ignoreUpdateScrollTopOnce = useRef ( false ) ;
7680 //
7781 const totalSpace = itemSize * count
7882 let topSpace = scrollTop - buffer
@@ -144,8 +148,8 @@ export const VirtualList = forwardRef(function <ITEM>(
144148
145149 setlistSize ( list . current ! . clientHeight )
146150
147- if ( ignoreScrollOnce . current ) {
148- ignoreScrollOnce . current = false
151+ if ( ignoreUpdateScrollTopOnce . current ) {
152+ ignoreUpdateScrollTopOnce . current = false
149153 } else {
150154 const scrollTop = list . current ! . scrollTop ;
151155 if ( Math . abs ( prevScrollTop . current - scrollTop ) > ( props . triggerDistance ?? itemSize ) ) {
@@ -183,7 +187,7 @@ export const VirtualList = forwardRef(function <ITEM>(
183187 if ( el ) {
184188 // @ts -ignore
185189 el . scrollIntoView ( { block } )
186- ignoreScrollOnce . current = true
190+ ignoreUpdateScrollTopOnce . current = true
187191 }
188192 }
189193 } , [ shouldScrollToIndex ] )
0 commit comments