File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ import {
13
13
} from './utils/itemUtil' ;
14
14
import { getIndexByStartLoc , findListDiffIndex } from './utils/algorithmUtil' ;
15
15
16
+ const ScrollStyle = {
17
+ overflowY : 'auto' ,
18
+ overflowAnchor : 'none' ,
19
+ } ;
20
+
16
21
type RenderFunc < T > = (
17
22
item : T ,
18
23
index : number ,
@@ -437,22 +442,22 @@ class List<T> extends React.Component<ListProps<T>, ListState<T>> {
437
442
...restProps
438
443
} = this . props ;
439
444
440
- const mergedStyle = {
441
- ...style ,
442
- height,
443
- overflowY : 'auto' ,
444
- overflowAnchor : 'none' ,
445
- } ;
446
-
447
445
// Render pure list if not set height or height is enough for all items
448
446
if ( height === undefined || data . length * itemHeight <= height ) {
449
447
return (
450
- < Component style = { mergedStyle } { ...restProps } >
448
+ < Component style = { height ? { ... style , ... ScrollStyle } : style } { ...restProps } >
451
449
< Filler height = { height } > { this . renderChildren ( data , 0 , children ) } </ Filler >
452
450
</ Component >
453
451
) ;
454
452
}
455
453
454
+ // Use virtual list
455
+ const mergedStyle = {
456
+ ...style ,
457
+ height,
458
+ ...ScrollStyle ,
459
+ } ;
460
+
456
461
const { status, startIndex, endIndex, startItemTop } = this . state ;
457
462
const contentHeight = data . length * itemHeight * ITEM_SCALE_RATE ;
458
463
You can’t perform that action at this time.
0 commit comments