| Index: sky/sdk/lib/animation/scroll_behavior.dart
|
| diff --git a/sky/sdk/lib/animation/scroll_behavior.dart b/sky/sdk/lib/animation/scroll_behavior.dart
|
| index b07ee8f7c6d182101d52c90d2d29ee8d2259279e..96ab1653c8d1bdc399bcc1bedffe16b98e5857e1 100644
|
| --- a/sky/sdk/lib/animation/scroll_behavior.dart
|
| +++ b/sky/sdk/lib/animation/scroll_behavior.dart
|
| @@ -60,9 +60,11 @@ class OverscrollBehavior extends ScrollBehavior {
|
|
|
| double get maxScrollOffset => math.max(0.0, _contentsHeight - _containerHeight);
|
|
|
| + bool get contentsHeightIsKnown => _contentsHeight != null;
|
| +
|
| Simulation release(Particle particle) {
|
| System system;
|
| - if ((particle.position >= 0.0) && (particle.position < maxScrollOffset)) {
|
| + if (contentsHeightIsKnown && particle.position >= 0.0 && particle.position < maxScrollOffset) {
|
| if (particle.velocity == 0.0)
|
| return null;
|
| System slowdownSystem = new ParticleInBoxWithFriction(
|
| @@ -77,8 +79,18 @@ class OverscrollBehavior extends ScrollBehavior {
|
| ));
|
| }));
|
| system = new Multisystem(particle: particle, system: slowdownSystem);
|
| - } else {
|
| + } else if (contentsHeightIsKnown || particle.position < 0) {
|
| system = getBounceBackSystem(particle);
|
| + } else {
|
| + double maxParticlePosition = particle.position + containerHeight;
|
| + if (particle.velocity == 0.0)
|
| + return null;
|
| + System slowdownSystem = new ParticleInBoxWithFriction(
|
| + particle: particle,
|
| + friction: _kScrollFriction,
|
| + box: new GeofenceBox(min: 0.0, max: maxParticlePosition, onEscape: (){ })
|
| + );
|
| + system = slowdownSystem;
|
| }
|
| return new Simulation(system, terminationCondition: () => particle.position == 0.0);
|
| }
|
| @@ -90,6 +102,8 @@ class OverscrollBehavior extends ScrollBehavior {
|
| box: new ClosedBox(max: 0.0),
|
| theta: _kBounceSlopeAngle,
|
| targetPosition: 0.0);
|
| +
|
| + assert(contentsHeightIsKnown);
|
| return new ParticleClimbingRamp(
|
| particle: particle,
|
| box: new ClosedBox(min: maxScrollOffset),
|
| @@ -102,12 +116,12 @@ class OverscrollBehavior extends ScrollBehavior {
|
| // If we're overscrolling, we want move the scroll offset 2x
|
| // slower than we would otherwise. Therefore, we "rewind" the
|
| // newScrollOffset by half the amount that we moved it above.
|
| - // Notice that we clap the "old" value to 0.0 so that we only
|
| + // Notice that we clamp the "old" value to 0.0 so that we only
|
| // reduce the portion of scrollDelta that's applied beyond 0.0. We
|
| // do similar things for overscroll in the other direction.
|
| if (newScrollOffset < 0.0) {
|
| newScrollOffset -= (newScrollOffset - math.min(0.0, scrollOffset)) / 2.0;
|
| - } else if (newScrollOffset > maxScrollOffset) {
|
| + } else if (contentsHeightIsKnown && newScrollOffset > maxScrollOffset) {
|
| newScrollOffset -= (newScrollOffset - math.max(maxScrollOffset, scrollOffset)) / 2.0;
|
| }
|
| return newScrollOffset;
|
|
|