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

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

Issue 999423004: Drive overscroll animations with a physics simulation (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: More comments 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 | « sky/framework/animation/kinematics.dart ('k') | sky/framework/animation/simulation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/animation/scroll_curve.dart
diff --git a/sky/framework/animation/scroll_curve.dart b/sky/framework/animation/scroll_curve.dart
index 54b6385bd1e5d10cccb8fc4dc209ca919b0ab0d9..4aa9483297eb39c971eb988cddf105b2227d2a50 100644
--- a/sky/framework/animation/scroll_curve.dart
+++ b/sky/framework/animation/scroll_curve.dart
@@ -3,8 +3,14 @@
// found in the LICENSE file.
import 'dart:math' as math;
+import 'kinematics.dart';
+import 'simulation.dart';
+
+const double _kSlope = 0.01;
abstract class ScrollCurve {
+ Simulation release(Particle particle) => null;
+
// Returns the new scroll offset.
double apply(double scrollOffset, double scrollDelta);
}
@@ -26,6 +32,18 @@ class BoundedScrollCurve extends ScrollCurve {
}
class OverscrollCurve extends ScrollCurve {
+ Simulation release(Particle particle) {
+ if (particle.position >= 0.0)
+ return null;
+ System system = new ParticleClimbingHill(
+ particle: particle,
+ box: new Box(max: 0.0),
+ slope: _kSlope,
+ targetPosition: 0.0);
+ return new Simulation(system,
+ terminationCondition: () => particle.position == 0.0);
+ }
+
double apply(double scrollOffset, double scrollDelta) {
double newScrollOffset = scrollOffset + scrollDelta;
if (newScrollOffset < 0.0) {
« no previous file with comments | « sky/framework/animation/kinematics.dart ('k') | sky/framework/animation/simulation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698