|
3 | 3 | * @module ionic
|
4 | 4 | * @name collectionRepeat
|
5 | 5 | * @restrict A
|
| 6 | + * @codepen mFygh |
6 | 7 | * @description
|
7 | 8 | * `collection-repeat` is a directive that allows you to render lists with
|
8 | 9 | * thousands of items in them, and experience little to no performance penalty.
|
9 | 10 | *
|
10 |
| - * Demo: |
| 11 | + * Demo: |
11 | 12 | *
|
12 |
| - * The directive renders onto the screen only the items that should be currently visible. |
13 |
| - * So if you have 1,000 items in your list but only ten fit on your screen, |
| 13 | + * The directive renders onto the screen only the items that should be currently visible. |
| 14 | + * So if you have 1,000 items in your list but only ten fit on your screen, |
14 | 15 | * collection-repeat will only render into the DOM the ten that are in the current
|
15 | 16 | * scroll position.
|
16 | 17 | *
|
17 | 18 | * Here are a few things to keep in mind while using collection-repeat:
|
18 |
| - * |
| 19 | + * |
19 | 20 | * 1. The data supplied to collection-repeat must be an array.
|
20 |
| - * 2. You must explicitly tell the directive what size your items will be in the DOM |
| 21 | + * 2. You must explicitly tell the directive what size your items will be in the DOM |
21 | 22 | * (pixel amount or percentage), using directive attributes (see below).
|
22 | 23 | * 3. The elements rendered will be absolutely positioned: be sure to let your CSS work with this (see below).
|
23 | 24 | * 4. Keep the HTML of your repeated elements as simple as possible. As the user scrolls down, elements
|
24 |
| - * will be lazily compiled. Resultingly, the more complicated your elements, the more likely it is that |
| 25 | + * will be lazily compiled. Resultingly, the more complicated your elements, the more likely it is that |
25 | 26 | * the on-demand compilation will cause jankiness in the user's scrolling.
|
26 | 27 | * 5. The more elements you render on the screen at a time, the slower the scrolling will be.
|
27 | 28 | * It is recommended to keep grids of collection-repeat list elements at 3-wide or less.
|
28 |
| - * 6. Each collection-repeat list will take up all of its parent scrollView's space. |
29 |
| - * If you wish to have multiple lists on one page, put each list within its own |
| 29 | + * 6. Each collection-repeat list will take up all of its parent scrollView's space. |
| 30 | + * If you wish to have multiple lists on one page, put each list within its own |
30 | 31 | * {@link ionic.directive:ionScroll ionScroll} container.
|
31 | 32 | *
|
32 | 33 | *
|
|
37 | 38 | *
|
38 | 39 | * Notice two things here: we use ng-style to set the height of the item to match
|
39 | 40 | * what the repeater thinks our item height is. Additionally, we add a css rule
|
40 |
| - * to make our item stretch to fit the full screen (since it will be absolutely |
| 41 | + * to make our item stretch to fit the full screen (since it will be absolutely |
41 | 42 | * positioned).
|
42 | 43 | *
|
43 | 44 | * ```html
|
|
121 | 122 | *
|
122 | 123 | * For example: `item in items | filter:searchText track by item.id` is a pattern that might be used to apply a filter
|
123 | 124 | * to items in conjunction with a tracking expression.
|
124 |
| - * |
125 |
| - * @param {expression} collection-item-width The width of the repeated element. Can be a number (in pixels) or a percentage. |
| 125 | + * |
| 126 | + * @param {expression} collection-item-width The width of the repeated element. Can be a number (in pixels) or a percentage. |
126 | 127 | * @param {expression} collection-item-height The height of the repeated element. Can be a number (in pixels), or a percentage.
|
127 | 128 | *
|
128 | 129 | */
|
|
0 commit comments