File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ export type VirtualListProps<ITEM> = {
33
33
* These items won't be removed when scroll. You can use css 'position:sticky' make them sticky.
34
34
*/
35
35
persistentIndices ?: number [ ] , // index[]
36
+ /**
37
+ * Minimum distance for triggering a calculation when scrolling.
38
+ */
39
+ triggerDistance ?: number ,
36
40
className ?: string ,
37
41
style ?: React . CSSProperties ,
38
42
} & OptionalKeys < typeof defaultProps >
@@ -127,7 +131,9 @@ export const VirtualList = forwardRef(function <ITEM>(
127
131
}
128
132
setlistSize ( list . current ! . clientHeight )
129
133
const scrollTop2 = list . current ! . scrollTop
130
- if ( Math . abs ( prevScrollTop . current - scrollTop2 ) > itemSize ) {
134
+ if ( Math . abs ( prevScrollTop . current - scrollTop2 ) > ( props . triggerDistance ?? itemSize ) ) {
135
+ console . log ( 'triggerd' ) ;
136
+
131
137
setscrollTop ( scrollTop2 )
132
138
prevScrollTop . current = scrollTop2
133
139
} else if ( scrollToIndexRef . current ) {
You can’t perform that action at this time.
0 commit comments