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

Side by Side Diff: sky/framework/components/scrollable.dart

Issue 1082163002: Scrollable should use scrollTo() when starting an animation (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 '../fn.dart'; 8 import '../fn.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;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return; 62 return;
63 _simulation.cancel(); 63 _simulation.cancel();
64 _simulation = null; 64 _simulation = null;
65 } 65 }
66 66
67 void _startSimulation(Particle particle) { 67 void _startSimulation(Particle particle) {
68 _stopSimulation(); 68 _stopSimulation();
69 _simulation = scrollBehavior.release(particle); 69 _simulation = scrollBehavior.release(particle);
70 if (_simulation == null) 70 if (_simulation == null)
71 return; 71 return;
72 _simulation.onTick.listen((_) { 72 _simulation.onTick.listen((_) {scrollTo(particle.position);});
Hixie 2015/04/14 16:52:30 Keep it on three lines or use the => form.
73 setState(() {
74 _scrollOffset = particle.position;
75 });
76 });
77 } 73 }
78 74
79 Particle _createParticle([double velocity = 0.0]) { 75 Particle _createParticle([double velocity = 0.0]) {
80 return new Particle(position: _scrollOffset, velocity: velocity); 76 return new Particle(position: _scrollOffset, velocity: velocity);
81 } 77 }
82 78
83 void _handlePointerDown(_) { 79 void _handlePointerDown(_) {
84 _stopSimulation(); 80 _stopSimulation();
85 } 81 }
86 82
(...skipping 11 matching lines...) Expand all
98 } 94 }
99 95
100 void _handleFlingCancel(sky.GestureEvent event) { 96 void _handleFlingCancel(sky.GestureEvent event) {
101 _startSimulation(_createParticle()); 97 _startSimulation(_createParticle());
102 } 98 }
103 99
104 void _handleWheel(sky.WheelEvent event) { 100 void _handleWheel(sky.WheelEvent event) {
105 scrollBy(-event.offsetY); 101 scrollBy(-event.offsetY);
106 } 102 }
107 } 103 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698