| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:sky' as sky; | 5 import 'dart:sky' as sky; |
| 6 | 6 |
| 7 import 'package:newton/newton.dart'; | 7 import 'package:newton/newton.dart'; |
| 8 import 'package:sky/animation/animated_simulation.dart'; | 8 import 'package:sky/animation/animated_simulation.dart'; |
| 9 import 'package:sky/animation/scroll_behavior.dart'; | 9 import 'package:sky/animation/scroll_behavior.dart'; |
| 10 import 'package:sky/theme/view_configuration.dart' as config; | 10 import 'package:sky/theme/view_configuration.dart' as config; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 enum ScrollDirection { vertical, horizontal } | 25 enum ScrollDirection { vertical, horizontal } |
| 26 | 26 |
| 27 abstract class Scrollable extends StatefulComponent { | 27 abstract class Scrollable extends StatefulComponent { |
| 28 | 28 |
| 29 Scrollable({ | 29 Scrollable({ |
| 30 String key, | 30 String key, |
| 31 this.backgroundColor, | 31 this.backgroundColor, |
| 32 this.direction: ScrollDirection.vertical | 32 this.direction: ScrollDirection.vertical |
| 33 }) : super(key: key) { | 33 }) : super(key: key); |
| 34 _animation = new AnimatedSimulation(_tickScrollOffset); | |
| 35 } | |
| 36 | 34 |
| 37 Color backgroundColor; | 35 Color backgroundColor; |
| 38 ScrollDirection direction; | 36 ScrollDirection direction; |
| 39 | 37 |
| 38 void initState() { |
| 39 _animation = new AnimatedSimulation(_tickScrollOffset); |
| 40 } |
| 41 |
| 40 void syncFields(Scrollable source) { | 42 void syncFields(Scrollable source) { |
| 41 backgroundColor = source.backgroundColor; | 43 backgroundColor = source.backgroundColor; |
| 42 direction == source.direction; | 44 direction == source.direction; |
| 43 } | 45 } |
| 44 | 46 |
| 45 double _scrollOffset = 0.0; | 47 double _scrollOffset = 0.0; |
| 46 double get scrollOffset => _scrollOffset; | 48 double get scrollOffset => _scrollOffset; |
| 47 | 49 |
| 48 ScrollBehavior _scrollBehavior; | 50 ScrollBehavior _scrollBehavior; |
| 49 ScrollBehavior createScrollBehavior(); | 51 ScrollBehavior createScrollBehavior(); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 167 |
| 166 void _handleFlingCancel(sky.GestureEvent event) { | 168 void _handleFlingCancel(sky.GestureEvent event) { |
| 167 settleScrollOffset(); | 169 settleScrollOffset(); |
| 168 } | 170 } |
| 169 | 171 |
| 170 void _handleWheel(sky.WheelEvent event) { | 172 void _handleWheel(sky.WheelEvent event) { |
| 171 scrollBy(-event.offsetY); | 173 scrollBy(-event.offsetY); |
| 172 } | 174 } |
| 173 | 175 |
| 174 } | 176 } |
| OLD | NEW |