1
- import { clearTimeout , setTimeout } from 'timers' ;
2
-
3
1
function getInternetExplorerVersion ( ) {
4
2
var ua = window . navigator . userAgent ;
5
3
@@ -216,6 +214,10 @@ var Scroller = {
216
214
type : [ Number , String ] ,
217
215
default : null
218
216
} ,
217
+ minItemHeight : {
218
+ type : [ Number , String ] ,
219
+ default : null
220
+ } ,
219
221
heightField : {
220
222
type : String ,
221
223
default : 'height'
@@ -251,14 +253,17 @@ var Scroller = {
251
253
heights : function heights ( ) {
252
254
if ( this . itemHeight === null ) {
253
255
var heights = {
254
- '-1' : 0
256
+ '-1' : { accumulator : 0 }
255
257
} ;
256
258
var items = this . items ;
257
259
var field = this . heightField ;
260
+ var minItemHeight = this . minItemHeight ;
258
261
var accumulator = 0 ;
262
+ var current = void 0 ;
259
263
for ( var i = 0 , l = items . length ; i < l ; i ++ ) {
260
- accumulator += items [ i ] [ field ] ;
261
- heights [ i ] = accumulator ;
264
+ current = items [ i ] [ field ] || minItemHeight ;
265
+ accumulator += current ;
266
+ heights [ i ] = { accumulator : accumulator , height : current } ;
262
267
}
263
268
return heights ;
264
269
}
@@ -323,7 +328,7 @@ var Scroller = {
323
328
scrollToItem : function scrollToItem ( index ) {
324
329
var scrollTop = void 0 ;
325
330
if ( this . itemHeight === null ) {
326
- scrollTop = index > 0 ? this . heights [ index - 1 ] : 0 ;
331
+ scrollTop = index > 0 ? this . heights [ index - 1 ] . accumulator : 0 ;
327
332
} else {
328
333
scrollTop = index * this . itemHeight ;
329
334
}
@@ -486,10 +491,10 @@ var VirtualScroller = { render: function render() {
486
491
// Searching for startIndex
487
492
do {
488
493
oldI = i ;
489
- h = heights [ i ] ;
494
+ h = heights [ i ] . accumulator ;
490
495
if ( h < scrollTop ) {
491
496
a = i ;
492
- } else if ( i < l && heights [ i + 1 ] > scrollTop ) {
497
+ } else if ( i < l && heights [ i + 1 ] . accumulator > scrollTop ) {
493
498
b = i ;
494
499
}
495
500
i = ~ ~ ( ( a + b ) / 2 ) ;
@@ -498,11 +503,11 @@ var VirtualScroller = { render: function render() {
498
503
startIndex = i ;
499
504
500
505
// For containers style
501
- offsetTop = i > 0 ? heights [ i - 1 ] : 0 ;
502
- containerHeight = heights [ l - 1 ] ;
506
+ offsetTop = i > 0 ? heights [ i - 1 ] . accumulator : 0 ;
507
+ containerHeight = heights [ l - 1 ] . accumulator ;
503
508
504
509
// Searching for endIndex
505
- for ( endIndex = i ; endIndex < l && heights [ endIndex ] < scrollBottom ; endIndex ++ ) { }
510
+ for ( endIndex = i ; endIndex < l && heights [ endIndex ] . accumulator < scrollBottom ; endIndex ++ ) { }
506
511
if ( endIndex === - 1 ) {
507
512
endIndex = items . length - 1 ;
508
513
} else {
@@ -594,8 +599,8 @@ var RecycleList = { render: function render() {
594
599
var _vm = this ; var _h = _vm . $createElement ; var _c = _vm . _self . _c || _h ; return _c ( 'div' , { directives : [ { name : "observe-visibility" , rawName : "v-observe-visibility" , value : _vm . handleVisibilityChange , expression : "handleVisibilityChange" } ] , staticClass : "recycle-list" , class : _vm . cssClass , on : { "&scroll" : function scroll ( $event ) {
595
600
_vm . handleScroll ( $event ) ;
596
601
} } } , [ _c ( 'div' , { staticClass : "item-wrapper" , style : { height : _vm . totalHeight + 'px' } } , _vm . _l ( _vm . pool , function ( view ) {
597
- return _c ( 'div' , { key : view . nr . id , staticClass : "item-view" , style : { transform : 'translateY(' + view . top + 'px)' } } , [ _vm . _t ( "default" , null , { item : view . item } ) ] , 2 ) ;
598
- } ) ) , _vm . _v ( " " ) , _c ( 'resize-observer' , { on : { "notify" : _vm . handleResize } } ) ] , 1 ) ;
602
+ return _c ( 'div' , { key : view . nr . id , staticClass : "item-view" , style : { transform : 'translateY(' + view . top + 'px)' } } , [ _vm . _t ( "default" , null , { item : view . item , active : view . nr . used } ) ] , 2 ) ;
603
+ } ) ) , _vm . _v ( " " ) , _vm . _t ( "after-container" ) , _vm . _v ( " " ) , _c ( 'resize-observer' , { on : { "notify" : _vm . handleResize } } ) ] , 2 ) ;
599
604
} , staticRenderFns : [ ] , _scopeId : 'data-v-2277f571' ,
600
605
name : 'RecycleList' ,
601
606
@@ -630,10 +635,15 @@ var RecycleList = { render: function render() {
630
635
checkItem : false
631
636
} ) ;
632
637
} ,
633
- heights : function heights ( ) {
634
- this . updateVisibleItems ( {
635
- checkItem : false
636
- } ) ;
638
+
639
+ heights : {
640
+ handler : function handler ( ) {
641
+ this . updateVisibleItems ( {
642
+ checkItem : false
643
+ } ) ;
644
+ } ,
645
+
646
+ deep : true
637
647
}
638
648
} ,
639
649
@@ -691,7 +701,7 @@ var RecycleList = { render: function render() {
691
701
unusedPool . push ( view ) ;
692
702
if ( ! fake ) {
693
703
view . nr . used = false ;
694
- view . top = this . totalHeight ;
704
+ view . top = - 9999 ;
695
705
this . $_views . delete ( view . item ) ;
696
706
}
697
707
} ,
@@ -768,10 +778,10 @@ var RecycleList = { render: function render() {
768
778
// Searching for startIndex
769
779
do {
770
780
oldI = i ;
771
- h = heights [ i ] ;
781
+ h = heights [ i ] . accumulator ;
772
782
if ( h < scroll . top ) {
773
783
a = i ;
774
- } else if ( i < count && heights [ i + 1 ] > scroll . top ) {
784
+ } else if ( i < count && heights [ i + 1 ] . accumulator > scroll . top ) {
775
785
b = i ;
776
786
}
777
787
i = ~ ~ ( ( a + b ) / 2 ) ;
@@ -780,10 +790,10 @@ var RecycleList = { render: function render() {
780
790
startIndex = i ;
781
791
782
792
// For container style
783
- totalHeight = heights [ count - 1 ] ;
793
+ totalHeight = heights [ count - 1 ] . accumulator ;
784
794
785
795
// Searching for endIndex
786
- for ( endIndex = i ; endIndex < count && heights [ endIndex ] < scroll . bottom ; endIndex ++ ) { }
796
+ for ( endIndex = i ; endIndex < count && heights [ endIndex ] . accumulator < scroll . bottom ; endIndex ++ ) { }
787
797
if ( endIndex === - 1 ) {
788
798
endIndex = items . length - 1 ;
789
799
} else {
@@ -847,6 +857,11 @@ var RecycleList = { render: function render() {
847
857
item = items [ _i3 ] ;
848
858
view = views . get ( item ) ;
849
859
860
+ if ( ! itemHeight && ! heights [ _i3 ] . height ) {
861
+ if ( view ) this . unuseView ( view ) ;
862
+ continue ;
863
+ }
864
+
850
865
// No view assigned to item
851
866
if ( ! view ) {
852
867
type = item [ typeField ] ;
@@ -887,7 +902,7 @@ var RecycleList = { render: function render() {
887
902
888
903
// Update position
889
904
if ( itemHeight === null ) {
890
- view . top = heights [ _i3 - 1 ] ;
905
+ view . top = heights [ _i3 - 1 ] . accumulator ;
891
906
} else {
892
907
view . top = _i3 * itemHeight ;
893
908
}
@@ -912,7 +927,7 @@ function registerComponents(Vue, prefix) {
912
927
913
928
var plugin$4 = {
914
929
// eslint-disable-next-line no-undef
915
- version : "0.11.1 " ,
930
+ version : "0.11.2 " ,
916
931
install : function install ( Vue , options ) {
917
932
var finalOptions = Object . assign ( { } , {
918
933
installComponents : true ,
0 commit comments