Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1365)

Unified Diff: chrome/browser/resources/ntp4/tile_page.js

Issue 7312016: ntp4: small followup to r91606 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/tile_page.js
diff --git a/chrome/browser/resources/ntp4/tile_page.js b/chrome/browser/resources/ntp4/tile_page.js
index dbea9be03b8e2b2145dba07eb92e4129b01b5086..4c6c0493afc2dd5fa79579bc386727225f780919 100644
--- a/chrome/browser/resources/ntp4/tile_page.js
+++ b/chrome/browser/resources/ntp4/tile_page.js
@@ -257,7 +257,7 @@ cr.define('ntp4', function() {
if (this.firstChild.classList.contains('new-tile-contents'))
this.firstChild.classList.remove('new-tile-contents');
else if (this.firstChild.classList.contains('removing-tile-contents'))
- this.parentNode.removeChild(this);
+ this.tilePage.removeTile(this);
},
};
@@ -451,7 +451,8 @@ cr.define('ntp4', function() {
* Adds the given element to the tile grid.
* @param {Node} tileElement The tile object/node to insert.
* @param {number} index The location in the tile grid to insert it at.
- * @param {?boolean} animate If true, the add will be animated.
+ * @param {?boolean} animate If true, the tile in question will be animated
+ * (other tiles, if they must reposition, do not animate).
* @protected
*/
addTileAt: function(tileElement, index, animate) {
@@ -471,6 +472,21 @@ cr.define('ntp4', function() {
},
/**
+ * Removes the given tile and animates the respositioning of the other
+ * tiles.
+ * @param {HTMLElement} tile The tile to remove from |tileGrid_|.
+ */
+ removeTile: function(tile) {
+ this.classList.add('animating-tile-page');
+ var index = Array.prototype.indexOf.call(this.tileElements_, tile);
+ tile.parentNode.removeChild(tile);
+ this.calculateLayoutValues_();
+ for (var i = index; i < this.tileElements_.length; i++) {
+ this.positionTile_(i);
+ }
+ },
+
+ /**
* Makes some calculations for tile layout. These change depending on
* height, width, and the number of tiles.
* @private
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698