| 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 /** | 5 /** |
| 6 * Holds a number of child views. As you switch between views, the old | 6 * Holds a number of child views. As you switch between views, the old |
| 7 * view is pushed off to the side and the new view slides in from the other | 7 * view is pushed off to the side and the new view slides in from the other |
| 8 * side. | 8 * side. |
| 9 */ | 9 */ |
| 10 class ConveyorView extends CompositeView { | 10 class ConveyorView extends CompositeView { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 final result = super.render(); | 32 final result = super.render(); |
| 33 // TODO(rnystrom): Have to do this in render() because container doesn't | 33 // TODO(rnystrom): Have to do this in render() because container doesn't |
| 34 // exist before then. Hack. Should find a cleaner solution. One of: | 34 // exist before then. Hack. Should find a cleaner solution. One of: |
| 35 // - Add a ctor param to CompositeView for container class name. | 35 // - Add a ctor param to CompositeView for container class name. |
| 36 // - Make ConveyorView contain a CompositeView instead of subclass. | 36 // - Make ConveyorView contain a CompositeView instead of subclass. |
| 37 // - Add method to CompositeView to set class name. | 37 // - Add method to CompositeView to set class name. |
| 38 container.attributes['class'] = 'conveyor-view-container'; | 38 container.attributes['class'] = 'conveyor-view-container'; |
| 39 return result; | 39 return result; |
| 40 } | 40 } |
| 41 | 41 |
| 42 void selectView(View targetView, [bool animate = true]) { | 42 void selectView(View targetView_, [bool animate = true]) { |
| 43 selectedView = targetView; | 43 selectedView = targetView_; |
| 44 | 44 |
| 45 // Only animate if we're actually in the document now. | 45 // Only animate if we're actually in the document now. |
| 46 if (isRendered) { | 46 if (isRendered) { |
| 47 adjustOffset(animate); | 47 adjustOffset(animate); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 void adjustOffset(bool animate) { | 51 void adjustOffset(bool animate) { |
| 52 int index = getIndexOfSelectedView(); | 52 int index = getIndexOfSelectedView(); |
| 53 final durationSeconds = animate ? ANIMATE_SECONDS : 0.0; | 53 final durationSeconds = animate ? ANIMATE_SECONDS : 0.0; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 view.transform = 'translate3d(' + (childViews.length * 100) + '%, 0, 0)'; | 89 view.transform = 'translate3d(' + (childViews.length * 100) + '%, 0, 0)'; |
| 90 return super.addChild(view); | 90 return super.addChild(view); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void _onAnimationEnd() { | 93 void _onAnimationEnd() { |
| 94 if (viewSelected != null) { | 94 if (viewSelected != null) { |
| 95 viewSelected(selectedView); | 95 viewSelected(selectedView); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 } | 98 } |
| OLD | NEW |