|
15 | 15 | </div>
|
16 | 16 | <div description>
|
17 | 17 | <p>
|
18 |
| - <em>Adapter.remove</em> method allows to remove items from current buffer. |
| 18 | + <em>Adapter.remove</em> method allows to remove items from current buffer or/and virtually. |
19 | 19 | The argument of this method is an object of the following type:
|
20 | 20 | </p>
|
21 | 21 | <pre>{{argumentsDescription}}</pre>
|
22 | 22 | <p>
|
23 | 23 | The <em>predicate</em> option is a function applying to each item in the buffer.
|
24 | 24 | If the return value is true, the item will be removed.
|
25 |
| - Only a continuous series of items can be removed at a time. |
26 |
| - So, if you need to remove items 1, 2, 3 and 5, |
27 |
| - you need to call this method twice: once for 1, 2, 3 and then for 5. |
28 |
| - </p> |
29 |
| - <p> |
30 | 25 | The argument of the predicate has <em>ItemAdapter</em> type, and
|
31 | 26 | in this demo we have two versions of <em>predicate</em> using for
|
32 | 27 | removing by id and by index:
|
33 | 28 | </p>
|
34 | 29 | <pre>{{predicateDescription}}</pre>
|
35 | 30 | <p>
|
36 |
| - Indexes are adjusted each time we perform a removing from the buffer. |
| 31 | + Only a continuous series of items can be removed at a time using <em>predicate</em>. |
| 32 | + So, if you need to remove items 1, 2, 3 and 5, |
| 33 | + you need to call this method twice: once for 1, 2, 3 and then for 5. |
| 34 | + </p> |
| 35 | + <p> |
| 36 | + Instead of <em>predicate</em> running over buffered items, |
| 37 | + it is possible to remove items by <em>indexes</em>. |
| 38 | + It has no sequence limitation. |
| 39 | + This method works with both buffered and virtual items. |
| 40 | + For example, if we have [1..10] buffered items (they are rendered) |
| 41 | + and [11..100] virtual items (emulated via forward padding element |
| 42 | + which size corresponds to 90 virtual items) and the we perform |
| 43 | + <em>Adapter.remove({ indexes: [100] })</em>, we'll have |
| 44 | + the following: |
| 45 | + </p> |
| 46 | + <ul> |
| 47 | + <li>buffer is not affected</li> |
| 48 | + <li>the visible part of the viewport remains the same</li> |
| 49 | + <li> |
| 50 | + size of the forward padding is reduced by the size of the 100th item, |
| 51 | + so the scrollable area becomes slightly smaller |
| 52 | + </li> |
| 53 | + </ul> |
| 54 | + <p> |
| 55 | + Indexes are adjusted each time we perform a removing via Adapter. |
37 | 56 | It is impossible to remove item with id = 5 twice,
|
38 | 57 | because there is only one item with id = 5.
|
39 | 58 | But we may remove item with index = 5 as many times
|
40 |
| - as many items we have after this index. Indexes decrease by default. |
| 59 | + as many items we have after this index. |
41 | 60 | </p>
|
42 | 61 | <p>
|
43 |
| - The second option is <em>increase</em>. |
44 |
| - It is for changing the default indexes adjustment strategy. |
45 |
| - By setting it to <em>true</em>, we tell the <em>uiScroll</em> |
| 62 | + Indexes decrease by default, and the next option (<em>increase</em>) |
| 63 | + allows to change the default indexes adjustment strategy. |
| 64 | + By setting <em>increase</em> to <em>true</em>, we tell the <em>uiScroll</em> |
46 | 65 | that we want to increase indexes of the items before the removed one(s).
|
47 | 66 | </p>
|
48 | 67 | <p>
|
49 |
| - The very important thing is to synchronize our datasource with the changes |
| 68 | + The very important thing is to synchronize the datasource with the changes |
50 | 69 | we are making over the <em>uiScroll</em> buffer via <em>Adapter.remove</em>.
|
51 | 70 | Generally this is the App component responsibility,
|
52 | 71 | and in this demo it is done by the <em>removeFromDatasource</em> method.
|
|
0 commit comments