Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: sky/sdk/lib/framework/components2/scrollable.dart

Issue 1172173002: Clean up a bunch of our Dart code. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: upstream merge Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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) {
27 onDidUnmount(_stopSimulation);
28 }
29
26 double _scrollOffset = 0.0; 30 double _scrollOffset = 0.0;
27 double get scrollOffset => _scrollOffset; 31 double get scrollOffset => _scrollOffset;
28 32
29 ScrollBehavior _scrollBehavior; 33 ScrollBehavior _scrollBehavior;
30 ScrollBehavior createScrollBehavior(); 34 ScrollBehavior createScrollBehavior();
31 ScrollBehavior get scrollBehavior { 35 ScrollBehavior get scrollBehavior {
32 if (_scrollBehavior == null) 36 if (_scrollBehavior == null)
33 _scrollBehavior = createScrollBehavior(); 37 _scrollBehavior = createScrollBehavior();
34 return _scrollBehavior; 38 return _scrollBehavior;
35 } 39 }
36 40
37 Simulation _simulation; 41 Simulation _simulation;
38 42
39 Scrollable({Object key}) : super(key: key) {
40 onDidUnmount(_stopSimulation);
41 }
42
43 UINode buildContent(); 43 UINode buildContent();
44 44
45 UINode build() { 45 UINode build() {
46 return new EventListenerNode( 46 return new EventListenerNode(
47 buildContent(), 47 buildContent(),
48 onPointerDown: _handlePointerDown, 48 onPointerDown: _handlePointerDown,
49 onPointerUp: _handlePointerUpOrCancel, 49 onPointerUp: _handlePointerUpOrCancel,
50 onPointerCancel: _handlePointerUpOrCancel, 50 onPointerCancel: _handlePointerUpOrCancel,
51 onGestureFlingStart: _handleFlingStart, 51 onGestureFlingStart: _handleFlingStart,
52 onGestureFlingCancel: _handleFlingCancel, 52 onGestureFlingCancel: _handleFlingCancel,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 _startSimulation(_createParticle(_velocityForFlingGesture(event))); 136 _startSimulation(_createParticle(_velocityForFlingGesture(event)));
137 } 137 }
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 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/components2/radio.dart ('k') | sky/sdk/lib/framework/components2/tool_bar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698