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; |