Index: sky/sdk/lib/widgets/scrollable.dart |
diff --git a/sky/sdk/lib/widgets/scrollable.dart b/sky/sdk/lib/widgets/scrollable.dart |
index 3e9c924880dcf2d0fc2b32bff14f0f0d83cafe67..237df4e37ff81a51ce4be05309b016507f248499 100644 |
--- a/sky/sdk/lib/widgets/scrollable.dart |
+++ b/sky/sdk/lib/widgets/scrollable.dart |
@@ -17,24 +17,31 @@ import 'theme.dart'; |
const double _kMillisecondsPerSecond = 1000.0; |
-double _velocityForFlingGesture(sky.GestureEvent event) { |
+double _velocityForFlingGesture(double eventVelocity) { |
return math.max(-config.kMaxFlingVelocity, math.min(config.kMaxFlingVelocity, |
- -event.velocityY)) / _kMillisecondsPerSecond; |
+ eventVelocity)) / _kMillisecondsPerSecond; |
} |
abarth-chromium
2015/07/02 15:27:21
eventVelocity.clamp(-config.kMaxFlingVelocity, con
hansmuller
2015/07/06 17:21:46
Done.
|
abstract class ScrollClient { |
bool ancestorScrolled(Scrollable ancestor); |
} |
+enum ScrollDirection { vertical, horizontal } |
+ |
abstract class Scrollable extends Component { |
- Scrollable({ String key, Color this.backgroundColor }) |
- : super(key: key, stateful: true); |
+ Scrollable({ |
+ String key, |
+ this.backgroundColor, |
+ this.direction: ScrollDirection.vertical |
+ }) : super(key: key, stateful: true); |
Color backgroundColor; |
+ ScrollDirection direction; |
void syncFields(Scrollable source) { |
backgroundColor = source.backgroundColor; |
+ direction == source.direction; |
} |
Color get _nonNullBackgroundColor { |
@@ -159,11 +166,14 @@ abstract class Scrollable extends Component { |
} |
void _handleScrollUpdate(sky.GestureEvent event) { |
- scrollBy(-event.dy); |
+ scrollBy(direction == ScrollDirection.horizontal ? event.dx : -event.dy); |
} |
void _handleFlingStart(sky.GestureEvent event) { |
- _startSimulation(_createParticle(_velocityForFlingGesture(event))); |
+ double eventVelocity = direction == ScrollDirection.horizontal |
+ ? -event.velocityX |
+ : -event.velocityY; |
+ _startSimulation(_createParticle(_velocityForFlingGesture(eventVelocity))); |
} |
void _handleFlingCancel(sky.GestureEvent event) { |