| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 @license | 2 @license |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 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 | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS |
| 7 Code distributed by Google as part of the polymer project is also | 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 | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS |
| 9 --> | 9 --> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 .item:nth-child(even) { | 33 .item:nth-child(even) { |
| 34 background-color: red; | 34 background-color: red; |
| 35 } | 35 } |
| 36 </style> | 36 </style> |
| 37 | 37 |
| 38 <template> | 38 <template> |
| 39 <iron-list style$="[[_computedListHeight(listHeight)]]" items="[[data]]" as=
"item" id="list"> | 39 <iron-list style$="[[_computedListHeight(listHeight)]]" items="[[data]]" as=
"item" id="list"> |
| 40 <template> | 40 <template> |
| 41 <div class="item"> | 41 <div class="item"> |
| 42 <div style$="[[_computedItemHeight()]]">[[item.index]]</div> | 42 <div style$="[[_computedItemHeight(item)]]">[[item.index]]</div> |
| 43 </div> | 43 </div> |
| 44 </template> | 44 </template> |
| 45 </iron-list> | 45 </iron-list> |
| 46 </template> | 46 </template> |
| 47 | 47 |
| 48 </dom-module> | 48 </dom-module> |
| 49 | 49 |
| 50 <script> | 50 <script> |
| 51 Polymer({ | 51 Polymer({ |
| 52 is: 'x-list', | 52 is: 'x-list', |
| 53 | 53 |
| 54 properties: { | 54 properties: { |
| 55 data: { | 55 data: { |
| 56 type: Array | 56 type: Array |
| 57 }, | 57 }, |
| 58 | 58 |
| 59 itemHeight: { | 59 itemHeight: { |
| 60 type: Number, | 60 type: Number, |
| 61 value: 100 | 61 value: 100 |
| 62 }, | 62 }, |
| 63 | 63 |
| 64 listHeight: { | 64 listHeight: { |
| 65 type: Number, | 65 type: Number, |
| 66 value: 300 | 66 value: 300 |
| 67 }, |
| 68 |
| 69 pre: { |
| 70 type: Boolean |
| 67 } | 71 } |
| 68 }, | 72 }, |
| 69 | 73 |
| 70 get list() { | 74 get list() { |
| 71 return this.$.list; | 75 return this.$.list; |
| 72 }, | 76 }, |
| 73 | 77 |
| 74 _computedItemHeight: function() { | 78 _computedItemHeight: function(item) { |
| 75 return 'height: ' + (this.itemHeight) + 'px'; | 79 var css = this.pre ? 'white-space:pre;' : ''; |
| 80 if (item.height) { |
| 81 css += this.itemHeight === 0 ? '' : 'height: ' + (item.height) + 'px;'; |
| 82 } else if (this.itemHeight) { |
| 83 css += 'height: ' + (this.itemHeight) + 'px;'; |
| 84 } |
| 85 return css; |
| 76 }, | 86 }, |
| 77 | 87 |
| 78 _computedListHeight: function(listHeight) { | 88 _computedListHeight: function(listHeight) { |
| 79 return 'height: ' + (listHeight) + 'px'; | 89 return 'height: ' + (listHeight) + 'px'; |
| 80 }, | 90 } |
| 81 }); | 91 }); |
| 82 </script> | 92 </script> |
| OLD | NEW |