@@ -1162,10 +1162,18 @@ var DynamicScroller = { render: function render() {
1162
1162
for ( var i = 0 ; i < items . length ; i ++ ) {
1163
1163
var item = items [ i ] ;
1164
1164
var id = item [ keyField ] ;
1165
+ var height = heights [ id ] ;
1166
+ if ( typeof height === 'undefined' && ! this . $_undefinedMap [ id ] ) {
1167
+ // eslint-disable-next-line vue/no-side-effects-in-computed-properties
1168
+ this . $_undefinedHeights ++ ;
1169
+ // eslint-disable-next-line vue/no-side-effects-in-computed-properties
1170
+ this . $_undefinedMap [ id ] = true ;
1171
+ height = 0 ;
1172
+ }
1165
1173
result . push ( {
1166
1174
item : item ,
1167
1175
id : id ,
1168
- height : heights [ id ] || 0
1176
+ height : height
1169
1177
} ) ;
1170
1178
}
1171
1179
return result ;
@@ -1182,11 +1190,15 @@ var DynamicScroller = { render: function render() {
1182
1190
} ,
1183
1191
1184
1192
watch : {
1185
- items : 'forceUpdate'
1193
+ items : function items ( ) {
1194
+ this . forceUpdate ( false ) ;
1195
+ }
1186
1196
} ,
1187
1197
1188
1198
created : function created ( ) {
1189
1199
this . $_updates = [ ] ;
1200
+ this . $_undefinedHeights = 0 ;
1201
+ this . $_undefinedMap = { } ;
1190
1202
} ,
1191
1203
mounted : function mounted ( ) {
1192
1204
var scroller = this . $refs . scroller ;
@@ -1214,7 +1226,9 @@ var DynamicScroller = { render: function render() {
1214
1226
this . $emit ( 'visible' ) ;
1215
1227
} ,
1216
1228
forceUpdate : function forceUpdate ( ) {
1217
- this . vscrollData . heights = { } ;
1229
+ var clear = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : true ;
1230
+
1231
+ if ( clear ) this . vscrollData . heights = { } ;
1218
1232
this . $emit ( 'vscroll:update' , { force : true } ) ;
1219
1233
} ,
1220
1234
getSize : function getSize ( scroller ) {
@@ -1223,6 +1237,30 @@ var DynamicScroller = { render: function render() {
1223
1237
scrollToItem : function scrollToItem ( index ) {
1224
1238
var scroller = this . $refs . scroller ;
1225
1239
if ( scroller ) scroller . scrollToItem ( index ) ;
1240
+ } ,
1241
+ getItemSize : function getItemSize ( item ) {
1242
+ var id = item [ this . keyField ] ;
1243
+ return this . vscrollData . heights [ id ] || 0 ;
1244
+ } ,
1245
+ scrollToBottom : function scrollToBottom ( ) {
1246
+ var _this = this ;
1247
+
1248
+ if ( this . $_scrollingToBottom ) return ;
1249
+ this . $_scrollingToBottom = true ;
1250
+ var el = this . $el ;
1251
+ // Item is inserted to the DOM
1252
+ this . $nextTick ( function ( ) {
1253
+ // Item sizes are computed
1254
+ var cb = function cb ( ) {
1255
+ el . scrollTop = el . scrollHeight ;
1256
+ if ( _this . $_undefinedHeights === 0 ) {
1257
+ _this . $_scrollingToBottom = false ;
1258
+ } else {
1259
+ requestAnimationFrame ( cb ) ;
1260
+ }
1261
+ } ;
1262
+ requestAnimationFrame ( cb ) ;
1263
+ } ) ;
1226
1264
}
1227
1265
}
1228
1266
} ;
@@ -1372,6 +1410,10 @@ var DynamicScrollerItem = {
1372
1410
if ( _this3 . id === id ) {
1373
1411
var size = _this3 . getSize ( ) ;
1374
1412
if ( size . height && _this3 . height !== size . height ) {
1413
+ if ( _this3 . vscrollBus . $_undefinedMap [ id ] ) {
1414
+ _this3 . vscrollBus . $_undefinedHeights -- ;
1415
+ _this3 . vscrollBus . $_undefinedMap [ id ] = undefined ;
1416
+ }
1375
1417
_this3 . $set ( _this3 . vscrollData . heights , _this3 . id , size . height ) ;
1376
1418
if ( _this3 . emitResize ) _this3 . $emit ( 'resize' , _this3 . id ) ;
1377
1419
}
@@ -1488,7 +1530,7 @@ function registerComponents(Vue$$1, prefix) {
1488
1530
1489
1531
var plugin = {
1490
1532
// eslint-disable-next-line no-undef
1491
- version : "1.0.0-beta.4 " ,
1533
+ version : "1.0.0-beta.5 " ,
1492
1534
install : function install ( Vue$$1 , options ) {
1493
1535
var finalOptions = Object . assign ( { } , {
1494
1536
installComponents : true ,
0 commit comments