File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -194,9 +194,12 @@ class List<T> extends React.Component<ListProps<T>, ListState> {
194
194
let bestStartIndex : number = null ;
195
195
let bestEndIndex : number = null ;
196
196
197
+ let missSimilarity = 0 ;
198
+
197
199
const scrollHeight = dataSource . length * itemHeight ;
198
200
const { clientHeight } = this . listRef . current ;
199
201
const maxScrollTop = scrollHeight - clientHeight ;
202
+
200
203
for ( let i = 0 ; i < maxScrollTop ; i += 1 ) {
201
204
const scrollTop = getIndexByStartLoc ( 0 , maxScrollTop , originScrollTop , i ) ;
202
205
@@ -240,8 +243,19 @@ class List<T> extends React.Component<ListProps<T>, ListState> {
240
243
bestItemOffsetPtg = itemOffsetPtg ;
241
244
bestStartIndex = startIndex ;
242
245
bestEndIndex = endIndex ;
246
+
247
+ missSimilarity = 0 ;
248
+ } else {
249
+ missSimilarity += 1 ;
243
250
}
244
251
}
252
+
253
+ // If keeping 10 times not match similarity,
254
+ // check more scrollTop is meaningless.
255
+ // Here boundary is set to 10.
256
+ if ( missSimilarity > 10 ) {
257
+ break ;
258
+ }
245
259
}
246
260
247
261
// 5. Re-scroll if has best scroll match
You can’t perform that action at this time.
0 commit comments