@@ -48,7 +48,7 @@ export default class VirtualList extends Component {
48
48
*/
49
49
itemSizeGetter : PropTypes . func ,
50
50
/**
51
- * 设置跳转位置,需要设置 itemSizeGetter 才能生效
51
+ * 设置跳转位置,需要设置 itemSizeGetter 才能生效, 不设置认为元素等高并取第一个元素高度作为默认高
52
52
*/
53
53
jumpIndex : PropTypes . number ,
54
54
className : PropTypes . string
@@ -153,7 +153,7 @@ export default class VirtualList extends Component {
153
153
el = el . parentElement ;
154
154
155
155
switch ( window . getComputedStyle ( el ) . overflowY ) {
156
- case 'auto' : case 'scroll' : case 'overlay' : return el ;
156
+ case 'auto' : case 'scroll' : case 'overlay' : case 'visible' : return el ;
157
157
}
158
158
159
159
return window ;
@@ -338,14 +338,24 @@ export default class VirtualList extends Component {
338
338
339
339
getSizeOf ( index ) {
340
340
const { cache } = this ;
341
- const { itemSizeGetter } = this . props ;
341
+ const { itemSizeGetter, jumpIndex } = this . props ;
342
+
342
343
// Try the cache.
343
344
if ( index in cache ) {
344
345
return cache [ index ] ;
345
346
}
346
347
if ( itemSizeGetter ) {
347
348
return itemSizeGetter ( index ) ;
348
349
}
350
+
351
+ const height = Object . values ( this . cache ) . pop ( ) ;
352
+ if ( ! this . defaultItemHeight && jumpIndex > - 1 && height ) {
353
+ this . defaultItemHeight = height ;
354
+ }
355
+
356
+ if ( this . defaultItemHeight ) {
357
+ return this . defaultItemHeight ;
358
+ }
349
359
}
350
360
351
361
constrain ( from , size , { children, minSize} ) {
0 commit comments