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> = {
3333 * These items won't be removed when scroll. You can use css 'position:sticky' make them sticky.
3434 */
3535 persistentIndices ?: number [ ] , // index[]
36+ /**
37+ * Minimum distance for triggering a calculation when scrolling.
38+ */
39+ triggerDistance ?: number ,
3640 className ?: string ,
3741 style ?: React . CSSProperties ,
3842} & OptionalKeys < typeof defaultProps >
@@ -127,7 +131,9 @@ export const VirtualList = forwardRef(function <ITEM>(
127131 }
128132 setlistSize ( list . current ! . clientHeight )
129133 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+
131137 setscrollTop ( scrollTop2 )
132138 prevScrollTop . current = scrollTop2
133139 } else if ( scrollToIndexRef . current ) {
You can’t perform that action at this time.
0 commit comments