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

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/file_grid.js

Issue 1034443002: Files.app: Calculate the hit elements on drag-selection correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 5 years, 9 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 | « ui/file_manager/file_manager/foreground/css/file_manager.css ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/ui/file_grid.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/file_grid.js b/ui/file_manager/file_manager/foreground/js/ui/file_grid.js
index 7a05e83619df3a1aaefd353001559ff632cb3f27..ac0368916e02b4944c714c4138299d2010c1c65c 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/file_grid.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/file_grid.js
@@ -72,6 +72,12 @@ FileGrid.decorate = function(
self.relayoutRateLimiter_ =
new AsyncUtil.RateLimiter(self.relayoutImmediately_.bind(self));
+
+ var style = window.getComputedStyle(self);
+ /** @private {number} */
+ self.paddingLeft_ = parseFloat(style.paddingLeft);
+ /** @private {number} */
+ self.paddingTop_ = parseFloat(style.paddingTop);
};
/**
@@ -421,17 +427,22 @@ FileGrid.prototype.getHitIndex_ = function(coordinate, step, threshold) {
*/
FileGrid.prototype.getHitElements = function(x, y, opt_width, opt_height) {
var currentSelection = [];
- var right = x + (opt_width || 0);
- var bottom = y + (opt_height || 0);
+ var xInAvailableSpace = Math.max(0, x - this.paddingLeft_);
+ var yInAvailableSpace = Math.max(0, y - this.paddingTop_);
+ var right = xInAvailableSpace + (opt_width || 0);
+ var bottom = yInAvailableSpace + (opt_height || 0);
var itemMetrics = this.measureItem();
var horizontalStartIndex = this.getHitIndex_(
- x, itemMetrics.width, itemMetrics.width - itemMetrics.marginRight);
+ xInAvailableSpace, itemMetrics.width,
+ itemMetrics.width - itemMetrics.marginRight);
var horizontalEndIndex = Math.min(this.columns, this.getHitIndex_(
right, itemMetrics.width, itemMetrics.marginLeft));
var verticalStartIndex = this.getHitIndex_(
- y, itemMetrics.height, itemMetrics.height - itemMetrics.marginBottom);
+ yInAvailableSpace, itemMetrics.height,
+ itemMetrics.height - itemMetrics.marginBottom);
var verticalEndIndex = this.getHitIndex_(
bottom, itemMetrics.height, itemMetrics.marginTop);
+
for (var verticalIndex = verticalStartIndex;
verticalIndex < verticalEndIndex;
verticalIndex++) {
« no previous file with comments | « ui/file_manager/file_manager/foreground/css/file_manager.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698