@@ -157,8 +157,12 @@ function GridListDirective($interpolate, $mdConstant, $mdGridLayout, $mdMedia) {
157157 /**
158158 * Invokes the layout engine, and uses its results to lay out our
159159 * tile elements.
160+ *
161+ * @param {boolean } tilesAdded Whether tiles have been added since the last
162+ * layout. This is to avoid situations where tiles are replaced with
163+ * properties identical to their removed counterparts.
160164 */
161- function layoutDelegate ( ) {
165+ function layoutDelegate ( tilesAdded ) {
162166 var props = {
163167 tileSpans : getTileSpans ( ) ,
164168 colCount : getColumnCount ( ) ,
@@ -167,7 +171,7 @@ function GridListDirective($interpolate, $mdConstant, $mdGridLayout, $mdMedia) {
167171 gutter : getGutter ( )
168172 } ;
169173
170- if ( angular . equals ( props , lastLayoutProps ) ) {
174+ if ( ! tilesAdded && angular . equals ( props , lastLayoutProps ) ) {
171175 return ;
172176 }
173177
@@ -407,6 +411,7 @@ function GridListDirective($interpolate, $mdConstant, $mdGridLayout, $mdMedia) {
407411/* @ngInject */
408412function GridListController ( $timeout ) {
409413 this . invalidated = false ;
414+ this . tilesAdded = false ;
410415 this . $timeout_ = $timeout ;
411416 this . tiles = [ ] ;
412417 this . layoutDelegate = angular . noop ;
@@ -420,6 +425,7 @@ GridListController.prototype = {
420425 } else {
421426 this . tiles . splice ( idx , 0 , tile ) ;
422427 }
428+ this . tilesAdded = true ;
423429 this . invalidateLayout ( ) ;
424430 } ,
425431
@@ -442,9 +448,10 @@ GridListController.prototype = {
442448
443449 layout : function ( ) {
444450 try {
445- this . layoutDelegate ( ) ;
451+ this . layoutDelegate ( this . tilesAdded ) ;
446452 } finally {
447453 this . invalidated = false ;
454+ this . tilesAdded = false ;
448455 }
449456 } ,
450457
0 commit comments