Commit dc304b42 authored by mpcomplete's avatar mpcomplete

Merge pull request #592 from mpcomplete/animation.asserts

Fix common asserts in animation API.
parents c80603cf 8a729317
...@@ -51,7 +51,8 @@ class Ticker { ...@@ -51,7 +51,8 @@ class Ticker {
_onTick(timeStamp); _onTick(timeStamp);
if (isTicking) // The onTick callback may have scheduled another tick already.
if (isTicking && _animationId == null)
_scheduleTick(); _scheduleTick();
} }
......
...@@ -14,7 +14,7 @@ class TweenSimulation extends Simulation { ...@@ -14,7 +14,7 @@ class TweenSimulation extends Simulation {
final double end; final double end;
TweenSimulation(Duration duration, this.begin, this.end) : TweenSimulation(Duration duration, this.begin, this.end) :
_durationInSeconds = duration.inMilliseconds / 1000.0 { _durationInSeconds = duration.inMicroseconds / Duration.MICROSECONDS_PER_SECOND {
assert(_durationInSeconds > 0.0); assert(_durationInSeconds > 0.0);
assert(begin != null && begin >= 0.0 && begin <= 1.0); assert(begin != null && begin >= 0.0 && begin <= 1.0);
assert(end != null && end >= 0.0 && end <= 1.0); assert(end != null && end >= 0.0 && end <= 1.0);
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// 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:async';
import 'dart:sky' as sky; import 'dart:sky' as sky;
import 'package:sky/animation/animated_value.dart'; import 'package:sky/animation/animated_value.dart';
...@@ -69,9 +68,7 @@ class Drawer extends StatefulComponent { ...@@ -69,9 +68,7 @@ class Drawer extends StatefulComponent {
_performance.attachedForce = kDefaultSpringForce; _performance.attachedForce = kDefaultSpringForce;
if (navigator != null) { if (navigator != null) {
scheduleMicrotask(() { navigator.pushState(this, (_) => _performance.reverse());
navigator.pushState(this, (_) => _performance.reverse());
});
} }
} }
...@@ -120,14 +117,12 @@ class Drawer extends StatefulComponent { ...@@ -120,14 +117,12 @@ class Drawer extends StatefulComponent {
} }
void _onDismissed() { void _onDismissed() {
scheduleMicrotask(() { if (navigator != null &&
if (navigator != null && navigator.currentRoute is RouteState &&
navigator.currentRoute is RouteState && (navigator.currentRoute as RouteState).owner == this) // TODO(ianh): remove cast once analyzer is cleverer
(navigator.currentRoute as RouteState).owner == this) // TODO(ianh): remove cast once analyzer is cleverer navigator.pop();
navigator.pop(); if (onDismissed != null)
if (onDismissed != null) onDismissed();
onDismissed();
});
} }
bool get _isMostlyClosed => _performance.progress < 0.5; bool get _isMostlyClosed => _performance.progress < 0.5;
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// 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:async';
import 'dart:sky' as sky; import 'dart:sky' as sky;
import 'package:sky/animation/animated_value.dart'; import 'package:sky/animation/animated_value.dart';
...@@ -72,11 +71,7 @@ class PopupMenu extends StatefulComponent { ...@@ -72,11 +71,7 @@ class PopupMenu extends StatefulComponent {
} }
void _open() { void _open() {
if (navigator != null) { navigator.pushState(this, (_) => _close());
scheduleMicrotask(() {
navigator.pushState(this, (_) => _close());
});
}
} }
void _close() { void _close() {
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// 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:async';
import 'package:sky/animation/animated_value.dart'; import 'package:sky/animation/animated_value.dart';
import 'package:sky/animation/animation_performance.dart'; import 'package:sky/animation/animation_performance.dart';
...@@ -61,7 +60,7 @@ class SnackBar extends Component { ...@@ -61,7 +60,7 @@ class SnackBar extends Component {
void _onDismissed() { void _onDismissed() {
if (onDismissed != null) if (onDismissed != null)
scheduleMicrotask(() { onDismissed(); }); onDismissed();
} }
Widget build() { Widget build() {
......
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