21
21
</span >
22
22
<span >
23
23
<button @mousedown =" showScroller = !showScroller" >Toggle scroller</button >
24
- <label ><input type =" checkbox" v-model =" scopedSlots" /> Scoped slots</label >
24
+ <label ><input type =" checkbox" v-model =" scopedSlots" :disabled =" recycleList" /> Scoped slots</label >
25
+ <label ><input type =" checkbox" v-model =" recycleList" /> Use recycle list</label >
25
26
</span >
26
27
27
28
</div >
28
29
<div class =" content" v-if =" showScroller" >
29
30
<div class =" wrapper" >
30
- <!-- Scoped slots -->
31
- <virtual-scroller v-if =" scopedSlots" class =" scroller" :item-height =" itemHeight" :items =" items" main-tag =" section" content-tag =" table" :buffer =" buffer" :pool-size =" poolSize" emit-update @update =" onUpdate" >
32
- <template slot-scope="props">
33
- <!-- <letter v-if="props.item.type === 'letter'" :item="props.item"></letter>-->
34
- <tr v-if =" props.item.type === 'letter'" class =" letter" :key =" props.itemKey" >
35
- <td class =" index" >
36
- {{props.item.index}}
37
- </td >
38
- <td >
39
- {{props.item.value}} Scoped
40
- </td >
41
- </tr >
42
- <item v-if =" props.item.type === 'person'" :item =" props.item" :key =" props.itemKey" ></item >
43
- </template >
44
- </virtual-scroller >
45
-
46
- <!-- Renderers -->
47
- <virtual-scroller v-else class =" scroller" :item-height =" itemHeight" :items =" items" :renderers =" renderers" type-field =" type" key-field =" index" main-tag =" section" content-tag =" table" :buffer =" buffer" :pool-size =" poolSize" emit-update @update =" onUpdate" />
31
+ <template v-if =" ! recycleList " >
32
+ <!-- Scoped slots -->
33
+ <virtual-scroller
34
+ v-if =" scopedSlots"
35
+ class =" scroller"
36
+ :item-height =" itemHeight"
37
+ :items =" items"
38
+ main-tag =" section"
39
+ content-tag =" table"
40
+ :buffer =" buffer"
41
+ :pool-size =" poolSize"
42
+ emit-update
43
+ @update =" onUpdate"
44
+ >
45
+ <template slot-scope="props">
46
+ <!-- <letter v-if="props.item.type === 'letter'" :item="props.item"></letter>-->
47
+ <tr v-if =" props.item.type === 'letter'" class =" letter" :key =" props.itemKey" >
48
+ <td class =" index" >
49
+ {{props.item.index}}
50
+ </td >
51
+ <td >
52
+ {{props.item.value}} Scoped
53
+ </td >
54
+ </tr >
55
+ <item v-if =" props.item.type === 'person'" :item =" props.item" :key =" props.itemKey" ></item >
56
+ </template >
57
+ </virtual-scroller >
58
+
59
+ <!-- Renderers -->
60
+ <virtual-scroller
61
+ v-else
62
+ class =" scroller"
63
+ :item-height =" itemHeight"
64
+ :items =" items"
65
+ :renderers =" renderers"
66
+ type-field =" type"
67
+ key-field =" index"
68
+ main-tag =" section"
69
+ content-tag =" table"
70
+ :buffer =" buffer"
71
+ :pool-size =" poolSize"
72
+ emit-update
73
+ @update =" onUpdate"
74
+ />
75
+ </template >
76
+
77
+ <template >
78
+ <recycle-list
79
+ ref =" scroller"
80
+ class =" scroller"
81
+ :items =" items"
82
+ :item-height =" itemHeight"
83
+ :buffer =" buffer"
84
+ >
85
+ <template slot-scope="props">
86
+ <tr
87
+ v-if =" props.item.type === 'letter'"
88
+ class =" letter big"
89
+ @click =" props.item.height = (props.item.height === 200 ? 300 : 200)"
90
+ >
91
+ <td class =" index" >
92
+ {{props.item.index}}
93
+ </td >
94
+ <td class =" value" >
95
+ {{props.item.value}} Scoped
96
+ </td >
97
+ </tr >
98
+ <item v-if =" props.item.type === 'person'" :item =" props.item" ></item >
99
+ </template >
100
+ </recycle-list >
101
+ </template >
48
102
</div >
49
103
</div >
50
104
</div >
@@ -79,6 +133,7 @@ export default {
79
133
poolSize: 2000 ,
80
134
enableLetters: true ,
81
135
updateCount: 0 ,
136
+ recycleList: true ,
82
137
}),
83
138
84
139
watch: {
@@ -110,6 +165,20 @@ export default {
110
165
},
111
166
},
112
167
168
+ updated () {
169
+ if (this ._dirty ) {
170
+ const time = Date .now ()
171
+ this .updateTime = time - this ._time
172
+ console .log (' update' , this .updateTime , ' ms' )
173
+ this ._dirty = false
174
+ }
175
+ },
176
+
177
+ mounted () {
178
+ this .$nextTick (this .generateItems )
179
+ window .scroller = this .$refs .scroller
180
+ },
181
+
113
182
methods: {
114
183
generateItems () {
115
184
console .log (' Generating ' + this .count + ' items...' )
@@ -126,19 +195,6 @@ export default {
126
195
this .updateCount ++
127
196
},
128
197
},
129
-
130
- updated () {
131
- if (this ._dirty ) {
132
- const time = Date .now ()
133
- this .updateTime = time - this ._time
134
- console .log (' update' , this .updateTime , ' ms' )
135
- this ._dirty = false
136
- }
137
- },
138
-
139
- mounted () {
140
- this .$nextTick (this .generateItems )
141
- },
142
198
}
143
199
</script >
144
200
@@ -196,19 +252,38 @@ body {
196
252
height : 100% ;
197
253
}
198
254
199
- .item-container {
255
+ .item-container ,
256
+ .item-wrapper {
200
257
box-sizing : border-box ;
201
258
}
202
259
203
- .item {
204
- height : 50 px ;
260
+ .item ,
261
+ .item-view {
205
262
cursor : pointer ;
206
263
user-select : none ;
207
264
-moz-user-select : none ;
208
265
-webkit-user-select : none ;
209
266
}
210
267
211
- .item :hover {
268
+ .item {
269
+ height : 50px ;
270
+ }
271
+
272
+ tr , td {
273
+ box-sizing : border-box ;
274
+ }
275
+
276
+ .item-view tr {
277
+ display : flex ;
278
+ align-items : center ;
279
+ }
280
+
281
+ .item-view td {
282
+ display : block ;
283
+ }
284
+
285
+ .item :hover ,
286
+ .item-view :hover {
212
287
background : #4fc08d ;
213
288
color : white ;
214
289
}
@@ -221,14 +296,26 @@ body {
221
296
222
297
.letter td {
223
298
padding : 12px ;
299
+ }
300
+
301
+ .item .letter td {
224
302
height : 200px ;
225
- box-sizing : border-box ;
303
+ }
304
+
305
+ .letter.big {
306
+ font-weight : normal ;
307
+ height : 200px ;
308
+ }
309
+
310
+ .letter.big .value {
311
+ font-size : 120px ;
226
312
}
227
313
228
314
.index {
229
315
color : rgba (0 , 0 , 0 , 0.2 );
230
316
width : 55px ;
231
317
text-align : right ;
318
+ flex : auto 0 0 ;
232
319
}
233
320
234
321
table {
@@ -249,5 +336,6 @@ table {
249
336
width : 50px ;
250
337
height : 50px ;
251
338
margin-right : 12px ;
339
+ background : grey ;
252
340
}
253
341
</style >
0 commit comments