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="../../platform/platform.js"></script> | |
15 <link href="../core-animated-pages.html" rel="import"> | |
16 | |
17 <style> | |
18 body { | |
19 font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
20 margin: 0; | |
21 } | |
22 | |
23 </style> | |
24 | |
25 </head> | |
26 <body unresolved> | |
27 | |
28 <polymer-element name="list-demo"> | |
29 <template> | |
30 | |
31 <style> | |
32 p { | |
33 margin: 8px; | |
34 } | |
35 | |
36 .item { | |
37 background: #e7e7e7; | |
38 padding: 16px; | |
39 margin: 8px; | |
40 border-radius: 3px; | |
41 box-sizing: border-box; | |
42 position: relative; | |
43 } | |
44 </style> | |
45 | |
46 <p>Tap to move to top</p> | |
47 | |
48 <core-animated-pages id="pages" on-tap="{{reorder}}" selected="{{selected}}"
on-core-animated-pages-transition-end="{{done}}" transitions="hero-transition"> | |
49 | |
50 <section> | |
51 <template repeat="{{items}}"> | |
52 <div hero-id="{{h}}" hero class="item">{{v}}</div> | |
53 </template> | |
54 </section> | |
55 | |
56 <section> | |
57 <template repeat="{{items2}}"> | |
58 <div hero-id="{{h}}" hero class="item">{{v}}</div> | |
59 </template> | |
60 </section> | |
61 | |
62 </core-animated-pages> | |
63 | |
64 </template> | |
65 | |
66 <script> | |
67 | |
68 Polymer('list-demo', { | |
69 | |
70 selected: 0, | |
71 | |
72 items: [ | |
73 {h: 'matt', v: 'Matt McNulty'}, | |
74 {h: 'scott', v: 'Scott Miles'}, | |
75 {h: 'steve', v: 'Steve Orvell'}, | |
76 {h: 'frankie', v: 'Frankie Fu'}, | |
77 {h: 'daniel', v: 'Daniel Freedman'}, | |
78 {h: 'yvonne', v: 'Yvonne Yip'}, | |
79 ], | |
80 | |
81 items2: [ | |
82 {h: 'matt', v: 'Matt McNulty'}, | |
83 {h: 'scott', v: 'Scott Miles'}, | |
84 {h: 'steve', v: 'Steve Orvell'}, | |
85 {h: 'frankie', v: 'Frankie Fu'}, | |
86 {h: 'daniel', v: 'Daniel Freedman'}, | |
87 {h: 'yvonne', v: 'Yvonne Yip'}, | |
88 ], | |
89 | |
90 reorder: function(e) { | |
91 if (this.$.pages.transitioning.length) { | |
92 return; | |
93 } | |
94 | |
95 this.lastMoved = e.target; | |
96 this.lastMoved.style.zIndex = 10005; | |
97 var item = e.target.templateInstance.model; | |
98 var items = this.selected ? this.items : this.items2; | |
99 var i = this.selected ? this.items2.indexOf(item) : this.items.indexOf(i
tem); | |
100 if (i != 0) { | |
101 items.splice(0, 0, item); | |
102 items.splice(i + 1, 1); | |
103 } | |
104 | |
105 this.lastIndex = i; | |
106 this.selected = this.selected ? 0 : 1; | |
107 }, | |
108 | |
109 done: function() { | |
110 var i = this.lastIndex; | |
111 var items = this.selected ? this.items : this.items2; | |
112 var item = items[i]; | |
113 items.splice(0, 0, item); | |
114 items.splice(i + 1, 1); | |
115 this.lastMoved.style.zIndex = null; | |
116 } | |
117 }); | |
118 | |
119 </script> | |
120 | |
121 </polymer-element> | |
122 | |
123 <list-demo></list-demo> | |
124 | |
125 </body> | |
126 </html> | |
OLD | NEW |