3 Polymer('core-header-panel',{
6 * Fired when the content has been scrolled. `event.detail.target` returns
7 * the scrollable element which you can use to access scroll info such as
10 * <core-header-panel on-scroll="{{scrollHandler}}">
12 * </core-header-panel>
15 * scrollHandler: function(event) {
16 * var scroller = event.detail.target;
17 * console.log(scroller.scrollTop);
25 * Controls header and scrolling behavior. Options are
26 * `standard`, `seamed`, `waterfall`, `waterfall-tall`, `scroll` and
27 * `cover`. Default is `standard`.
29 * `standard`: The header is a step above the panel. The header will consume the
30 * panel at the point of entry, preventing it from passing through to the
33 * `seamed`: The header is presented as seamed with the panel.
35 * `waterfall`: Similar to standard mode, but header is initially presented as
36 * seamed with panel, but then separates to form the step.
38 * `waterfall-tall`: The header is initially taller (`tall` class is added to
39 * the header). As the user scrolls, the header separates (forming an edge)
40 * while condensing (`tall` class is removed from the header).
42 * `scroll`: The header keeps its seam with the panel, and is pushed off screen.
44 * `cover`: The panel covers the whole `core-header-panel` including the
45 * header. This allows user to style the panel in such a way that the panel is
46 * partially covering the header.
49 * core-header-panel[mode=cover]::shadow #mainContainer {
53 * margin: 60px 60px 60px 0;
57 * <core-header-panel mode="cover">
58 * <core-toolbar class="tall">
59 * <core-icon-button icon="menu"></core-icon-button>
61 * <div class="content"></div>
62 * </core-header-panel>
68 mode: {value: '', reflect: true},
71 * The class used in waterfall-tall mode. Change this if the header
72 * accepts a different class for toggling height, e.g. "medium-tall"
74 * @attribute tallClass
81 * If true, the drop-shadow is always shown no matter what mode is set to.
93 shadowMode: {'waterfall': 1, 'waterfall-tall': 1},
94 noShadow: {'seamed': 1, 'cover': 1, 'scroll': 1},
95 tallMode: {'waterfall-tall': 1},
96 outerScroll: {'scroll': 1}
100 this.scrollHandler = this.scroll.bind(this);
104 detached: function() {
105 this.removeListener(this.mode);
108 addListener: function() {
109 this.scroller.addEventListener('scroll', this.scrollHandler);
112 removeListener: function(mode) {
113 var s = this.getScrollerForMode(mode);
114 s.removeEventListener('scroll', this.scrollHandler);
117 domReady: function() {
118 this.async('scroll');
121 modeChanged: function(old) {
122 var configs = this.modeConfigs;
123 var header = this.header;
125 // in tallMode it may add tallClass to the header; so do the cleanup
126 // when mode is changed from tallMode to not tallMode
127 if (configs.tallMode[old] && !configs.tallMode[this.mode]) {
128 header.classList.remove(this.tallClass);
129 this.async(function() {
130 header.classList.remove('animate');
131 }, null, this.animateDuration);
133 header.classList.toggle('animate', configs.tallMode[this.mode]);
136 if (configs && (configs.outerScroll[this.mode] || configs.outerScroll[old])) {
137 this.removeListener(old);
144 return this.$.headerContent.getDistributedNodes()[0];
147 getScrollerForMode: function(mode) {
148 return this.modeConfigs.outerScroll[mode] ?
149 this.$.outerContainer : this.$.mainContainer;
153 * Returns the scrollable element.
159 return this.getScrollerForMode(this.mode);
163 var configs = this.modeConfigs;
164 var main = this.$.mainContainer;
165 var header = this.header;
167 var sTop = main.scrollTop;
168 var atTop = sTop === 0;
170 this.$.dropShadow.classList.toggle('hidden', !this.shadow &&
171 (atTop && configs.shadowMode[this.mode] || configs.noShadow[this.mode]));
173 if (header && configs.tallMode[this.mode]) {
174 header.classList.toggle(this.tallClass, atTop ||
175 header.classList.contains(this.tallClass) &&
176 main.scrollHeight < this.$.outerContainer.offsetHeight);
179 this.fire('scroll', {target: this.scroller}, this, false);