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.github.io/LICENSE.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/CONTRIBUTORS.txt
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/PATENTS.txt
11 `core-scaffold` provides general application layout, introducing a
12 responsive scaffold containing a header, toolbar, menu, title and
13 areas for application content.
18 <core-header-panel navigation flex mode="seamed">
19 <core-toolbar>Application</core-toolbar>
20 <core-menu theme="core-light-theme">
21 <core-item icon="settings" label="item1"></core-item>
22 <core-item icon="settings" label="item2"></core-item>
26 <div>Main content goes here...</div>
29 Use `mode` to control the header and scrolling behavior of `core-header-panel`
30 and `responsiveWidth` to change the layout of the scaffold. Use 'disableSwipe'
31 to disable swipe-to-open on toolbar.
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:
38 <core-scaffold rightDrawer>
39 <div tool flex >Title</div>
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 using
44 mode="waterfall-tall"):
46 <core-scaffold rightDrawer mode="waterfall-tall">
47 <div tool flex >Title</div>
48 <div tool horizontal layout flex center-justified class="middle">Title-middle</div>
49 <div tool horizontal layout flex end-justified class="bottom">Title-bottom</div>
52 To have the content fit to the main area, use `fit` attribute.
55 <core-header-panel navigation flex mode="seamed">
59 <div fit>Content fits to the main area</div>
62 @group Polymer Core Elements
63 @element core-scaffold
67 <link rel=
"import" href=
"../core-toolbar/core-toolbar.html">
68 <link rel=
"import" href=
"../core-drawer-panel/core-drawer-panel.html">
69 <link rel=
"import" href=
"../core-header-panel/core-header-panel.html">
70 <link rel=
"import" href=
"../core-icon-button/core-icon-button.html">
72 <polymer-element name=
"core-scaffold">
82 background-color: #fff;
83 box-shadow:
1px
0 1px rgba(
0,
0,
0,
0.1);
88 background-color: #eee;
92 background-color: #
526E9C;
96 #drawerPanel:not([narrow]) #menuButton {
102 <core-drawer-panel id=
"drawerPanel" narrow=
"{{narrow}}" drawerWidth=
"{{drawerWidth}}" rightDrawer=
"{{rightDrawer}}" responsiveWidth=
"{{responsiveWidth}}" disableSwipe=
"{{disableSwipe}}">
104 <div vertical layout drawer
>
106 <content select=
"[navigation], nav"></content>
110 <core-header-panel id=
"headerPanel" main
mode=
"{{mode}}">
113 <template if=
"{{!rightDrawer}}">
114 <core-icon-button id=
"menuButton" icon=
"menu" on-tap=
"{{togglePanel}}"></core-icon-button>
116 <content select=
"[tool]"></content>
117 <template if=
"{{rightDrawer}}">
118 <core-icon-button id=
"menuButton" icon=
"menu" on-tap=
"{{togglePanel}}"></core-icon-button>
122 <content select=
"*"></content>
131 Polymer('core-scaffold', {
134 * Fired when the main content has been scrolled. `event.detail.target` returns
135 * the scrollable element which you can use to access scroll info such as
138 * <core-scaffold on-scroll="{{scrollHandler}}">
143 * scrollHandler: function(event) {
144 * var scroller = event.detail.target;
145 * console.log(scroller.scrollTop);
154 * Width of the drawer panel.
156 * @attribute drawerWidth
160 drawerWidth
: '256px',
163 * When the browser window size is smaller than the `responsiveWidth`,
164 * `core-drawer-panel` changes to a narrow layout. In narrow layout,
165 * the drawer will be stacked on top of the main panel.
167 * @attribute responsiveWidth
171 responsiveWidth
: '600px',
174 * If true, position the drawer to the right. Also place menu icon to
175 * the right of the content instead of left.
177 * @attribute rightDrawer
184 * If true, swipe to open/close the drawer is disabled.
186 * @attribute disableSwipe
193 * Used to control the header and scrolling behaviour of `core-header-panel`
199 mode
: {value
: 'seamed', reflect
: true}
203 this._scrollHandler
= this.scroll
.bind(this);
204 this.$.headerPanel
.addEventListener('scroll', this._scrollHandler
);
207 detached: function() {
208 this.$.headerPanel
.removeEventListener('scroll', this._scrollHandler
);
212 * Toggle the drawer panel
213 * @method togglePanel
215 togglePanel: function() {
216 this.$.drawerPanel
.togglePanel();
220 * Open the drawer panel
223 openDrawer: function() {
224 this.$.drawerPanel
.openDrawer();
228 * Close the drawer panel
229 * @method closeDrawer
231 closeDrawer: function() {
232 this.$.drawerPanel
.closeDrawer();
236 * Returns the scrollable element on the main area.
242 return this.$.headerPanel
.scroller
;
245 scroll: function(e
) {
246 this.fire('scroll', {target
: e
.detail
.target
}, this, false);