Index: samples/swarm/swarm_ui_lib/view/ConveyorView.dart |
diff --git a/samples/swarm/swarm_ui_lib/view/ConveyorView.dart b/samples/swarm/swarm_ui_lib/view/ConveyorView.dart |
index 87c0710af71221fba597e13611af7e1ce532a88f..696c1bd4d74c3ad3c843f3c33b93e31e9bbedcad 100644 |
--- a/samples/swarm/swarm_ui_lib/view/ConveyorView.dart |
+++ b/samples/swarm/swarm_ui_lib/view/ConveyorView.dart |
@@ -23,11 +23,11 @@ class ConveyorView extends CompositeView { |
// which view is selected? (e.g. the MVVM pattern) |
Function viewSelected; |
- Timer animationTimer; |
+ int animationTimeoutId; |
ConveyorView() |
: super('conveyor-view', true), |
- animationTimer = null { |
+ animationTimeoutId = null { |
} |
Element render() { |
@@ -61,10 +61,13 @@ class ConveyorView extends CompositeView { |
final xTranslationPercent = -index * 100; |
style.transform = 'translate3d(${xTranslationPercent}%, 0px, 0px)'; |
+ if (animationTimeoutId != null) { |
+ window.clearTimeout(animationTimeoutId); |
+ } |
+ |
if (animate) { |
- animationTimer = new Timer( |
- new Duration(milliseconds: ((durationSeconds * 1000).toInt())), |
- () { _onAnimationEnd(); }); |
+ animationTimeoutId = window.setTimeout( |
+ () { _onAnimationEnd(); }, (durationSeconds * 1000).toInt()); |
} |
// TODO(mattsh), we should set the visibility to hide everything but the |
// selected view. |