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

Side by Side Diff: sky/framework/fling-curve.dart

Issue 948073002: Fix typos in sky-drawer and sky-scrollable (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | sky/framework/sky-drawer.sky » ('j') | 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 "dart:math" as math; 5 import "dart:math" as math;
6 6
7 const double _kDefaultAlpha = -5707.62; 7 const double _kDefaultAlpha = -5707.62;
8 const double _kDefaultBeta = 172.0; 8 const double _kDefaultBeta = 172.0;
9 const double _kDefaultGamma = 3.7; 9 const double _kDefaultGamma = 3.7;
10 10
11 double _positionAtTime(double t) { 11 double _positionAtTime(double t) {
12 return kDefaultAlpha * math.exp(-kDefaultGamma * t) - kDefaultBeta * t - kDefa ultAlpha; 12 return _kDefaultAlpha * math.exp(-_kDefaultGamma * t)
13 - _kDefaultBeta * t
14 - _kDefaultAlpha;
13 } 15 }
14 16
15 double _velocityAtTime(double t) { 17 double _velocityAtTime(double t) {
16 return -kDefaultAlpha * kDefaultGamma * math.exp(-kDefaultGamma * t) - kDefaul tBeta; 18 return -_kDefaultAlpha * _kDefaultGamma * math.exp(-_kDefaultGamma * t)
19 - _kDefaultBeta;
17 } 20 }
18 21
19 double _timeAtVelocity(double v) { 22 double _timeAtVelocity(double v) {
20 return -math.log((v + kDefaultBeta) / (-kDefaultAlpha * kDefaultGamma)) / kDef aultGamma; 23 return -math.log((v + _kDefaultBeta) / (-_kDefaultAlpha * _kDefaultGamma))
24 / _kDefaultGamma;
21 } 25 }
22 26
23 final double _kMaxVelocity = _velocityAtTime(0.0); 27 final double _kMaxVelocity = _velocityAtTime(0.0);
24 final double _kCurveDuration = _timeAtVelocity(0.0); 28 final double _kCurveDuration = _timeAtVelocity(0.0);
25 29
26 class FlingCurve { 30 class FlingCurve {
27 double _timeOffset; 31 double _timeOffset;
28 double _positionOffset; 32 double _positionOffset;
29 double _startTime; 33 double _startTime;
30 double _previousPosition; 34 double _previousPosition;
(...skipping 11 matching lines...) Expand all
42 double update(double timeStamp) { 46 double update(double timeStamp) {
43 double t = timeStamp / 1000.0 - _startTime + _timeOffset; 47 double t = timeStamp / 1000.0 - _startTime + _timeOffset;
44 if (t >= _kCurveDuration) 48 if (t >= _kCurveDuration)
45 return 0.0; 49 return 0.0;
46 double position = _positionAtTime(t) - _positionOffset; 50 double position = _positionAtTime(t) - _positionOffset;
47 double positionDelta = position - _previousPosition; 51 double positionDelta = position - _previousPosition;
48 _previousPosition = position; 52 _previousPosition = position;
49 return _direction * math.max(0.0, positionDelta); 53 return _direction * math.max(0.0, positionDelta);
50 } 54 }
51 } 55 }
OLDNEW
« no previous file with comments | « no previous file | sky/framework/sky-drawer.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698