OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
6 Code distributed by Google as part of the polymer project is also | 6 Code distributed by Google as part of the polymer project is also |
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
8 --> | 8 --> |
9 | 9 |
10 <!-- | 10 <!-- |
11 `core-scaffold` provides general application layout, introducing a | 11 `core-scaffold` provides general application layout, introducing a |
12 responsive scaffold containing a header, toolbar, menu, title and | 12 responsive scaffold containing a header, toolbar, menu, title and |
13 areas for application content. | 13 areas for application content. |
14 | 14 |
15 Example: | 15 Example: |
16 | 16 |
17 <core-scaffold> | 17 <core-scaffold> |
18 <core-header-panel navigation flex mode="seamed"> | 18 <core-header-panel navigation flex mode="seamed"> |
19 <core-toolbar>Application</core-toolbar> | 19 <core-toolbar>Application</core-toolbar> |
20 <core-menu theme="core-light-theme"> | 20 <core-menu theme="core-light-theme"> |
21 <core-item icon="settings" label="item1"></core-item> | 21 <core-item icon="settings" label="item1"></core-item> |
22 <core-item icon="settings" label="item2"></core-item> | 22 <core-item icon="settings" label="item2"></core-item> |
23 </core-menu> | 23 </core-menu> |
24 </core-header-panel> | 24 </core-header-panel> |
25 <div tool>Title</div> | 25 <div tool>Title</div> |
26 <div>Main content goes here...</div> | 26 <div>Main content goes here...</div> |
27 </core-scaffold> | 27 </core-scaffold> |
28 | 28 |
29 Use `mode` to control the header and scrolling behavior of `core-header-panel` | 29 Use `mode` to control the header and scrolling behavior of `core-header-panel` |
30 and `responsiveWidth` to change the layout of the scaffold. | 30 and `responsiveWidth` to change the layout of the scaffold. Use 'disableSwipe' |
| 31 to disable swipe-to-open on toolbar. |
31 | 32 |
32 To have the content fits to the main area, use `fit` attribute. | 33 Use `rightDrawer` to move position of folding toolbar to the right instead of |
| 34 left (default). This will also position content to the left of the menu button |
| 35 instead of the right. You can use `flex` within your `tool` content to push the
menu |
| 36 button to the far right: |
| 37 |
| 38 <core-scaffold rightDrawer> |
| 39 <div tool flex >Title</div> |
| 40 </core-scaffold> |
| 41 |
| 42 You may also add `middle` or `bottom` classes to your `tool` content when using
tall |
| 43 modes to adjust vertical content positioning in the core-toolbar (e.g. when usin
g |
| 44 mode="waterfall-tall"): |
| 45 |
| 46 <core-scaffold rightDrawer mode="waterfall-tall"> |
| 47 <div tool flex >Title</div> |
| 48 <div tool horizontal layout flex center-justified class="middle">Title-mid
dle</div> |
| 49 <div tool horizontal layout flex end-justified class="bottom">Title-bottom
</div> |
| 50 </core-scaffold> |
| 51 |
| 52 To have the content fit to the main area, use `fit` attribute. |
33 | 53 |
34 <core-scaffold> | 54 <core-scaffold> |
35 <core-header-panel navigation flex mode="seamed"> | 55 <core-header-panel navigation flex mode="seamed"> |
36 .... | 56 .... |
37 </core-header-panel> | 57 </core-header-panel> |
38 <div tool>Title</div> | 58 <div tool>Title</div> |
39 <div fit>Content fits to the main area</div> | 59 <div fit>Content fits to the main area</div> |
40 </core-scaffold> | 60 </core-scaffold> |
41 | 61 |
42 @group Polymer Core Elements | 62 @group Polymer Core Elements |
(...skipping 29 matching lines...) Expand all Loading... |
72 background-color: #526E9C; | 92 background-color: #526E9C; |
73 color: #fff; | 93 color: #fff; |
74 } | 94 } |
75 | 95 |
76 #drawerPanel:not([narrow]) #menuButton { | 96 #drawerPanel:not([narrow]) #menuButton { |
77 display: none; | 97 display: none; |
78 } | 98 } |
79 | 99 |
80 </style> | 100 </style> |
81 | 101 |
82 <core-drawer-panel id="drawerPanel" narrow="{{narrow}}" responsiveWidth="{{res
ponsiveWidth}}"> | 102 <core-drawer-panel id="drawerPanel" narrow="{{narrow}}" drawerWidth="{{drawerW
idth}}" rightDrawer="{{rightDrawer}}" responsiveWidth="{{responsiveWidth}}" disa
bleSwipe="{{disableSwipe}}"> |
83 | 103 |
84 <div vertical layout drawer> | 104 <div vertical layout drawer> |
85 | 105 |
86 <content select="[navigation], nav"></content> | 106 <content select="[navigation], nav"></content> |
87 | 107 |
88 </div> | 108 </div> |
89 | 109 |
90 <core-header-panel id="headerPanel" main mode="{{mode}}"> | 110 <core-header-panel id="headerPanel" main mode="{{mode}}"> |
91 | 111 |
92 <core-toolbar> | 112 <core-toolbar> |
93 <core-icon-button id="menuButton" icon="menu" on-tap="{{togglePanel}}"><
/core-icon-button> | 113 <template if="{{!rightDrawer}}"> |
| 114 <core-icon-button id="menuButton" icon="menu" on-tap="{{togglePanel}}"
></core-icon-button> |
| 115 </template> |
94 <content select="[tool]"></content> | 116 <content select="[tool]"></content> |
| 117 <template if="{{rightDrawer}}"> |
| 118 <core-icon-button id="menuButton" icon="menu" on-tap="{{togglePanel}}"
></core-icon-button> |
| 119 </template> |
95 </core-toolbar> | 120 </core-toolbar> |
96 | 121 |
97 <content select="*"></content> | 122 <content select="*"></content> |
98 | 123 |
99 </core-header-panel> | 124 </core-header-panel> |
100 | 125 |
101 </core-drawer-panel> | 126 </core-drawer-panel> |
102 | 127 |
103 </template> | 128 </template> |
104 <script> | 129 <script> |
(...skipping 12 matching lines...) Expand all Loading... |
117 * | 142 * |
118 * scrollHandler: function(event) { | 143 * scrollHandler: function(event) { |
119 * var scroller = event.detail.target; | 144 * var scroller = event.detail.target; |
120 * console.log(scroller.scrollTop); | 145 * console.log(scroller.scrollTop); |
121 * } | 146 * } |
122 * | 147 * |
123 * @event scroll | 148 * @event scroll |
124 */ | 149 */ |
125 | 150 |
126 publish: { | 151 publish: { |
| 152 |
| 153 /** |
| 154 * Width of the drawer panel. |
| 155 * |
| 156 * @attribute drawerWidth |
| 157 * @type string |
| 158 * @default '256px' |
| 159 */ |
| 160 drawerWidth: '256px', |
| 161 |
127 /** | 162 /** |
128 * When the browser window size is smaller than the `responsiveWidth`, | 163 * When the browser window size is smaller than the `responsiveWidth`, |
129 * `core-drawer-panel` changes to a narrow layout. In narrow layout, | 164 * `core-drawer-panel` changes to a narrow layout. In narrow layout, |
130 * the drawer will be stacked on top of the main panel. | 165 * the drawer will be stacked on top of the main panel. |
131 * | 166 * |
132 * @attribute responsiveWidth | 167 * @attribute responsiveWidth |
133 * @type string | 168 * @type string |
134 * @default '600px' | 169 * @default '600px' |
135 */ | 170 */ |
136 responsiveWidth: '600px', | 171 responsiveWidth: '600px', |
| 172 |
| 173 /** |
| 174 * If true, position the drawer to the right. Also place menu icon to |
| 175 * the right of the content instead of left. |
| 176 * |
| 177 * @attribute rightDrawer |
| 178 * @type boolean |
| 179 * @default false |
| 180 */ |
| 181 rightDrawer: false, |
| 182 |
| 183 /** |
| 184 * If true, swipe to open/close the drawer is disabled. |
| 185 * |
| 186 * @attribute disableSwipe |
| 187 * @type boolean |
| 188 * @default false |
| 189 */ |
| 190 disableSwipe: false, |
137 | 191 |
138 /** | 192 /** |
139 * Used to control the header and scrolling behaviour of `core-header-pane
l` | 193 * Used to control the header and scrolling behaviour of `core-header-pane
l` |
140 * | 194 * |
141 * @attribute mode | 195 * @attribute mode |
142 * @type string | 196 * @type string |
143 * @default 'seamed' | 197 * @default 'seamed' |
144 */ | 198 */ |
145 mode: {value: 'seamed', reflect: true} | 199 mode: {value: 'seamed', reflect: true} |
146 }, | 200 }, |
147 | 201 |
148 ready: function() { | 202 ready: function() { |
149 this._scrollHandler = this.scroll.bind(this); | 203 this._scrollHandler = this.scroll.bind(this); |
150 this.$.headerPanel.addEventListener('scroll', this._scrollHandler); | 204 this.$.headerPanel.addEventListener('scroll', this._scrollHandler); |
151 }, | 205 }, |
152 | 206 |
153 detached: function() { | 207 detached: function() { |
154 this.$.headerPanel.removeEventListener('scroll', this._scrollHandler); | 208 this.$.headerPanel.removeEventListener('scroll', this._scrollHandler); |
155 }, | 209 }, |
156 | 210 |
157 /** | 211 /** |
158 * Toggle the drawer panel | 212 * Toggle the drawer panel |
159 * @method togglePanel | 213 * @method togglePanel |
160 */ | 214 */ |
161 togglePanel: function() { | 215 togglePanel: function() { |
162 this.$.drawerPanel.togglePanel(); | 216 this.$.drawerPanel.togglePanel(); |
163 }, | 217 }, |
164 | 218 |
165 /** | 219 /** |
166 * Open the drawer panel | 220 * Open the drawer panel |
167 * @method openDrawer | 221 * @method openDrawer |
168 */ | 222 */ |
169 openDrawer: function() { | 223 openDrawer: function() { |
170 this.$.drawerPanel.openDrawer(); | 224 this.$.drawerPanel.openDrawer(); |
171 }, | 225 }, |
172 | 226 |
173 /** | 227 /** |
174 * Close the drawer panel | 228 * Close the drawer panel |
175 * @method closeDrawer | 229 * @method closeDrawer |
176 */ | 230 */ |
177 closeDrawer: function() { | 231 closeDrawer: function() { |
178 this.$.drawerPanel.closeDrawer(); | 232 this.$.drawerPanel.closeDrawer(); |
179 }, | 233 }, |
180 | 234 |
| 235 /** |
| 236 * Returns the scrollable element on the main area. |
| 237 * |
| 238 * @property scroller |
| 239 * @type Object |
| 240 */ |
| 241 get scroller() { |
| 242 return this.$.headerPanel.scroller; |
| 243 }, |
| 244 |
181 scroll: function(e) { | 245 scroll: function(e) { |
182 this.fire('scroll', {target: e.detail.target}, this, false); | 246 this.fire('scroll', {target: e.detail.target}, this, false); |
183 } | 247 } |
184 | 248 |
185 }); | 249 }); |
186 | 250 |
187 </script> | 251 </script> |
188 </polymer-element> | 252 </polymer-element> |
OLD | NEW |