@@ -183,7 +183,7 @@ VirtualRepeatContainerController.prototype.getSize = function() {
183
183
/**
184
184
* Resizes the container.
185
185
* @private
186
- * @param {number } The new size to set.
186
+ * @param {number } size The new size to set.
187
187
*/
188
188
VirtualRepeatContainerController . prototype . setSize_ = function ( size ) {
189
189
var dimension = this . getDimensionName_ ( ) ;
@@ -201,6 +201,7 @@ VirtualRepeatContainerController.prototype.unsetSize_ = function() {
201
201
202
202
/** Instructs the container to re-measure its size. */
203
203
VirtualRepeatContainerController . prototype . updateSize = function ( ) {
204
+ // If the original size is already determined, we can skip the update.
204
205
if ( this . originalSize ) return ;
205
206
206
207
this . size = this . isHorizontal ( )
@@ -274,22 +275,35 @@ VirtualRepeatContainerController.prototype.sizeScroller_ = function(size) {
274
275
*/
275
276
VirtualRepeatContainerController . prototype . autoShrink_ = function ( size ) {
276
277
var shrinkSize = Math . max ( size , this . autoShrinkMin * this . repeater . getItemSize ( ) ) ;
278
+
277
279
if ( this . autoShrink && shrinkSize !== this . size ) {
278
280
if ( this . oldElementSize === null ) {
279
281
this . oldElementSize = this . $element [ 0 ] . style [ this . getDimensionName_ ( ) ] ;
280
282
}
281
283
282
284
var currentSize = this . originalSize || this . size ;
285
+
283
286
if ( ! currentSize || shrinkSize < currentSize ) {
284
287
if ( ! this . originalSize ) {
285
288
this . originalSize = this . size ;
286
289
}
287
290
291
+ // Now we update the containers size, because shrinking is enabled.
288
292
this . setSize_ ( shrinkSize ) ;
289
293
} else if ( this . originalSize !== null ) {
294
+ // Set the size back to our initial size.
290
295
this . unsetSize_ ( ) ;
296
+
297
+ var _originalSize = this . originalSize ;
291
298
this . originalSize = null ;
292
- this . updateSize ( ) ;
299
+
300
+ // We determine the repeaters size again, if the original size was zero.
301
+ // The originalSize needs to be null, to be able to determine the size.
302
+ if ( ! _originalSize ) this . updateSize ( ) ;
303
+
304
+ // Apply the original size or the determined size back to the container, because
305
+ // it has been overwritten before, in the shrink block.
306
+ this . setSize_ ( _originalSize || this . size ) ;
293
307
}
294
308
295
309
this . repeater . containerUpdated ( ) ;
0 commit comments