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

Unified Diff: ui/webui/resources/js/cr/ui/list.js

Issue 96823002: [list.js] Consider vertical paddings of list view when scrolling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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: ui/webui/resources/js/cr/ui/list.js
diff --git a/ui/webui/resources/js/cr/ui/list.js b/ui/webui/resources/js/cr/ui/list.js
index 6377273124467465801854953c4d9fc396b1c2a2..27e1d678cb02a46dbd58fc330947245bd96ecf51 100644
--- a/ui/webui/resources/js/cr/ui/list.js
+++ b/ui/webui/resources/js/cr/ui/list.js
@@ -711,6 +711,11 @@ cr.define('cr.ui', function() {
var top = this.getItemTop(index);
var clientHeight = this.clientHeight;
+ var cs = getComputedStyle(this);
+ var paddingY = parseInt(cs.paddingTop, 10) +
+ parseInt(cs.paddingBottom, 10);
+ var availableHeight = clientHeight - paddingY;
+
var self = this;
// Function to adjust the tops of viewport and row.
function scrollToAdjustTop() {
@@ -719,27 +724,20 @@ cr.define('cr.ui', function() {
};
// Function to adjust the bottoms of viewport and row.
function scrollToAdjustBottom() {
- var cs = getComputedStyle(self);
- var paddingY = parseInt(cs.paddingTop, 10) +
- parseInt(cs.paddingBottom, 10);
-
- if (top + itemHeight > scrollTop + clientHeight - paddingY) {
- self.scrollTop = top + itemHeight - clientHeight + paddingY;
- return true;
- }
- return false;
+ self.scrollTop = top + itemHeight - availableHeight;
arv (Not doing code reviews) 2013/12/02 16:30:27 This changes the behavior too. In the old code we
yoshiki 2013/12/03 01:12:02 Yes, this check is already done in the callers.
+ return true;
};
// Check if the entire of given indexed row can be shown in the viewport.
- if (itemHeight <= clientHeight) {
+ if (itemHeight <= availableHeight) {
if (top < scrollTop)
return scrollToAdjustTop();
- if (scrollTop + clientHeight < top + itemHeight)
+ if (scrollTop + availableHeight < top + itemHeight)
return scrollToAdjustBottom();
} else {
if (scrollTop < top)
return scrollToAdjustTop();
- if (top + itemHeight < scrollTop + clientHeight)
+ if (top + itemHeight < scrollTop + availableHeight)
return scrollToAdjustBottom();
}
return false;
« 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