Commit 34238dd8 authored by Adam Barth's avatar Adam Barth

Force AnimatedVariables to hit begin on 0.0

We already forced hitting end on 1.0.

Fixes #1358
parent 445c512d
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import "dart:sky"; import 'dart:sky' show Color, Rect;
import 'package:sky/src/animation/curves.dart'; import 'package:sky/src/animation/curves.dart';
...@@ -57,13 +57,13 @@ class AnimationTiming { ...@@ -57,13 +57,13 @@ class AnimationTiming {
Interval interval = _getInterval(direction); Interval interval = _getInterval(direction);
if (interval != null) if (interval != null)
t = interval.transform(t); t = interval.transform(t);
if (t == 1.0) // Or should we support inverse curves? assert(t >= 0.0 && t <= 1.0);
return t; if (t == 0.0 || t == 1.0) {
Curve curve = _getCurve(direction); assert(t == _applyCurve(t, direction).round().toDouble());
if (curve != null)
t = curve.transform(t);
return t; return t;
} }
return _applyCurve(t, direction);
}
Interval _getInterval(Direction direction) { Interval _getInterval(Direction direction) {
if (direction == Direction.forward || reverseInterval == null) if (direction == Direction.forward || reverseInterval == null)
...@@ -76,6 +76,13 @@ class AnimationTiming { ...@@ -76,6 +76,13 @@ class AnimationTiming {
return curve; return curve;
return reverseCurve; return reverseCurve;
} }
double _applyCurve(double t, Direction direction) {
Curve curve = _getCurve(direction);
if (curve == null)
return t;
return curve.transform(t);
}
} }
/// An animated variable with a concrete type /// An animated variable with a concrete type
...@@ -101,7 +108,12 @@ class AnimatedValue<T extends dynamic> extends AnimationTiming implements Animat ...@@ -101,7 +108,12 @@ class AnimatedValue<T extends dynamic> extends AnimationTiming implements Animat
void setProgress(double t, Direction direction) { void setProgress(double t, Direction direction) {
if (end != null) { if (end != null) {
t = transform(t, direction); t = transform(t, direction);
value = (t == 1.0) ? end : lerp(t); if (t == 0.0)
value = begin;
else if (t == 1.0)
value = end;
else
value = lerp(t);
} }
} }
......
...@@ -102,11 +102,6 @@ class DismissableState extends State<Dismissable> { ...@@ -102,11 +102,6 @@ class DismissableState extends State<Dismissable> {
..addListener(_handleResizeProgressChanged); ..addListener(_handleResizeProgressChanged);
_resizePerformance.play(); _resizePerformance.play();
}); });
// Our squash curve (ease) does not return v=0.0 for t=0.0, so we
// technically resize on the first frame. To make sure this doesn't confuse
// any other widgets (like MixedViewport, which checks for this kind of
// thing), we report a resize straight away.
_maybeCallOnResized();
} }
void _handleResizeProgressChanged() { void _handleResizeProgressChanged() {
......
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