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

Unified Diff: sky/sdk/lib/widgets/fixed_height_scrollable.dart

Issue 1232083006: Avoid drawing an extra row when the number of rows that fit on the screen is integral. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/fixed_height_scrollable.dart
diff --git a/sky/sdk/lib/widgets/fixed_height_scrollable.dart b/sky/sdk/lib/widgets/fixed_height_scrollable.dart
index 06ce7d35ae2171492a073d37a9e2b6d6d843323a..0e0a41dd31df28fc1c60f5842ad90244e6b144cb 100644
--- a/sky/sdk/lib/widgets/fixed_height_scrollable.dart
+++ b/sky/sdk/lib/widgets/fixed_height_scrollable.dart
@@ -61,24 +61,25 @@ abstract class FixedHeightScrollable extends Scrollable {
int itemShowIndex = 0;
int itemShowCount = 0;
-
double offsetY = 0.0;
-
if (_height != null && _height > 0.0) {
if (scrollOffset < 0.0) {
double visibleHeight = _height + scrollOffset;
itemShowCount = (visibleHeight / itemHeight).round() + 1;
offsetY = scrollOffset;
} else {
- itemShowCount = (_height / itemHeight).ceil() + 1;
+ itemShowCount = (_height / itemHeight).ceil();
double alignmentDelta = -scrollOffset % itemHeight;
- if (alignmentDelta != 0.0)
+ double drawStart;
+ if (alignmentDelta != 0.0) {
alignmentDelta -= itemHeight;
-
- double drawStart = scrollOffset + alignmentDelta;
+ itemShowCount += 1;
+ drawStart = scrollOffset + alignmentDelta;
+ offsetY = -alignmentDelta;
+ } else {
+ drawStart = scrollOffset;
+ }
itemShowIndex = math.max(0, (drawStart / itemHeight).floor());
-
- offsetY = -alignmentDelta;
}
}
« 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