|
78 | 78 | /** |
79 | 79 | * If true, polymer-flex-layout is the flex container. |
80 | 80 | * |
| 81 | + * Example: |
| 82 | + * |
| 83 | + * <polymer-flex-layout isContainer> |
| 84 | + * <div>Left</div> |
| 85 | + * <div flex>Main</div> |
| 86 | + * <div>Right</div> |
| 87 | + * </polymer-flex-layout> |
| 88 | + * |
| 89 | + * --------------------------------- |
| 90 | + * |-------------------------------| |
| 91 | + * ||Left| Main |Right|| |
| 92 | + * |-------------------------------| |
| 93 | + * --------------------------------- |
| 94 | + * |
81 | 95 | * @attribute isContainer |
82 | 96 | * @type boolean |
83 | 97 | * @default false |
|
93 | 107 | Polymer('polymer-flex-layout', { |
94 | 108 | vertical: false, |
95 | 109 | isContainer: false, |
| 110 | + layoutContainer: null, |
96 | 111 | enteredView: function() { |
97 | 112 | this.installControllerStyles(); |
98 | 113 | this.layoutContainer = this.isContainer ? |
99 | 114 | this : (this.parentNode.host || this.parentNode); |
100 | | - if (!this.isContainer) { |
101 | | - this.style.display = 'none'; |
| 115 | + this.verticalChanged(); |
| 116 | + this.alignChanged(); |
| 117 | + this.justifyChanged(); |
| 118 | + }, |
| 119 | + leftView: function() { |
| 120 | + this.layoutContainer = null; |
| 121 | + }, |
| 122 | + layoutContainerChanged: function(old) { |
| 123 | + if (old) { |
| 124 | + old.classList.remove('flexbox'); |
| 125 | + } |
| 126 | + this.style.display = this.layoutContainer === this ? '' : 'none'; |
| 127 | + if (this.layoutContainer) { |
| 128 | + this.layoutContainer.classList.add('flexbox'); |
102 | 129 | } |
103 | | - this.async(function() { |
104 | | - this.layoutContainer && this.layoutContainer.classList.add('flexbox'); |
105 | | - this.verticalChanged(); |
106 | | - this.alignChanged(); |
107 | | - this.justifyChanged(); |
108 | | - }); |
109 | | - |
110 | 130 | }, |
111 | 131 | switchContainerClass: function(prefix, old, name) { |
112 | 132 | if (this.layoutContainer && name) { |
|
0 commit comments