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

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 js error and scrolling 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..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;
},
« 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