| 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:math' as math; | 5 import 'dart:math' as math; |
| 6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
| 7 | 7 |
| 8 import '../framework/animation/generators.dart'; | 8 import '../framework/animation/generators.dart'; |
| 9 import '../framework/animation/mechanics.dart'; | 9 import '../framework/animation/mechanics.dart'; |
| 10 import '../framework/animation/scroll_behavior.dart'; | 10 import '../framework/animation/scroll_behavior.dart'; |
| 11 import '../theme2/edges.dart'; | 11 import '../theme2/edges.dart'; |
| 12 import '../theme2/view_configuration.dart' as config; | 12 import '../theme2/view_configuration.dart' as config; |
| 13 import 'basic.dart'; | 13 import 'basic.dart'; |
| 14 import 'material.dart'; | 14 import 'material.dart'; |
| 15 | 15 |
| 16 const double _kMillisecondsPerSecond = 1000.0; | 16 const double _kMillisecondsPerSecond = 1000.0; |
| 17 | 17 |
| 18 double _velocityForFlingGesture(sky.GestureEvent event) { | 18 double _velocityForFlingGesture(sky.GestureEvent event) { |
| 19 return math.max(-config.kMaxFlingVelocity, math.min(config.kMaxFlingVelocity, | 19 return math.max(-config.kMaxFlingVelocity, math.min(config.kMaxFlingVelocity, |
| 20 -event.velocityY)) / _kMillisecondsPerSecond; | 20 -event.velocityY)) / _kMillisecondsPerSecond; |
| 21 } | 21 } |
| 22 | 22 |
| 23 abstract class ScrollClient { | 23 abstract class ScrollClient { |
| 24 bool ancestorScrolled(Scrollable ancestor); | 24 bool ancestorScrolled(Scrollable ancestor); |
| 25 } | 25 } |
| 26 | 26 |
| 27 abstract class Scrollable extends Component { | 27 abstract class Scrollable extends Component { |
| 28 | 28 |
| 29 Scrollable({ Object key, Color this.backgroundColor }) : super(key: key, state
ful: true); | 29 Scrollable({ String key, Color this.backgroundColor }) |
| 30 : super(key: key, stateful: true); |
| 30 | 31 |
| 31 Color backgroundColor; | 32 Color backgroundColor; |
| 32 | 33 |
| 33 void syncFields(Scrollable source) { | 34 void syncFields(Scrollable source) { |
| 34 backgroundColor = source.backgroundColor; | 35 backgroundColor = source.backgroundColor; |
| 35 } | 36 } |
| 36 | 37 |
| 37 double _scrollOffset = 0.0; | 38 double _scrollOffset = 0.0; |
| 38 double get scrollOffset => _scrollOffset; | 39 double get scrollOffset => _scrollOffset; |
| 39 | 40 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 155 |
| 155 void _handleFlingCancel(sky.GestureEvent event) { | 156 void _handleFlingCancel(sky.GestureEvent event) { |
| 156 _startSimulation(_createParticle()); | 157 _startSimulation(_createParticle()); |
| 157 } | 158 } |
| 158 | 159 |
| 159 void _handleWheel(sky.WheelEvent event) { | 160 void _handleWheel(sky.WheelEvent event) { |
| 160 scrollBy(-event.offsetY); | 161 scrollBy(-event.offsetY); |
| 161 } | 162 } |
| 162 | 163 |
| 163 } | 164 } |
| OLD | NEW |