20
20
let dynamicList2: DynamicList ;
21
21
</script >
22
22
23
+ {#snippet itemRenderer (item : number | string )}
24
+ {#if typeof item == ' number' }
25
+ This is item #{item }
26
+ {:else }
27
+ <b >{item }</b >
28
+ {/if }
29
+ {/ snippet }
30
+
23
31
<h1 >Casterlabs UI Test Page</h1 >
24
32
25
33
Page Zoom:
@@ -167,11 +175,9 @@ Is at bottom?
167
175
<Box style ="flex: 1; height: 100%; padding: 0;" sides ={[' top' , ' bottom' , ' left' , ' right' ]}>
168
176
<InvertedScroller bind:this ={scroller } bind:isAtBottom ={isScrollerAtBottom }>
169
177
<ul >
170
- <li ><b >(end of list)</b ></li >
171
- {#each Array (SCROLL_ITEMS ) as _ , idx }
172
- <li >Item {idx + 1 }</li >
178
+ {#each [' (start of list)' , ... Array (100 ).keys (), ' This is an InvertedScroller (in a Box)' ] as item }
179
+ <li >{@render itemRenderer (item )}</li >
173
180
{/each }
174
- <li ><b >This is an InvertedScroller (in a Box)</b ></li >
175
181
</ul >
176
182
</InvertedScroller >
177
183
</Box >
@@ -180,11 +186,9 @@ Is at bottom?
180
186
sides ={[' top' , ' bottom' , ' right' ]}
181
187
>
182
188
<ul >
183
- <li ><b >This is a regular scrollable div (in a Box)</b ></li >
184
- {#each Array (SCROLL_ITEMS ) as _ , idx }
185
- <li >Item {idx + 1 }</li >
189
+ {#each [' This is a regular scrollable div (in a Box)' , ... Array (100 ).keys (), ' (end of list)' ] as item }
190
+ <li >{@render itemRenderer (item )}</li >
186
191
{/each }
187
- <li ><b >(end of list)</b ></li >
188
192
</ul >
189
193
</Box >
190
194
</div >
@@ -229,16 +233,20 @@ Is at bottom?
229
233
<Box style ="flex: 1; height: 100%; padding: 0;" sides ={[' top' , ' bottom' , ' left' , ' right' ]}>
230
234
<DynamicList
231
235
bind:this ={dynamicList1 }
232
- startWith ={[' This is an regular DynamicList (in a Box)' , ... Array (1_000 ).keys ()]}
236
+ startWith ={[
237
+ ' This is an regular DynamicList (in a Box)' ,
238
+ ... Array (1_000 ).keys (),
239
+ ' (end of list)'
240
+ ]}
233
241
bleed ={dynamicListBleed / 100 }
242
+ {itemRenderer }
234
243
>
235
- {#snippet itemRenderer (item : number | string )}
236
- {#if typeof item == ' number' }
237
- This is item #{item }
238
- {:else }
239
- <b >{item }</b >
240
- {/if }
241
- {/ snippet }
244
+ <!--
245
+ You can also:
246
+ {#snippet itemRenderer(item: any)}
247
+ ...
248
+ {/snippet}
249
+ -->
242
250
</DynamicList >
243
251
</Box >
244
252
<Box
@@ -248,17 +256,14 @@ Is at bottom?
248
256
<DynamicList
249
257
bind:this ={dynamicList2 }
250
258
inverted
251
- startWith ={[... Array (1_000 ).keys (), ' This is an inverted DynamicList (in a Box)' ]}
259
+ startWith ={[
260
+ ' (start of list)' ,
261
+ ... Array (1_000 ).keys (),
262
+ ' This is an inverted DynamicList (in a Box)'
263
+ ]}
252
264
bleed ={dynamicListBleed / 100 }
253
- >
254
- {#snippet itemRenderer (item : number | string )}
255
- {#if typeof item == ' number' }
256
- This is item #{item }
257
- {:else }
258
- <b >{item }</b >
259
- {/if }
260
- {/ snippet }
261
- </DynamicList >
265
+ {itemRenderer }
266
+ />
262
267
</Box >
263
268
{/ key }
264
269
</div >
0 commit comments