| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 @license | |
| 3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | |
| 4 This code may only be used under the BSD style license found at http://polym
er.github.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/CO
NTRIBUTORS.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/P
ATENTS.txt | |
| 9 --> | |
| 10 <!doctype html> | |
| 11 <html> | |
| 12 <head> | |
| 13 | |
| 14 <script src="../../webcomponentsjs/webcomponents.js"></script> | |
| 15 | |
| 16 <link href="../../core-icons/core-icons.html" rel="import"> | |
| 17 <link href="../../core-icon-button/core-icon-button.html" rel="import"> | |
| 18 <link href="../../core-toolbar/core-toolbar.html" rel="import"> | |
| 19 <link href="../core-animated-pages.html" rel="import"> | |
| 20 | |
| 21 <style> | |
| 22 body { | |
| 23 font-family: sans-serif; | |
| 24 } | |
| 25 | |
| 26 .toolbar { | |
| 27 background-color: steelblue; | |
| 28 } | |
| 29 | |
| 30 </style> | |
| 31 | |
| 32 </head> | |
| 33 <body unresolved fullbleed vertical layout> | |
| 34 | |
| 35 <polymer-element name="grid-toc" attributes="items selected"> | |
| 36 <template> | |
| 37 <style> | |
| 38 #container { | |
| 39 overflow: auto; | |
| 40 } | |
| 41 | |
| 42 .card { | |
| 43 position: relative; | |
| 44 height: 150px; | |
| 45 width: 150px; | |
| 46 font-size: 50px; | |
| 47 margin: 8px; | |
| 48 background-color: tomato; | |
| 49 border-radius: 4px; | |
| 50 cursor: default; | |
| 51 } | |
| 52 </style> | |
| 53 <div id="container" on-tap="{{selectView}}" flex horizontal wrap around-ju
stified layout hero-p> | |
| 54 <template repeat="{{item in items}}"> | |
| 55 <div class="card" vertical center center-justified layout hero-id="ite
m-{{item}}" hero?="{{selected === item + 1 || lastSelected === item + 1}}"><span
cross-fade>{{item}}</span></div> | |
| 56 </template> | |
| 57 </div> | |
| 58 </template> | |
| 59 <script> | |
| 60 Polymer('grid-toc', { | |
| 61 selectedChanged: function(old) { | |
| 62 this.lastSelected = old; | |
| 63 }, | |
| 64 selectView: function(e) { | |
| 65 var item = e.target.templateInstance.model.item; | |
| 66 if (item !== undefined) { | |
| 67 this.fire('grid-toc-select', {item: item}); | |
| 68 } | |
| 69 } | |
| 70 }); | |
| 71 </script> | |
| 72 </polymer-element> | |
| 73 | |
| 74 <polymer-element name="grid-item" attributes="item isHero"> | |
| 75 <template> | |
| 76 <style> | |
| 77 .view { | |
| 78 font-size: 250px; | |
| 79 background-color: tomato; | |
| 80 } | |
| 81 </style> | |
| 82 <div class="view" flex vertical center center-justified layout hero-id="it
em-{{item}}" hero?="{{isHero}}"> | |
| 83 <span cross-fade>{{item}}</span> | |
| 84 </div> | |
| 85 </template> | |
| 86 <script> | |
| 87 Polymer('grid-item', { | |
| 88 isSelected: false | |
| 89 }) | |
| 90 </script> | |
| 91 </polymer-element> | |
| 92 | |
| 93 | |
| 94 <template is="auto-binding"> | |
| 95 <core-toolbar class="toolbar"> | |
| 96 <core-icon-button icon="{{$.pages.selected != 0 ? 'arrow-back' : 'menu'}}"
on-tap="{{back}}"></core-icon-button> | |
| 97 <div flex>Stuff</div> | |
| 98 <core-icon-button icon="more-vert"></core-icon-button> | |
| 99 </core-toolbar> | |
| 100 <core-animated-pages id="pages" flex selected="0" on-core-animated-pages-tra
nsition-end="{{transitionend}}" transitions="cross-fade-all hero-transition"> | |
| 101 | |
| 102 <grid-toc vertical id="toc" layout selected="{{$.pages.selected}}" items="
{{items}}" hero-p on-grid-toc-select="{{selectView}}"></grid-toc> | |
| 103 | |
| 104 <template repeat="{{item in items}}"> | |
| 105 <grid-item vertical layout item="{{item}}" hero-p isHero="{{$.pages.sele
cted === item + 1 || $.pages.selected === 0}}"></grid-item> | |
| 106 </template> | |
| 107 | |
| 108 </core-animated-pages> | |
| 109 </template> | |
| 110 | |
| 111 <script> | |
| 112 | |
| 113 addEventListener('template-bound', function(e) { | |
| 114 var scope = e.target; | |
| 115 var items = [], count=50; | |
| 116 for (var i=0; i < count; i++) { | |
| 117 items.push(i); | |
| 118 } | |
| 119 | |
| 120 scope.items = items; | |
| 121 | |
| 122 scope.selectView = function(e, detail) { | |
| 123 var i = detail.item; | |
| 124 this.$.pages.selected = i+1; | |
| 125 } | |
| 126 | |
| 127 scope.back = function() { | |
| 128 this.lastSelected = this.$.pages.selected; | |
| 129 this.$.pages.selected = 0; | |
| 130 } | |
| 131 | |
| 132 scope.transitionend = function() { | |
| 133 if (this.lastSelected) { | |
| 134 this.lastSelected = null; | |
| 135 } | |
| 136 } | |
| 137 }) | |
| 138 | |
| 139 </script> | |
| 140 | |
| 141 </body> | |
| 142 </html> | |
| OLD | NEW |