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-header-panel` contains a header section and a content panel section.
13 __Important:__ The `core-header-panel` will not display if its parent does not have a height.
15 Using [layout attributes](http://www.polymer-project.org/docs/polymer/layout-attrs.html), you can easily make the `core-header-panel` fill the screen
17 <body fullbleed layout vertical>
18 <core-header-panel flex>
20 <div>Hello World!</div>
25 or, if you would prefer to do it in CSS, just give `html`, `body`, and `core-header-panel` a height of 100%:
35 Special support is provided for scrolling modes when one uses a core-toolbar or equivalent
36 for the header section.
41 <core-toolbar>Header</core-toolbar>
42 <div>Content goes here...</div>
45 If you want to use other than `core-toolbar` for the header, add
46 `core-header` class to that element.
51 <div class="core-header">Header</div>
52 <div>Content goes here...</div>
55 To have the content fits to the main area, use `fit` attribute.
58 <div class="core-header">standard</div>
59 <div class="content" fit>content fits 100% below the header</div>
62 Use `mode` to control the header and scrolling behavior.
64 @group Polymer Core Elements
65 @element core-header-panel
69 <link rel="import" href="../polymer/polymer.html">
71 <polymer-element name="core-header-panel">
74 <link rel="stylesheet" href="core-header-panel.css">
76 <div id="outerContainer" on-scroll="{{scroll}}" vertical layout>
78 <content id="headerContent" select="core-toolbar, .core-header"></content>
80 <div id="mainPanel" flex vertical layout>
82 <div id="mainContainer" flex?="{{mode !== 'cover'}}" on-scroll="{{scroll}}">
83 <content id="mainContent" select="*"></content>
86 <div id="dropShadow"></div>
95 Polymer('core-header-panel', {
98 * Fired when the content has been scrolled. `details.target` returns
99 * the scrollable element which you can use to access scroll info such as
107 * Controls header and scrolling behavior. Options are
108 * `standard`, `seamed`, `waterfall`, `waterfall-tall`,
109 * `waterfall-medium-tall`, `scroll` and `cover`.
110 * Default is `standard`.
112 * `standard`: The header is a step above the panel. The header will consume the
113 * panel at the point of entry, preventing it from passing through to the
116 * `seamed`: The header is presented as seamed with the panel.
118 * `waterfall`: Similar to standard mode, but header is initially presented as
119 * seamed with panel, but then separates to form the step.
121 * `waterfall-tall`: The header is initially taller (`tall` class is added to
122 * the header). As the user scrolls, the header separates (forming an edge)
123 * while condensing (`tall` class is removed from the header).
125 * `scroll`: The header keeps its seam with the panel, and is pushed off screen.
127 * `cover`: The panel covers the whole `core-header-panel` including the
128 * header. This allows user to style the panel in such a way that the panel is
129 * partially covering the header.
132 * core-header-panel[mode=cover]::shadow #mainContainer {
136 * margin: 60px 60px 60px 0;
140 * <core-header-panel mode="cover">
141 * <core-appbar class="tall">
142 * <core-icon-button icon="menu"></core-icon-button>
144 * <div class="content"></div>
145 * </core-header-panel>
151 mode: {value: '', reflect: true},
154 * The class used in waterfall-tall mode. Change this if the header
155 * accepts a different class for toggling height, e.g. "medium-tall"
157 * @attribute tallClass
164 * If true, the drop-shadow is always shown no matter what mode is set to.
173 domReady: function() {
174 this.async('scroll');
177 modeChanged: function() {
182 return this.$.headerContent.getDistributedNodes()[0];
186 * Returns the scrollable element.
192 return this.mode === 'scroll' ?
193 this.$.outerContainer : this.$.mainContainer;
197 var shadowMode = {'waterfall': 1, 'waterfall-tall': 1};
198 var noShadow = {'seamed': 1, 'cover': 1, 'scroll': 1};
199 var tallMode = {'waterfall-tall': 1};
201 var main = this.$.mainContainer;
202 var header = this.header;
204 var sTop = main.scrollTop;
205 var atTop = sTop === 0;
208 this.$.dropShadow.classList.toggle('hidden', !this.shadow &&
209 (atTop && shadowMode[this.mode] || noShadow[this.mode]));
211 if (tallMode[this.mode]) {
212 header.classList.toggle(this.tallClass, atTop ||
213 main.scrollHeight < this.$.outerContainer.offsetHeight);
216 header.classList.toggle('animate', tallMode[this.mode]);
219 this.fire('scroll', {target: this.scroller}, this, false);