Commit 49b43e2e authored by Hixie's avatar Hixie

Trivial code changes for style in animation/ directory.

parent 183ea104
...@@ -33,11 +33,11 @@ class Ticker { ...@@ -33,11 +33,11 @@ class Ticker {
_animationId = null; _animationId = null;
} }
// We take the _completer into a local variable so that !isTicking
// when we actually complete the future (isTicking uses _completer
// to determine its state).
Completer localCompleter = _completer; Completer localCompleter = _completer;
_completer = null; _completer = null;
// We take the _completer into a local variable so that !isTicking when we
// actually complete the future.
assert(!isTicking); assert(!isTicking);
localCompleter.complete(); localCompleter.complete();
} }
......
...@@ -10,27 +10,34 @@ abstract class Force { ...@@ -10,27 +10,34 @@ abstract class Force {
} }
class SpringForce extends Force { class SpringForce extends Force {
SpringForce(this.spring, {this.left: 0.0, this.right: 1.0}); SpringForce(this.spring, { this.left: 0.0, this.right: 1.0 });
// We overshoot the target by this distance, but stop the simulation when
// the spring gets within this distance (regardless of how fast it's moving).
// This causes the spring to settle a bit faster than it otherwise would.
static final Tolerance tolerance =
new Tolerance(velocity: double.INFINITY, distance: 0.01);
final SpringDescription spring; final SpringDescription spring;
// Where to put the spring's resting point when releasing left or right, // Where to put the spring's resting point when releasing left or right,
// respectively. // respectively.
final double left, right; final double left, right;
// We overshoot the target by this distance, but stop the simulation when
// the spring gets within this distance (regardless of how fast it's moving).
// This causes the spring to settle a bit faster than it otherwise would.
static final Tolerance tolerance = new Tolerance(
velocity: double.INFINITY,
distance: 0.01
);
Simulation release(double position, double velocity) { Simulation release(double position, double velocity) {
double target = velocity < 0.0 ? double target = velocity < 0.0 ? this.left - tolerance.distance
this.left - tolerance.distance : this.right + tolerance.distance; : this.right + tolerance.distance;
return new SpringSimulation(spring, position, target, velocity) return new SpringSimulation(spring, position, target, velocity)
..tolerance = tolerance; ..tolerance = tolerance;
} }
} }
final SpringDescription _kDefaultSpringDesc = final SpringDescription _kDefaultSpringDesc = new SpringDescription.withDampingRatio(
new SpringDescription.withDampingRatio(mass: 1.0, springConstant: 500.0, ratio: 1.0); mass: 1.0,
springConstant: 500.0,
ratio: 1.0
);
final SpringForce kDefaultSpringForce = new SpringForce(_kDefaultSpringDesc); final SpringForce kDefaultSpringForce = new SpringForce(_kDefaultSpringDesc);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment