| 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 | 8 |
| 9 import '../animation/animated_simulation.dart'; | 9 import '../animation/animated_simulation.dart'; |
| 10 import '../animation/scroll_behavior.dart'; | 10 import '../animation/scroll_behavior.dart'; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 void settleScrollOffset() { | 128 void settleScrollOffset() { |
| 129 _startSimulation(); | 129 _startSimulation(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void _stopSimulation() { | 132 void _stopSimulation() { |
| 133 _animation.stop(); | 133 _animation.stop(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void _startSimulation({ double velocity: 0.0 }) { | 136 void _startSimulation({ double velocity: 0.0 }) { |
| 137 _stopSimulation(); | 137 _stopSimulation(); |
| 138 print("velocity=$velocity"); | |
| 139 Simulation simulation = scrollBehavior.release(scrollOffset, velocity); | 138 Simulation simulation = scrollBehavior.release(scrollOffset, velocity); |
| 140 if (simulation != null) | 139 if (simulation != null) |
| 141 _animation.start(simulation); | 140 _animation.start(simulation); |
| 142 } | 141 } |
| 143 | 142 |
| 144 void _tickScrollOffset(double value) { | 143 void _tickScrollOffset(double value) { |
| 145 scrollTo(value); | 144 scrollTo(value); |
| 146 } | 145 } |
| 147 | 146 |
| 148 void _handlePointerDown(_) { | 147 void _handlePointerDown(_) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 167 | 166 |
| 168 void _handleFlingCancel(sky.GestureEvent event) { | 167 void _handleFlingCancel(sky.GestureEvent event) { |
| 169 settleScrollOffset(); | 168 settleScrollOffset(); |
| 170 } | 169 } |
| 171 | 170 |
| 172 void _handleWheel(sky.WheelEvent event) { | 171 void _handleWheel(sky.WheelEvent event) { |
| 173 scrollBy(-event.offsetY); | 172 scrollBy(-event.offsetY); |
| 174 } | 173 } |
| 175 | 174 |
| 176 } | 175 } |
| OLD | NEW |