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

Unified Diff: chrome/browser/resources/ntp/apps.js

Issue 6264012: [NTP] Tweak app drag and drop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/resources
Patch Set: fix another scrolling issue Created 9 years, 11 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 | « chrome/browser/resources/ntp/apps.css ('k') | chrome/browser/resources/ntp/drag_drop_controller.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..89eb8bb9e6c8268fc1718e0804b2c7e8a8cf1109 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'))
return null;
return item;
@@ -410,18 +410,24 @@ var apps = (function() {
},
getIndexAt_: function(coordinates) {
- var x = coordinates.x;
- var y = coordinates.y;
-
var w = this.dimensions.width;
var h = this.dimensions.height;
var availableWidth = this.dragContainer.offsetWidth;
- var row = Math.floor(y / h);
- var col = Math.floor(x / w);
+ var row = Math.floor(coordinates.y / h);
+ var col = Math.floor(coordinates.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)
+ return appCount-1;
+
return index;
},
« no previous file with comments | « chrome/browser/resources/ntp/apps.css ('k') | chrome/browser/resources/ntp/drag_drop_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698