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

Unified Diff: sky/framework/components/fixed_height_scrollable.dart

Issue 1002953003: Implement an OverscrollCurve for Scrollable (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 | « sky/framework/animation/scroll_curve.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/components/fixed_height_scrollable.dart
diff --git a/sky/framework/components/fixed_height_scrollable.dart b/sky/framework/components/fixed_height_scrollable.dart
index 4f3a9d9116cc7d9af231266704b5f335f667e536..b388b17635a069551a24e4f200e482bec09a7d3b 100644
--- a/sky/framework/components/fixed_height_scrollable.dart
+++ b/sky/framework/components/fixed_height_scrollable.dart
@@ -4,6 +4,7 @@
import '../animation/scroll_curve.dart';
import '../fn.dart';
+import 'dart:math' as math;
import 'dart:sky' as sky;
import 'scrollable.dart';
@@ -52,17 +53,24 @@ abstract class FixedHeightScrollable extends Scrollable {
var transformStyle = '';
if (_height > 0.0) {
- drawCount = (_height / _itemHeight).round() + 1;
- double alignmentDelta = -scrollOffset % _itemHeight;
- if (alignmentDelta != 0.0) {
- alignmentDelta -= _itemHeight;
- }
+ if (scrollOffset < 0.0) {
+ double visibleHeight = _height + scrollOffset;
+ drawCount = (visibleHeight / _itemHeight).round() + 1;
+ transformStyle =
+ 'transform: translateY(${(-scrollOffset).toStringAsFixed(2)}px)';
+ } else {
+ drawCount = (_height / _itemHeight).round() + 1;
+ double alignmentOffset = math.max(0.0, scrollOffset);
+ double alignmentDelta = -scrollOffset % _itemHeight;
+ if (alignmentDelta != 0.0)
+ alignmentDelta -= _itemHeight;
- double drawStart = scrollOffset + alignmentDelta;
- itemNumber = (drawStart / _itemHeight).floor();
+ double drawStart = scrollOffset + alignmentDelta;
+ itemNumber = (drawStart / _itemHeight).floor();
- transformStyle =
- 'transform: translateY(${(alignmentDelta).toStringAsFixed(2)}px)';
+ transformStyle =
+ 'transform: translateY(${(alignmentDelta).toStringAsFixed(2)}px)';
+ }
}
return new Container(
« no previous file with comments | « sky/framework/animation/scroll_curve.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698