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

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

Issue 1100583002: [Effen] implement bounce back behaviour for lists. Turns out this is (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 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/mechanics.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/animation/scroll_behavior.dart
diff --git a/sky/framework/animation/scroll_behavior.dart b/sky/framework/animation/scroll_behavior.dart
index fcc65a43e3892e1002da56e884c3874fc741036d..cea428ad67f4bd7bf4b01a329eb5809504461e77 100644
--- a/sky/framework/animation/scroll_behavior.dart
+++ b/sky/framework/animation/scroll_behavior.dart
@@ -6,8 +6,9 @@ import 'dart:math' as math;
import 'mechanics.dart';
import 'generators.dart';
-const double _kSlope = 0.02;
-const double _kFriction = 0.004;
+const double _kScrollFriction = 0.005;
+const double _kOverscrollFriction = 0.075;
+const double _kBounceSlopeAngle = math.PI / 512.0; // radians
abstract class ScrollBehavior {
Simulation release(Particle particle) => null;
@@ -34,23 +35,34 @@ class BoundedScrollBehavior extends ScrollBehavior {
class OverscrollBehavior extends ScrollBehavior {
Simulation release(Particle particle) {
+ System system;
if (particle.position >= 0.0) {
if (particle.velocity == 0.0)
return null;
- System system = new ParticleInBoxWithFriction(
+ System slowdownSystem = new ParticleInBoxWithFriction(
particle: particle,
- box: new Box(min: 0.0),
- friction: _kFriction);
- return new Simulation(system,
- terminationCondition: () => particle.velocity == 0.0);
+ friction: _kScrollFriction,
+ box: new GeofenceBox(min: 0.0, onEscape: () {
+ (system as Multisystem).transitionToSystem(new ParticleInBoxWithFriction(
+ particle: particle,
+ friction: _kOverscrollFriction,
+ box: new ClosedBox(),
+ onStop: () => (system as Multisystem).transitionToSystem(getBounceBackSystem(particle))
+ ));
+ }));
+ system = new Multisystem(particle: particle, system: slowdownSystem);
+ } else {
+ system = getBounceBackSystem(particle);
}
- System system = new ParticleClimbingRamp(
+ return new Simulation(system, terminationCondition: () => particle.position == 0.0);
+ }
+
+ System getBounceBackSystem(Particle particle) {
+ return new ParticleClimbingRamp(
particle: particle,
- box: new Box(max: 0.0),
- slope: _kSlope,
+ box: new ClosedBox(max: 0.0),
+ theta: _kBounceSlopeAngle,
targetPosition: 0.0);
- return new Simulation(system,
- terminationCondition: () => particle.position == 0.0);
}
double applyCurve(double scrollOffset, double scrollDelta) {
« no previous file with comments | « sky/framework/animation/mechanics.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698