| 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 '../animation/generators.dart'; | 5 import '../animation/generators.dart'; |
| 6 import '../animation/mechanics.dart'; | 6 import '../animation/mechanics.dart'; |
| 7 import '../animation/scroll_behavior.dart'; | 7 import '../animation/scroll_behavior.dart'; |
| 8 import '../fn2.dart'; | 8 import '../fn2.dart'; |
| 9 import '../theme/view_configuration.dart' as config; | 9 import '../theme/view_configuration.dart' as config; |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| 11 import 'dart:sky' as sky; | 11 import 'dart:sky' as sky; |
| 12 | 12 |
| 13 const double _kMillisecondsPerSecond = 1000.0; | 13 const double _kMillisecondsPerSecond = 1000.0; |
| 14 | 14 |
| 15 double _velocityForFlingGesture(sky.GestureEvent event) { | 15 double _velocityForFlingGesture(sky.GestureEvent event) { |
| 16 return math.max(-config.kMaxFlingVelocity, math.min(config.kMaxFlingVelocity, | 16 return math.max(-config.kMaxFlingVelocity, math.min(config.kMaxFlingVelocity, |
| 17 -event.velocityY)) / _kMillisecondsPerSecond; | 17 -event.velocityY)) / _kMillisecondsPerSecond; |
| 18 } | 18 } |
| 19 | 19 |
| 20 abstract class ScrollClient { | 20 abstract class ScrollClient { |
| 21 bool ancestorScrolled(Scrollable ancestor); | 21 bool ancestorScrolled(Scrollable ancestor); |
| 22 } | 22 } |
| 23 | 23 |
| 24 abstract class Scrollable extends Component { | 24 abstract class Scrollable extends Component { |
| 25 | 25 |
| 26 Scrollable({Object key}) : super(key: key) { | 26 Scrollable({Object key}) : super(key: key, stateful: true) { |
| 27 onDidUnmount(_stopSimulation); | 27 onDidUnmount(_stopSimulation); |
| 28 } | 28 } |
| 29 | 29 |
| 30 double _scrollOffset = 0.0; | 30 double _scrollOffset = 0.0; |
| 31 double get scrollOffset => _scrollOffset; | 31 double get scrollOffset => _scrollOffset; |
| 32 | 32 |
| 33 ScrollBehavior _scrollBehavior; | 33 ScrollBehavior _scrollBehavior; |
| 34 ScrollBehavior createScrollBehavior(); | 34 ScrollBehavior createScrollBehavior(); |
| 35 ScrollBehavior get scrollBehavior { | 35 ScrollBehavior get scrollBehavior { |
| 36 if (_scrollBehavior == null) | 36 if (_scrollBehavior == null) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 138 |
| 139 void _handleFlingCancel(sky.GestureEvent event) { | 139 void _handleFlingCancel(sky.GestureEvent event) { |
| 140 _startSimulation(_createParticle()); | 140 _startSimulation(_createParticle()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void _handleWheel(sky.WheelEvent event) { | 143 void _handleWheel(sky.WheelEvent event) { |
| 144 scrollBy(-event.offsetY); | 144 scrollBy(-event.offsetY); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } | 147 } |
| OLD | NEW |