OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 @license |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> |
| 10 |
| 11 <!doctype html> |
| 12 <html> |
| 13 <head> |
| 14 |
| 15 <title>iron-list and paper-scroll-header-panel demo</title> |
| 16 |
| 17 <meta charset="utf-8"> |
| 18 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-
scale=1, user-scalable=yes"> |
| 19 <meta name="mobile-web-app-capable" content="yes"> |
| 20 <meta name="apple-mobile-web-app-capable" content="yes"> |
| 21 |
| 22 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 23 |
| 24 <link rel="import" href="../../polymer/polymer.html"> |
| 25 |
| 26 <link rel="import" href="../../iron-flex-layout/iron-flex-layout.html"> |
| 27 <link rel="import" href="../../paper-toolbar/paper-toolbar.html"> |
| 28 <link rel="import" href="../../paper-scroll-header-panel/paper-scroll-header-p
anel.html"> |
| 29 <link rel="import" href="../../paper-icon-button/paper-icon-button.html"> |
| 30 <link rel="import" href="../../iron-ajax/iron-ajax.html"> |
| 31 <link rel="import" href="../../iron-icons/iron-icons.html"> |
| 32 |
| 33 <link rel="import" href="../iron-list.html"> |
| 34 |
| 35 <style is="custom-style"> |
| 36 |
| 37 paper-scroll-header-panel { |
| 38 @apply(--layout-fit); |
| 39 @apply(--layout-vertical); |
| 40 @apply(--paper-font-common-base); |
| 41 } |
| 42 |
| 43 paper-toolbar.tall .title { |
| 44 font-size: 40px; |
| 45 margin-left: 60px; |
| 46 |
| 47 -webkit-transform-origin: left center; |
| 48 transform-origin: left center; |
| 49 overflow: visible; |
| 50 } |
| 51 |
| 52 iron-list { |
| 53 background-color: var(--paper-grey-200, #eee); |
| 54 padding-bottom: 16px; |
| 55 } |
| 56 |
| 57 .item { |
| 58 @apply(--layout-horizontal); |
| 59 |
| 60 margin: 16px 16px 0 16px; |
| 61 padding: 20px; |
| 62 |
| 63 border-radius: 8px; |
| 64 background-color: white; |
| 65 border: 1px solid #ddd; |
| 66 } |
| 67 |
| 68 .avatar { |
| 69 height: 40px; |
| 70 width: 40px; |
| 71 border-radius: 20px; |
| 72 box-sizing: border-box; |
| 73 background-color: #DDD; |
| 74 } |
| 75 |
| 76 .pad { |
| 77 padding: 0 16px; |
| 78 @apply(--layout-flex); |
| 79 @apply(--layout-vertical); |
| 80 } |
| 81 |
| 82 .primary { |
| 83 font-size: 16px; |
| 84 font-weight: bold; |
| 85 } |
| 86 |
| 87 .secondary { |
| 88 font-size: 14px; |
| 89 } |
| 90 |
| 91 .dim { |
| 92 color: gray; |
| 93 } |
| 94 |
| 95 </style> |
| 96 |
| 97 </head> |
| 98 <body unresolved> |
| 99 |
| 100 <template is="dom-bind"> |
| 101 <iron-ajax url="data/contacts.json" last-response="{{data}}" auto></iron-aja
x> |
| 102 |
| 103 <paper-scroll-header-panel class="fit" condenses keep-condensed-header> |
| 104 <paper-toolbar class="tall"> |
| 105 <paper-icon-button icon="arrow-back"></paper-icon-button> |
| 106 <div class="flex"></div> |
| 107 <paper-icon-button icon="search"></paper-icon-button> |
| 108 <paper-icon-button icon="more-vert"></paper-icon-button> |
| 109 <div class="bottom title">iron-list</div> |
| 110 </paper-toolbar> |
| 111 <iron-list items="[[data]]" as="item"> |
| 112 <template> |
| 113 <div> |
| 114 <div class="item"> |
| 115 <img class="avatar" src="[[item.image]]"> |
| 116 <div class="pad"> |
| 117 <div class="primary">[[item.name]]</div> |
| 118 <div class="secondary">[[item.shortText]]</div> |
| 119 <div class="secondary dim">[[item.longText]]</div> |
| 120 </div> |
| 121 <iron-icon icon$="[[iconForItem(item)]]"></iron-icon> |
| 122 </div> |
| 123 </div> |
| 124 </template> |
| 125 </iron-list> |
| 126 </paper-scroll-header-panel> |
| 127 </template> |
| 128 |
| 129 <script> |
| 130 |
| 131 document.querySelector('template[is=dom-bind]').iconForItem = function(item)
{ |
| 132 return item ? (item.integer < 50 ? 'star-border' : 'star') : ''; |
| 133 }; |
| 134 |
| 135 document.addEventListener('paper-header-transform', function(event) { |
| 136 var title = this.querySelector('.title'); |
| 137 var detail = event.detail; |
| 138 var deltaHeight = detail.height - detail.condensedHeight; |
| 139 var scale = Math.max(0.6, (deltaHeight - detail.y) / (deltaHeight / 0.4)
+ 0.6); |
| 140 |
| 141 Polymer.Base.transform('scale(' + scale + ') translateZ(0)', title); |
| 142 }); |
| 143 |
| 144 </script> |
| 145 </body> |
| 146 </html> |
OLD | NEW |