@@ -50,6 +50,10 @@ export const defaultProps = {
50
50
* The visible space of the list. It is only used before DOM created(SSR).
51
51
*/
52
52
listSize : 1000 ,
53
+ /**
54
+ * Whether to enable the virtual list feature.
55
+ */
56
+ virtual : true ,
53
57
}
54
58
55
59
export interface VirtualListHandle {
@@ -72,7 +76,7 @@ export const VirtualList = forwardRef(function <ITEM>(
72
76
const [ scrollTop , setscrollTop ] = useState ( 0 ) ;
73
77
const [ listSize , setlistSize ] = useState ( props . listSize ! ) ;
74
78
const [ forceRerender , setforceRerender ] = useState ( [ ] ) ; // change value to force rerender
75
- const ignoreScrollOnce = useRef ( false ) ;
79
+ const ignoreUpdateScrollTopOnce = useRef ( false ) ;
76
80
//
77
81
const totalSpace = itemSize * count
78
82
let topSpace = scrollTop - buffer
@@ -144,8 +148,8 @@ export const VirtualList = forwardRef(function <ITEM>(
144
148
145
149
setlistSize ( list . current ! . clientHeight )
146
150
147
- if ( ignoreScrollOnce . current ) {
148
- ignoreScrollOnce . current = false
151
+ if ( ignoreUpdateScrollTopOnce . current ) {
152
+ ignoreUpdateScrollTopOnce . current = false
149
153
} else {
150
154
const scrollTop = list . current ! . scrollTop ;
151
155
if ( Math . abs ( prevScrollTop . current - scrollTop ) > ( props . triggerDistance ?? itemSize ) ) {
@@ -183,7 +187,7 @@ export const VirtualList = forwardRef(function <ITEM>(
183
187
if ( el ) {
184
188
// @ts -ignore
185
189
el . scrollIntoView ( { block } )
186
- ignoreScrollOnce . current = true
190
+ ignoreUpdateScrollTopOnce . current = true
187
191
}
188
192
}
189
193
} , [ shouldScrollToIndex ] )
0 commit comments