Index: chrome/browser/resources/ntp/apps.js |
diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js |
index db15e58c75b188582dd499538d6ffac6b26b64a2..71228ebaabcff890bc8044c72a39340a7c5a0301 100644 |
--- a/chrome/browser/resources/ntp/apps.js |
+++ b/chrome/browser/resources/ntp/apps.js |
@@ -367,7 +367,7 @@ var apps = (function() { |
var item = findAncestorByClass(e.target, 'app'); |
// You can't drag the web store launcher. |
- if (item.classList.contains('web-store-entry')) |
+ if (!item || item.classList.contains('web-store-entry')) |
Aaron Boodman
2011/01/24 19:22:42
Can the second half of this check happen now? If n
|
return null; |
return item; |
@@ -410,8 +410,10 @@ var apps = (function() { |
}, |
getIndexAt_: function(coordinates) { |
- var x = coordinates.x; |
- var y = coordinates.y; |
+ // We need to adjust for the page offsets because scrolling the window |
+ // actually scrolls the app section. |
+ var x = coordinates.x - window.pageXOffset; |
+ var y = coordinates.y - window.pageYOffset; |
var w = this.dimensions.width; |
var h = this.dimensions.height; |
@@ -422,6 +424,15 @@ var apps = (function() { |
var col = Math.floor(x / w); |
var index = Math.floor(availableWidth / w) * row + col; |
+ var appCount = this.data.length; |
+ var cols = MAX_APPS_PER_ROW[layoutMode]; |
+ var rows = Math.ceil(appCount / cols); |
+ |
+ // Rather than making the free space on the last row invalid, we |
+ // map it to the last valid position. |
+ if (index >= appCount && index < cols * rows) |
Aaron Boodman
2011/01/24 19:22:42
Cool. This was a good benefit of moving getIndexAt
|
+ return appCount-1; |
+ |
return index; |
}, |