OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of view; | 5 part of view; |
6 | 6 |
7 /** | 7 /** |
8 * Holds a number of child views. As you switch between views, the old | 8 * Holds a number of child views. As you switch between views, the old |
9 * view is pushed off to the side and the new view slides in from the other | 9 * view is pushed off to the side and the new view slides in from the other |
10 * side. | 10 * side. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 style.transitionDuration = '${durationSeconds}s'; | 60 style.transitionDuration = '${durationSeconds}s'; |
61 final xTranslationPercent = -index * 100; | 61 final xTranslationPercent = -index * 100; |
62 style.transform = 'translate3d(${xTranslationPercent}%, 0px, 0px)'; | 62 style.transform = 'translate3d(${xTranslationPercent}%, 0px, 0px)'; |
63 | 63 |
64 if (animationTimeoutId != null) { | 64 if (animationTimeoutId != null) { |
65 window.clearTimeout(animationTimeoutId); | 65 window.clearTimeout(animationTimeoutId); |
66 } | 66 } |
67 | 67 |
68 if (animate) { | 68 if (animate) { |
69 animationTimeoutId = window.setTimeout( | 69 animationTimeoutId = window.setTimeout( |
70 () { _onAnimationEnd(); }, (durationSeconds * 1000).toInt()); | 70 () { _onAnimationEnd(); }, (durationSeconds * 1000).truncate()); |
71 } | 71 } |
72 // TODO(mattsh), we should set the visibility to hide everything but the | 72 // TODO(mattsh), we should set the visibility to hide everything but the |
73 // selected view. | 73 // selected view. |
74 } | 74 } |
75 | 75 |
76 int getIndexOfSelectedView() { | 76 int getIndexOfSelectedView() { |
77 for (int i = 0; i < childViews.length; i++) { | 77 for (int i = 0; i < childViews.length; i++) { |
78 if (childViews[i] == selectedView) { | 78 if (childViews[i] == selectedView) { |
79 return i; | 79 return i; |
80 } | 80 } |
(...skipping 10 matching lines...) Expand all Loading... |
91 view.transform = 'translate3d(${(childViews.length * 100)}%, 0, 0)'; | 91 view.transform = 'translate3d(${(childViews.length * 100)}%, 0, 0)'; |
92 return super.addChild(view); | 92 return super.addChild(view); |
93 } | 93 } |
94 | 94 |
95 void _onAnimationEnd() { | 95 void _onAnimationEnd() { |
96 if (viewSelected != null) { | 96 if (viewSelected != null) { |
97 viewSelected(selectedView); | 97 viewSelected(selectedView); |
98 } | 98 } |
99 } | 99 } |
100 } | 100 } |
OLD | NEW |