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

Unified Diff: sky/framework/animation/mechanics.dart

Issue 1004363002: Improve Sky's Scrollable physics (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/framework/animation/scroll_behavior.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/animation/mechanics.dart
diff --git a/sky/framework/animation/mechanics.dart b/sky/framework/animation/mechanics.dart
index 7ed6da19f7e58f97abbc842522ec646d1cb729c6..d862d75c8d38a3c08660b20d33ca5e0a16c56438 100644
--- a/sky/framework/animation/mechanics.dart
+++ b/sky/framework/animation/mechanics.dart
@@ -5,7 +5,7 @@
import 'dart:math' as math;
const double kGravity = -0.980;
-const double _kMinVelocity = 0.1;
+const double _kMinVelocity = 0.01;
abstract class System {
void update(double deltaT);
@@ -69,6 +69,23 @@ class ParticleInBox extends System {
}
}
+class ParticleInBoxWithFriction extends ParticleInBox {
+ final double friction;
+ final double _sign;
+
+ ParticleInBoxWithFriction({Particle particle, Box box, this.friction})
+ : super(particle: particle, box: box),
+ _sign = particle.velocity.sign;
+
+ void update(double deltaT) {
+ double force = -_sign * friction;
+ particle.applyImpluse(force * deltaT);
+ if (particle.velocity.sign != _sign)
+ particle.velocity = 0.0;
+ super.update(deltaT);
+ }
+}
+
class Spring {
final double k;
double displacement;
« no previous file with comments | « no previous file | sky/framework/animation/scroll_behavior.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698