From 37c27faae42b57d570fa6a49cd7b7d8e5cdaf95d Mon Sep 17 00:00:00 2001 From: Hixie Date: Thu, 5 Mar 2015 15:46:21 -0800 Subject: [PATCH] fix the hang when clicking the drawer in the stocks app R=eseidel@chromium.org Review URL: https://codereview.chromium.org/980043005 --- examples/fn/widgets/drawer.dart | 8 +++++--- framework/animation/generator.dart | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/fn/widgets/drawer.dart b/examples/fn/widgets/drawer.dart index 282310c53e8..f4a3aa00bbf 100644 --- a/examples/fn/widgets/drawer.dart +++ b/examples/fn/widgets/drawer.dart @@ -73,9 +73,11 @@ class DrawerAnimation { void _animateToPosition(double targetPosition) { double distance = (targetPosition - _position).abs(); - double targetDuration = distance / _kWidth * _kBaseSettleDurationMS; - double duration = math.min(targetDuration, _kMaxSettleDurationMS); - _animate(duration, _position, targetPosition, _kAnimationCurve); + if (distance != 0) { + double targetDuration = distance / _kWidth * _kBaseSettleDurationMS; + double duration = math.min(targetDuration, _kMaxSettleDurationMS); + _animate(duration, _position, targetPosition, _kAnimationCurve); + } } void handleFlingStart(event) { diff --git a/framework/animation/generator.dart b/framework/animation/generator.dart index 0b5055050a9..9b83d9fb4f6 100644 --- a/framework/animation/generator.dart +++ b/framework/animation/generator.dart @@ -66,6 +66,7 @@ class AnimationGenerator extends FrameGenerator { this.curve: linear, Function onDone }):super(onDone: onDone) { + assert(duration > 0); double startTime = 0.0; _stream = super.onTick.map((timeStamp) { if (startTime == 0.0)