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

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

Issue 7461148: ntp4: fix some bugs that appeared when I changed the margin size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 c2dcaa5fcc1c8fe08f1c20e50c8e2ed92cdf919a..829512cf553ef9c0086b1ad8e92f15ea429aea63 100644
--- a/chrome/browser/resources/ntp4/tile_page.js
+++ b/chrome/browser/resources/ntp4/tile_page.js
@@ -391,7 +391,7 @@ cr.define('ntp4', function() {
this.tileGrid_ = this.ownerDocument.createElement('div');
this.tileGrid_.className = 'tile-grid';
this.tileGrid_.style.minWidth = (this.gridValues_.minColCount *
- this.gridValues_.minTileWidth) + 'px';
+ tileWidthFraction(this.gridValues_.minTileWidth)) + 'px';
this.content_.appendChild(this.tileGrid_);
// Ordered list of our tiles.
@@ -612,24 +612,26 @@ cr.define('ntp4', function() {
* that this function doesn't care where the tiles actually are, and will
* return an index even for the space between two tiles. This function is
* effectively the inverse of |positionTile_|.
- * @param {number} x The x coordinate, in pixels, relative to the top left
- * of tileGrid_.
- * @param {number} y The y coordinate.
+ * @param {number} x The x coordinate, in pixels, relative to the left of
+ * |this|.
+ * @param {number} y The y coordinate, in pixels, relative to the top of
+ * |this|.
* @private
*/
getWouldBeIndexForPoint_: function(x, y) {
var grid = this.gridValues_;
var layout = this.layoutValues_;
- var col = Math.floor((x - layout.leftMargin) / layout.colWidth);
+ var gridClientRect = this.tileGrid_.getBoundingClientRect();
+ var col = Math.floor((x - gridClientRect.left - layout.leftMargin) /
+ layout.colWidth);
if (col < 0 || col >= layout.numRowTiles)
return -1;
if (ntp4.isRTL())
col = layout.numRowTiles - 1 - col;
- var row = Math.floor(
- (y - this.tileGrid_.getBoundingClientRect().top) / layout.rowHeight);
+ var row = Math.floor((y - gridClientRect.top) / layout.rowHeight);
return row * layout.numRowTiles + col;
},
« 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