Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Side by Side Diff: polymer_1.2.3/bower_components/paper-header-panel/paper-header-panel.html

Issue 1581713003: [third_party] add polymer 1.2.3 (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: 1.2.3 Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2015 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
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
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
8 -->
9
10 <link rel="import" href="../polymer/polymer.html">
11 <link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
12
13 <!--
14 `paper-header-panel` contains a header section and a content panel section.
15
16 __Important:__ The `paper-header-panel` will not display if its parent does not have a height.
17
18 Using layout classes, you can make the `paper-header-panel` fill the screen
19
20 <body class="fullbleed layout vertical">
21 <paper-header-panel class="flex">
22 <paper-toolbar>
23 <div>Hello World!</div>
24 </paper-toolbar>
25 </paper-header-panel>
26 </body>
27
28 Special support is provided for scrolling modes when one uses a paper-toolbar or equivalent for the
29 header section.
30
31 Example:
32
33 <paper-header-panel>
34 <paper-toolbar>Header</paper-toolbar>
35 <div>Content goes here...</div>
36 </paper-header-panel>
37
38 If you want to use other than `paper-toolbar` for the header, add `paper-header` class to that
39 element.
40
41 Example:
42
43 <paper-header-panel>
44 <div class="paper-header">Header</div>
45 <div>Content goes here...</div>
46 </paper-header-panel>
47
48 To have the content fit to the main area, use the `fit` class.
49
50 <paper-header-panel>
51 <div class="paper-header">standard</div>
52 <div class="fit">content fits 100% below the header</div>
53 </paper-header-panel>
54
55 ### Modes
56
57 Controls header and scrolling behavior. Options are `standard`, `seamed`, `water fall`, `waterfall-tall`, `scroll` and
58 `cover`. Default is `standard`.
59
60 Mode | Description
61 ----------------|-------------
62 `standard` | The header is a step above the panel. The header will consume the p anel at the point of entry, preventing it from passing through to the opposite s ide.
63 `seamed` | The header is presented as seamed with the panel.
64 `waterfall` | Similar to standard mode, but header is initially presented as sea med with panel, but then separates to form the step.
65 `waterfall-tall` | The header is initially taller (`tall` class is added to the header). As the user scrolls, the header separates (forming an edge) while conde nsing (`tall` class is removed from the header).
66 `scroll` | The header keeps its seam with the panel, and is pushed off screen.
67 `cover` | The panel covers the whole `paper-header-panel` including the header. This allows user to style the panel in such a way that the panel is partially co vering the header.
68
69 Example:
70
71 <paper-header-panel mode="waterfall">
72 <div class="paper-header">standard</div>
73 <div class="content fit">content fits 100% below the header</div>
74 </paper-header-panel>
75
76
77 ### Styling
78
79 To change the shadow that shows up underneath the header:
80
81 paper-header-panel {
82 --paper-header-panel-shadow: {
83 height: 6px;
84 bottom: -6px;
85 box-shadow: inset 0px 5px 6px -3px rgba(0, 0, 0, 0.4);
86 };
87 }
88
89 To change the panel container in different modes:
90
91 paper-header-panel {
92 --paper-header-panel-standard-container: {
93 border: 1px solid gray;
94 };
95
96 --paper-header-panel-seamed-container: {
97 border: 1px solid gray;
98 };
99
100 --paper-header-panel-waterfall-container: {
101 border: 1px solid gray;
102 };
103
104 --paper-header-panel-waterfall-tall-container: {
105 border: 1px solid gray;
106 };
107
108 --paper-header-panel-scroll-container: {
109 border: 1px solid gray;
110 };
111
112 --paper-header-panel-cover-container: {
113 border: 1px solid gray;
114 };
115 }
116
117 The following custom properties and mixins are available for styling:
118
119 Custom property | Description | Default
120 ----------------|-------------|----------
121 `--paper-header-panel` | Mixin applied to the element | `{}`
122 `--paper-header-panel-body` | Mixin applied to the element's body (i.e. everythi ng below the toolbar) | `{}`
123 `--paper-header-panel-scroll-container` | Mixin applied to the container when in scroll mode | `{}`
124 `--paper-header-panel-cover-container` | Mixin applied to the container when in cover mode | `{}`
125 `--paper-header-panel-standard-container` | Mixin applied to the container when in standard mode | `{}`
126 `--paper-header-panel-seamed-container` | Mixin applied to the container when in seamed mode | `{}`
127 `--paper-header-panel-waterfall-container` | Mixin applied to the container when in waterfall mode | `{}`
128 `--paper-header-panel-waterfall-tall-container` | Mixin applied to the container when in tall waterfall mode | `{}`
129
130 @group Paper Elements
131 @element paper-header-panel
132 @demo demo/index.html
133 @hero hero.svg
134 -->
135
136 <dom-module id="paper-header-panel">
137 <template>
138 <style>
139 :host {
140 --paper-header-panel-shadow: {
141 height: 6px;
142 bottom: -6px;
143 box-shadow: inset 0px 5px 6px -3px rgba(0, 0, 0, 0.4);
144 };
145
146 @apply(--layout-vertical);
147
148 position: relative;
149 height: 100%;
150
151 @apply(--paper-header-panel);
152 }
153
154 #mainContainer {
155 @apply(--layout-flex);
156
157 position: relative;
158 overflow-y: auto;
159 overflow-x: hidden;
160 -webkit-overflow-scrolling: touch;
161 }
162
163 #mainPanel {
164 @apply(--layout-vertical);
165 @apply(--layout-flex);
166
167 position: relative;
168 min-height: 0;
169
170 @apply(--paper-header-panel-body);
171 }
172
173 /*
174 * mode: scroll
175 */
176 :host([mode=scroll]) #mainContainer {
177 @apply(--paper-header-panel-scroll-container);
178
179 overflow: visible;
180 }
181
182 :host([mode=scroll]) {
183 overflow-y: auto;
184 overflow-x: hidden;
185 -webkit-overflow-scrolling: touch;
186 }
187
188 /*
189 * mode: cover
190 */
191 :host([mode=cover]) #mainContainer {
192 @apply(--paper-header-panel-cover-container);
193
194 position: absolute;
195 top: 0;
196 right: 0;
197 bottom: 0;
198 left: 0;
199 }
200
201 :host([mode=cover]) #mainPanel {
202 position: static;
203 }
204
205 /*
206 * mode: standard
207 */
208 :host([mode=standard]) #mainContainer {
209 @apply(--paper-header-panel-standard-container);
210 }
211
212 /*
213 * mode: seamed
214 */
215 :host([mode=seamed]) #mainContainer {
216 @apply(--paper-header-panel-seamed-container);
217 }
218
219
220 /*
221 * mode: waterfall
222 */
223 :host([mode=waterfall]) #mainContainer {
224 @apply(--paper-header-panel-waterfall-container);
225 }
226
227 /*
228 * mode: waterfall-tall
229 */
230 :host([mode=waterfall-tall]) #mainContainer {
231 @apply(--paper-header-panel-waterfall-tall-container);
232 }
233
234 #dropShadow {
235 @apply(--paper-header-panel-shadow);
236
237 position: absolute;
238 top: 0;
239 left: 0;
240 right: 0;
241 height: 6px;
242 pointer-events: none;
243
244 -webkit-transition: opacity 0.5s;
245 transition: opacity 0.5s;
246
247 opacity: 0;
248 }
249
250 #dropShadow.has-shadow {
251 opacity: 1;
252 }
253 </style>
254
255 <content id="headerContent" select="paper-toolbar, .paper-header"></content>
256
257 <div id="mainPanel">
258 <div id="mainContainer" class$="[[_computeMainContainerClass(mode)]]">
259 <content id="mainContent" select="*"></content>
260 </div>
261 <div id="dropShadow"></div>
262 </div>
263 </template>
264
265 <script>
266 (function() {
267 'use strict';
268
269 var SHADOW_WHEN_SCROLLING = 1;
270 var SHADOW_ALWAYS = 2;
271 var MODE_CONFIGS = {
272 outerScroll: {
273 'scroll': true
274 },
275
276 shadowMode: {
277 'standard': SHADOW_ALWAYS,
278 'waterfall': SHADOW_WHEN_SCROLLING,
279 'waterfall-tall': SHADOW_WHEN_SCROLLING
280 },
281
282 tallMode: {
283 'waterfall-tall': true
284 }
285 };
286
287 Polymer({
288 is: 'paper-header-panel',
289
290 /**
291 * Fired when the content has been scrolled. `event.detail.target` retu rns
292 * the scrollable element which you can use to access scroll info such a s
293 * `scrollTop`.
294 *
295 * <paper-header-panel on-content-scroll="scrollHandler">
296 * ...
297 * </paper-header-panel>
298 *
299 *
300 * scrollHandler: function(event) {
301 * var scroller = event.detail.target;
302 * console.log(scroller.scrollTop);
303 * }
304 *
305 * @event content-scroll
306 */
307
308 properties: {
309 /**
310 * Controls header and scrolling behavior. Options are
311 * `standard`, `seamed`, `waterfall`, `waterfall-tall`, `scroll` and
312 * `cover`. Default is `standard`.
313 *
314 * `standard`: The header is a step above the panel. The header will c onsume the
315 * panel at the point of entry, preventing it from passing through to the
316 * opposite side.
317 *
318 * `seamed`: The header is presented as seamed with the panel.
319 *
320 * `waterfall`: Similar to standard mode, but header is initially pres ented as
321 * seamed with panel, but then separates to form the step.
322 *
323 * `waterfall-tall`: The header is initially taller (`tall` class is a dded to
324 * the header). As the user scrolls, the header separates (forming an edge)
325 * while condensing (`tall` class is removed from the header).
326 *
327 * `scroll`: The header keeps its seam with the panel, and is pushed o ff screen.
328 *
329 * `cover`: The panel covers the whole `paper-header-panel` including the
330 * header. This allows user to style the panel in such a way that the panel is
331 * partially covering the header.
332 *
333 * <paper-header-panel mode="cover">
334 * <paper-toolbar class="tall">
335 * <paper-icon-button icon="menu"></paper-icon-button>
336 * </paper-toolbar>
337 * <div class="content"></div>
338 * </paper-header-panel>
339 */
340 mode: {
341 type: String,
342 value: 'standard',
343 observer: '_modeChanged',
344 reflectToAttribute: true
345 },
346
347 /**
348 * If true, the drop-shadow is always shown no matter what mode is set to.
349 */
350 shadow: {
351 type: Boolean,
352 value: false
353 },
354
355 /**
356 * The class used in waterfall-tall mode. Change this if the header
357 * accepts a different class for toggling height, e.g. "medium-tall"
358 */
359 tallClass: {
360 type: String,
361 value: 'tall'
362 },
363
364 /**
365 * If true, the scroller is at the top
366 */
367 atTop: {
368 type: Boolean,
369 value: true,
370 readOnly: true
371 }
372 },
373
374 observers: [
375 '_computeDropShadowHidden(atTop, mode, shadow)'
376 ],
377
378 ready: function() {
379 this.scrollHandler = this._scroll.bind(this);
380 },
381
382 attached: function() {
383 this._addListener();
384 // Run `scroll` logic once to initialize class names, etc.
385 this._keepScrollingState();
386 },
387
388 detached: function() {
389 this._removeListener();
390 },
391
392 /**
393 * Returns the header element
394 *
395 * @property header
396 * @type Object
397 */
398 get header() {
399 return Polymer.dom(this.$.headerContent).getDistributedNodes()[0];
400 },
401
402 /**
403 * Returns the scrollable element.
404 *
405 * @property scroller
406 * @type Object
407 */
408 get scroller() {
409 return this._getScrollerForMode(this.mode);
410 },
411
412 /**
413 * Returns true if the scroller has a visible shadow.
414 *
415 * @property visibleShadow
416 * @type Boolean
417 */
418 get visibleShadow() {
419 return this.$.dropShadow.classList.contains('has-shadow');
420 },
421
422 _computeDropShadowHidden: function(atTop, mode, shadow) {
423 var shadowMode = MODE_CONFIGS.shadowMode[mode];
424
425 if (this.shadow) {
426 this.toggleClass('has-shadow', true, this.$.dropShadow);
427 } else if (shadowMode === SHADOW_ALWAYS) {
428 this.toggleClass('has-shadow', true, this.$.dropShadow);
429 } else if (shadowMode === SHADOW_WHEN_SCROLLING && !atTop) {
430 this.toggleClass('has-shadow', true, this.$.dropShadow);
431 } else {
432 this.toggleClass('has-shadow', false, this.$.dropShadow);
433 }
434 },
435
436 _computeMainContainerClass: function(mode) {
437 // TODO: It will be useful to have a utility for classes
438 // e.g. Polymer.Utils.classes({ foo: true });
439
440 var classes = {};
441
442 classes['flex'] = mode !== 'cover';
443
444 return Object.keys(classes).filter(
445 function(className) {
446 return classes[className];
447 }).join(' ');
448 },
449
450 _addListener: function() {
451 this.scroller.addEventListener('scroll', this.scrollHandler, false);
452 },
453
454 _removeListener: function() {
455 this.scroller.removeEventListener('scroll', this.scrollHandler);
456 },
457
458 _modeChanged: function(newMode, oldMode) {
459 var configs = MODE_CONFIGS;
460 var header = this.header;
461 var animateDuration = 200;
462
463 if (header) {
464 // in tallMode it may add tallClass to the header; so do the cleanup
465 // when mode is changed from tallMode to not tallMode
466 if (configs.tallMode[oldMode] && !configs.tallMode[newMode]) {
467 header.classList.remove(this.tallClass);
468 this.async(function() {
469 header.classList.remove('animate');
470 }, animateDuration);
471 } else {
472 header.classList.toggle('animate', configs.tallMode[newMode]);
473 }
474 }
475 this._keepScrollingState();
476 },
477
478 _keepScrollingState: function() {
479 var main = this.scroller;
480 var header = this.header;
481
482 this._setAtTop(main.scrollTop === 0);
483
484 if (header && this.tallClass && MODE_CONFIGS.tallMode[this.mode]) {
485 this.toggleClass(this.tallClass, this.atTop ||
486 header.classList.contains(this.tallClass) &&
487 main.scrollHeight < this.offsetHeight, header);
488 }
489 },
490
491 _scroll: function() {
492 this._keepScrollingState();
493 this.fire('content-scroll', {target: this.scroller}, {bubbles: false}) ;
494 },
495
496 _getScrollerForMode: function(mode) {
497 return MODE_CONFIGS.outerScroll[mode] ?
498 this : this.$.mainContainer;
499 }
500 });
501 })();
502 </script>
503 </dom-module>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698