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

Side by Side Diff: sky/examples/fn/widgets/drawer.dart

Issue 976193002: Fix the drawer curve to match Android (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 part of widgets; 1 part of widgets;
2 2
3 const double _kWidth = 256.0; 3 const double _kWidth = 256.0;
4 const double _kMinFlingVelocity = 0.4; 4 const double _kMinFlingVelocity = 0.4;
5 const double _kMinAnimationDurationMS = 246.0; 5 const double _kBaseSettleDurationMS = 246.0;
6 const double _kMaxAnimationDurationMS = 600.0; 6 const double _kMaxSettleDurationMS = 600.0;
7 const Cubic _kAnimationCurve = easeOut; 7 const Cubic _kAnimationCurve = easeOut;
8 8
9 class DrawerAnimation { 9 class DrawerAnimation {
10 10
11 Stream<double> get onPositionChanged => _controller.stream; 11 Stream<double> get onPositionChanged => _controller.stream;
12 12
13 StreamController _controller; 13 StreamController _controller;
14 AnimationGenerator _animation; 14 AnimationGenerator _animation;
15 double _position; 15 double _position;
16 bool get _isAnimating => _animation != null; 16 bool get _isAnimating => _animation != null;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 _animation = new AnimationGenerator(duration, begin: begin, end: end, 66 _animation = new AnimationGenerator(duration, begin: begin, end: end,
67 curve: curve); 67 curve: curve);
68 68
69 _animation.onTick.listen(_setPosition, onDone: () { 69 _animation.onTick.listen(_setPosition, onDone: () {
70 _animation = null; 70 _animation = null;
71 }); 71 });
72 } 72 }
73 73
74 void _animateToPosition(double targetPosition) { 74 void _animateToPosition(double targetPosition) {
75 double distance = (targetPosition - _position).abs(); 75 double distance = (targetPosition - _position).abs();
76 double duration = math.max( 76 double targetDuration = distance / _kWidth * _kBaseSettleDurationMS;
77 _kMinAnimationDurationMS, 77 double duration = math.min(targetDuration, _kMaxSettleDurationMS);
78 _kMaxAnimationDurationMS * distance / _kWidth);
79
80 _animate(duration, _position, targetPosition, _kAnimationCurve); 78 _animate(duration, _position, targetPosition, _kAnimationCurve);
81 } 79 }
82 80
83 void handleFlingStart(event) { 81 void handleFlingStart(event) {
84 double direction = event.velocityX.sign; 82 double direction = event.velocityX.sign;
85 double velocityX = event.velocityX.abs() / 1000; 83 double velocityX = event.velocityX.abs() / 1000;
86 if (velocityX < _kMinFlingVelocity) 84 if (velocityX < _kMinFlingVelocity)
87 return; 85 return;
88 86
89 double targetPosition = direction < 0.0 ? -_kWidth : 0.0; 87 double targetPosition = direction < 0.0 ? -_kWidth : 0.0;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 new Container( 189 new Container(
192 key: 'Content', 190 key: 'Content',
193 style: _contentStyle, 191 style: _contentStyle,
194 inlineStyle: contentInlineStyle, 192 inlineStyle: contentInlineStyle,
195 children: children 193 children: children
196 ) 194 )
197 ] 195 ]
198 ); 196 );
199 } 197 }
200 } 198 }
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