| 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 <!-- |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 html, body { | 31 html, body { |
| 32 height: 100%; | 32 height: 100%; |
| 33 margin: 0; | 33 margin: 0; |
| 34 } | 34 } |
| 35 core-scroll-header-panel { | 35 core-scroll-header-panel { |
| 36 height: 100%; | 36 height: 100%; |
| 37 } | 37 } |
| 38 | 38 |
| 39 `core-scroll-header-panel` works well with `core-toolbar` but can use any elemen
t | 39 `core-scroll-header-panel` works well with `core-toolbar` but can use any elemen
t |
| 40 that represents a header by adding a `core-header` class to it. Use the attribu
te | 40 that represents a header by adding a `core-header` class to it. |
| 41 or class `content` to delineate the content section. | |
| 42 | 41 |
| 43 <core-scroll-header-panel> | 42 <core-scroll-header-panel> |
| 44 <core-toolbar>Header</core-toolbar> | 43 <core-toolbar>Header</core-toolbar> |
| 45 <div content>Content goes here...</div> | 44 <div>Content goes here...</div> |
| 46 </core-scroll-header-panel> | 45 </core-scroll-header-panel> |
| 47 | 46 |
| 48 @group Polymer Core Elements | 47 @group Polymer Core Elements |
| 49 @element core-scroll-header-panel | 48 @element core-scroll-header-panel |
| 50 @homepage github.io | 49 @homepage github.io |
| 51 --> | 50 --> |
| 52 | 51 |
| 53 <link rel="import" href="../polymer/polymer.html"> | 52 <link rel="import" href="../polymer/polymer.html"> |
| 53 <link rel="import" href="../core-resizable/core-resizable.html"> |
| 54 | 54 |
| 55 <polymer-element name="core-scroll-header-panel"> | 55 <polymer-element name="core-scroll-header-panel"> |
| 56 <template> | 56 <template> |
| 57 | 57 |
| 58 <link rel="stylesheet" href="core-scroll-header-panel.css"> | 58 <link rel="stylesheet" href="core-scroll-header-panel.css"> |
| 59 | 59 |
| 60 <div id="mainContainer"> | 60 <div id="mainContainer"> |
| 61 | 61 |
| 62 <content id="mainContent" select="[content], .content"></content> | 62 <content id="mainContent" select=":not(core-toolbar):not(.core-header)"></co
ntent> |
| 63 | 63 |
| 64 </div> | 64 </div> |
| 65 | 65 |
| 66 <div id="headerContainer"> | 66 <div id="headerContainer"> |
| 67 | 67 |
| 68 <div class="bg-container"> | 68 <div class="bg-container"> |
| 69 <div id="condensedHeaderBg"></div> | 69 <div id="condensedHeaderBg"></div> |
| 70 <div id="headerBg"></div> | 70 <div id="headerBg"></div> |
| 71 </div> | 71 </div> |
| 72 | 72 |
| 73 <content id="headerContent" select="core-toolbar, .core-header"></content> | 73 <content id="headerContent" select="core-toolbar, .core-header"></content> |
| 74 | 74 |
| 75 </div> | 75 </div> |
| 76 | 76 |
| 77 </template> | 77 </template> |
| 78 <script> | 78 <script> |
| 79 (function() { | 79 (function() { |
| 80 | 80 |
| 81 Polymer('core-scroll-header-panel', { | 81 Polymer(Polymer.mixin({ |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * Fired when the content has been scrolled. | 84 * Fired when the content has been scrolled. |
| 85 * | 85 * |
| 86 * @event scroll | 86 * @event scroll |
| 87 */ | 87 */ |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * Fired when the header is transformed. | 90 * Fired when the header is transformed. |
| 91 * | 91 * |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 prevScrollTop: 0, | 179 prevScrollTop: 0, |
| 180 | 180 |
| 181 headerMargin: 0, | 181 headerMargin: 0, |
| 182 | 182 |
| 183 y: 0, | 183 y: 0, |
| 184 | 184 |
| 185 observe: { | 185 observe: { |
| 186 'headerMargin fixed': 'setup' | 186 'headerMargin fixed': 'setup' |
| 187 }, | 187 }, |
| 188 | 188 |
| 189 eventDelegates: { |
| 190 'core-resize': 'measureHeaderHeight' |
| 191 }, |
| 192 |
| 193 attached: function() { |
| 194 this.resizableAttachedHandler(); |
| 195 }, |
| 196 |
| 189 ready: function() { | 197 ready: function() { |
| 190 this._scrollHandler = this.scroll.bind(this); | 198 this._scrollHandler = this.scroll.bind(this); |
| 191 this.scroller.addEventListener('scroll', this._scrollHandler); | 199 this.scroller.addEventListener('scroll', this._scrollHandler); |
| 192 }, | 200 }, |
| 193 | 201 |
| 194 detached: function() { | 202 detached: function() { |
| 195 this.scroller.removeEventListener('scroll', this._scrollHandler); | 203 this.scroller.removeEventListener('scroll', this._scrollHandler); |
| 204 this.resizableDetachedHandler(); |
| 196 }, | 205 }, |
| 197 | 206 |
| 198 domReady: function() { | 207 domReady: function() { |
| 199 this.async('measureHeaderHeight'); | 208 this.async('measureHeaderHeight'); |
| 200 }, | 209 }, |
| 201 | 210 |
| 202 get header() { | 211 get header() { |
| 203 return this.$.headerContent.getDistributedNodes()[0]; | 212 return this.$.headerContent.getDistributedNodes()[0]; |
| 204 }, | 213 }, |
| 205 | 214 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 333 } |
| 325 | 334 |
| 326 this.prevScrollTop = Math.max(sTop, 0); | 335 this.prevScrollTop = Math.max(sTop, 0); |
| 327 this.y = y; | 336 this.y = y; |
| 328 | 337 |
| 329 if (event) { | 338 if (event) { |
| 330 this.fire('scroll', {target: this.scroller}, this, false); | 339 this.fire('scroll', {target: this.scroller}, this, false); |
| 331 } | 340 } |
| 332 } | 341 } |
| 333 | 342 |
| 334 }); | 343 }, Polymer.CoreResizable)); |
| 335 | 344 |
| 336 //determine proper transform mechanizm | 345 //determine proper transform mechanizm |
| 337 if (document.documentElement.style.transform !== undefined) { | 346 if (document.documentElement.style.transform !== undefined) { |
| 338 var setTransform = function(style, string) { | 347 var setTransform = function(style, string) { |
| 339 style.transform = string; | 348 style.transform = string; |
| 340 } | 349 } |
| 341 } else { | 350 } else { |
| 342 var setTransform = function(style, string) { | 351 var setTransform = function(style, string) { |
| 343 style.webkitTransform = string; | 352 style.webkitTransform = string; |
| 344 } | 353 } |
| 345 } | 354 } |
| 346 | 355 |
| 347 })(); | 356 })(); |
| 348 | 357 |
| 349 </script> | 358 </script> |
| 350 </polymer-element> | 359 </polymer-element> |
| OLD | NEW |