1e41f4b71Sopenharmony_ci# List
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **List** component provides a list container that presents a series of list items arranged in a column with the same width. It supports presentations of the same type of data in a multiple and coherent row style, for example, images or text.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> - By default, this component can produce a bounce effect only when there is more than one screen of content. To produce a bounce effect when there is less than one screen of content, use the **options** parameter of the **edgeEffect** attribute.
10e41f4b71Sopenharmony_ci>
11e41f4b71Sopenharmony_ci> - The default value of the universal attribute [clip](ts-universal-attributes-sharp-clipping.md) is **true** for the **List** component.
12e41f4b71Sopenharmony_ci>
13e41f4b71Sopenharmony_ci> - To enable the editable mode for a list, the following conditions must be met: (This feature is deprecated since API version 9.)
14e41f4b71Sopenharmony_ci>
15e41f4b71Sopenharmony_ci>   - **editMode** is set to **true**.
16e41f4b71Sopenharmony_ci>
17e41f4b71Sopenharmony_ci>   - The list is bound to the **onItemDelete** event and the event returns **true** in the event callback.
18e41f4b71Sopenharmony_ci>
19e41f4b71Sopenharmony_ci>   - The **editable** attribute of **ListItem** is set to **true**.
20e41f4b71Sopenharmony_ci>
21e41f4b71Sopenharmony_ci> - To enable dragging for a list item, the following conditions must be met:
22e41f4b71Sopenharmony_ci>
23e41f4b71Sopenharmony_ci>   - **editMode** is set to **true**. (This is not required since API version 9.)
24e41f4b71Sopenharmony_ci>
25e41f4b71Sopenharmony_ci>   - The list item is bound to the **onDragStart** event and the event returns a floating UI during event callback.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci## Child Components
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ciOnly the [ListItem](ts-container-listitem.md) and [ListItemGroup](ts-container-listitemgroup.md) child components are allowed, with support for [if/else](../../../quick-start/arkts-rendering-control-ifelse.md), [ForEach](../../../quick-start/arkts-rendering-control-foreach.md), [LazyForEach](../../../quick-start/arkts-rendering-control-lazyforeach.md), and [Repeat](../../../quick-start/arkts-new-rendering-control-repeat.md) rendering control.
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci> **NOTE**
33e41f4b71Sopenharmony_ci>
34e41f4b71Sopenharmony_ci> Below are the rules for calculating the indexes of the child components of **List**:
35e41f4b71Sopenharmony_ci>
36e41f4b71Sopenharmony_ci> The index increases in ascending order of child components.
37e41f4b71Sopenharmony_ci>
38e41f4b71Sopenharmony_ci> In the **if/else** statement, only the child components for which the condition evaluates to true participate in the index calculation.
39e41f4b71Sopenharmony_ci>
40e41f4b71Sopenharmony_ci> In the **ForEach**, **LazyForEach**, or **Repeat** statement, the indexes of all expanded subnodes are calculated.
41e41f4b71Sopenharmony_ci>
42e41f4b71Sopenharmony_ci> After changes occur in [if/else](../../../quick-start/arkts-rendering-control-ifelse.md), [ForEach](../../../quick-start/arkts-rendering-control-foreach.md), [LazyForEach](../../../quick-start/arkts-rendering-control-lazyforeach.md), or [Repeat](../../../quick-start/arkts-new-rendering-control-repeat.md), the indexes of the child nodes are updated.
43e41f4b71Sopenharmony_ci>
44e41f4b71Sopenharmony_ci> Each **ListItemGroup** component is taken as a whole and assigned an index, and the indexes of the list items within are not included in the index calculation.
45e41f4b71Sopenharmony_ci>
46e41f4b71Sopenharmony_ci> Child components of **List** whose **visibility** attribute is set to **Hidden** or **None** are included in the index calculation.
47e41f4b71Sopenharmony_ci>
48e41f4b71Sopenharmony_ci> Child components of **List** whose **visibility** attribute is set to **None** are not displayed, but the spacing above and below them still takes effect.
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci## APIs
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ciList(value?:{space?: number | string, initialIndex?: number, scroller?: Scroller})
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci**Parameters**
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci| Name      | Type                                   | Mandatory| Description                                                    |
64e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- | ---- | ------------------------------------------------------------ |
65e41f4b71Sopenharmony_ci| space        | number \| string                  | No  | Spacing between list items along the main axis.<br>Default value: **0**<br>If the parameter type is number, the unit is vp.<br>**NOTE**<br>If this parameter is set to a negative number or a value greater than or equal to the length of the list content area, the default value is used.<br>If this parameter is set to a value less than the width of the list divider, the width of the list divider is used as the spacing.|
66e41f4b71Sopenharmony_ci| initialIndex | number                                      | No  | Item displayed at the beginning of the viewport when the current list is loaded for the first time, that is, the first item to be displayed.<br>Default value: **0**<br>**NOTE**<br>If the set value is a negative number or is greater than the index of the last item in the list, the value is invalid. In this case, the default value will be used.|
67e41f4b71Sopenharmony_ci| scroller     | [Scroller](ts-container-scroll.md#scroller) | No  | Scroller, which can be bound to scrollable components.<br>**NOTE**<br>The scroller cannot be bound to other scrollable components.|
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci## Attributes
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ciIn addition to [universal attributes](ts-universal-attributes-size.md) and [scrollable component common attributes](ts-container-scrollable-common.md#attributes), the following attributes are also supported.
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci### listDirection
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_cilistDirection(value: Axis)
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ciSets the direction in which the list items are arranged.
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci**Parameters**
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci| Name| Type                             | Mandatory| Description                                      |
88e41f4b71Sopenharmony_ci| ------ | --------------------------------- | ---- | ------------------------------------------ |
89e41f4b71Sopenharmony_ci| value  | [Axis](ts-appendix-enums.md#axis) | Yes  | Direction in which the list items are arranged.<br>Default value: **Axis.Vertical**|
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci### divider
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_cidivider(value: {strokeWidth: Length; color?: ResourceColor; startMargin?: Length; endMargin?: Length;} | null,)
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ciSets the style of the divider for the list items. By default, there is no divider.
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ciIf **endMargin** and **startMargin** add up to a value that exceeds the column width, they will be set to **0**.
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci**strokeWidth**, **startMargin**, and **endMargin** cannot be set in percentage.
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ciThe divider is drawn between list items along the main axis, and not above the first list item and below the last list item.
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ciIn multi-column mode, the value of **startMargin** is calculated from the start edge of the cross axis of each column. In other cases, it is calculated from the start edge of the cross axis of the list.
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ciWhen a list item has [polymorphic styles](ts-universal-attributes-polymorphic-style.md) applied, the dividers above and below the pressed child component are not rendered.
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci**Parameters**
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                                                        |
116e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
117e41f4b71Sopenharmony_ci| value  | {<br>strokeWidth: [Length](ts-types.md#length),<br>color?:[ResourceColor](ts-types.md#resourcecolor),<br>startMargin?: [Length](ts-types.md#length),<br>endMargin?: [Length](ts-types.md#length)<br>} \| null | Yes  | Style of the divider for the list items.<br>- **strokeWidth**: stroke width of the divider.<br>- **color**: color of the divider.<br>Default value: **0x08000000**<br>- **startMargin**: distance between the divider and the start edge of the list.<br>Default value: **0**, in vp<br>- **endMargin**: distance between the divider and the end edge of the list.<br>Default value: **0**, in vp|
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci### scrollBar
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ciscrollBar(value: BarState)
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ciSets the scrollbar state.
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci**Parameters**
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci| Name| Type                                     | Mandatory| Description                                                        |
134e41f4b71Sopenharmony_ci| ------ | ----------------------------------------- | ---- | ------------------------------------------------------------ |
135e41f4b71Sopenharmony_ci| value  | [BarState](ts-appendix-enums.md#barstate) | Yes  | Scrollbar state.<br>Default value: **BarState.Auto**<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **BarState.Off**. Since API version 10, the default value is **BarState.Auto**.|
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci### cachedCount
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_cicachedCount(value: number)
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ciSets the number of list items or list item groups to be preloaded (cached). In a lazy loading scenario, only the content equivalent to **cachedCount** outside the visible area of the list is preloaded. In a non-lazy loading scenario, all items are loaded at once. For both lazy and non-lazy loading, only the content within the list display area plus the content equivalent to **cachedCount** outside the display area is laid out. <!--Del-->For details, see [Minimizing White Blocks During Swiping](../../../performance/arkts-performance-improvement-recommendation.md#minimizing-white-blocks-during-swiping).<!--DelEnd-->
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ciWhen **cachedCount** is set for a list, the system preloads and lays out the **cachedCount**-specified number of rows of list items both above and below the currently visible area of the list. When calculating the number of rows for list items, the system takes into account the number of rows from the list items within a list item group. If a list item group does not contain any list items, then the entire list item group is counted as one row.
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ciWhen a list is nested with **LazyForEach**, and within **LazyForEach** there is a list item group, **LazyForEach** will create **cachedCount**-specified number of list item groups both above and below the currently visible area of the list.
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci**Parameters**
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                              |
156e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------------------- |
157e41f4b71Sopenharmony_ci| value  | number | Yes  | Number of list items or list item groups to be preloaded (cached).<br>Default value: **1**|
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci### editMode<sup>(deprecated)</sup>
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_cieditMode(value: boolean)
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ciSets whether to enable edit mode. For details about how to implement deletion of a selected list item, see [Example 3](#example-3).
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. There is no substitute API.
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci**Parameters**
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                              |
172e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------------------- |
173e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether to enable edit mode.<br>Default value: **false**|
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci### edgeEffect
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ciedgeEffect(value: EdgeEffect, options?: EdgeEffectOptions)
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ciSets the effect used when the scroll boundary is reached.
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci**Parameters**
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci| Name               | Type                                                        | Mandatory| Description                                                        |
190e41f4b71Sopenharmony_ci| --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
191e41f4b71Sopenharmony_ci| value                 | [EdgeEffect](ts-appendix-enums.md#edgeeffect)                | Yes  | Effect used when the scroll boundary is reached. The spring and shadow effects are supported.<br>Default value: **EdgeEffect.Spring**|
192e41f4b71Sopenharmony_ci| options<sup>11+</sup> | [EdgeEffectOptions](ts-container-scrollable-common.md#edgeeffectoptions11) | No  | Whether to enable the scroll effect when the component content is smaller than the component itself. The value **{ alwaysEnabled: true }** means to enable the scroll effect, and **{ alwaysEnabled: false }** means the opposite.<br>Default value: **{ alwaysEnabled: false }**|
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci### chainAnimation
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_cichainAnimation(value: boolean)
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ciSets whether to enable chained animations, which are displayed when the list slides or its top or bottom is dragged.
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ciThe list items are separated with even space, and one item animation starts after the previous animation during basic sliding interactions. The chained animation effect is similar with spring physics.
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ciWhen chained animations are in motion, the list divider is not displayed.
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ciThe following prerequisites must be met for the chained animations to take effect:
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci 1. The spring effect is used when the scroll boundary of the list is reached.
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci 2. The multi-column mode is not enabled for the list.
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci**Parameters**
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                                                        |
219e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------------------------ |
220e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether to enable chained animations.<br>**false** (default): Chained animations are disabled.<br>**true**: Chained animations are enabled. |
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci### multiSelectable<sup>8+</sup>
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_cimultiSelectable(value: boolean)
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ciSets whether to enable multiselect.
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci**Parameters**
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                                                        |
237e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------------------------ |
238e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether to enable multiselect.<br>**false** (default): Multiselect is disabled.<br>**true**: Multiselect is enabled. |
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci### lanes<sup>9+</sup>
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_cilanes(value: number | LengthConstrain, gutter?: Dimension)
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ciSets the number of columns or rows in the list. If the value is set to the **gutter** type, it indicates the gap between columns. It takes effect when the number of columns is greater than 1.
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ciThe rules are as follows:
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci- If the value is set to a number, the column width is calculated by dividing the cross-axis width of the **List** component by the specified number.
249e41f4b71Sopenharmony_ci- If the value is set to {minLength, maxLength}, the number of columns is adjusted adaptively based on the width of the **List** component, ensuring that the width respects the {minLength, maxLength} constraints during adaptation. The **minLength** constraint is prioritized.
250e41f4b71Sopenharmony_ci- If the value is set to {minLength, maxLength}, and the cross-axis width constraint of the parent component is infinite, the parent component is arranged by column, and the column width is calculated based on the largest list item in the display area.
251e41f4b71Sopenharmony_ci- Each list item group occupies one row in multi-column mode. Its child list items are arranged based on the **lanes** attribute of the list.
252e41f4b71Sopenharmony_ci- If the value is set to {minLength, maxLength}, the number of columns is calculated based on the cross-axis width of the list item group. If the cross-axis width of the list item group is different from that of the list, the number of columns in the list item group may be different from that in the list.
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci**Parameters**
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci| Name              | Type                                                        | Mandatory| Description                                    |
263e41f4b71Sopenharmony_ci| -------------------- | ------------------------------------------------------------ | ---- | ---------------------------------------- |
264e41f4b71Sopenharmony_ci| value                | number \| [LengthConstrain](ts-types.md#lengthconstrain) | Yes  | Number of columns or rows in the list.<br>Default value: **1**|
265e41f4b71Sopenharmony_ci| gutter<sup>10+</sup> | [Dimension](ts-types.md#dimension10)                         | No  | Gap between columns.<br>Default value: **0**                 |
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_ci### alignListItem<sup>9+</sup>
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_cialignListItem(value: ListItemAlign)
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ciAlignment mode of list items along the cross axis when the cross-axis width of the list is greater than the cross-axis width of list items multiplied by the value of **lanes**.
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci**Parameters**
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci| Name| Type                                    | Mandatory| Description                                                  |
282e41f4b71Sopenharmony_ci| ------ | ---------------------------------------- | ---- | ------------------------------------------------------ |
283e41f4b71Sopenharmony_ci| value  | [ListItemAlign](#listitemalign9) | Yes  | Alignment mode of list items along the cross axis.<br>Default value: **ListItemAlign.Start**|
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci### sticky<sup>9+</sup>
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_cisticky(value: StickyStyle)
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ciSets whether to pin the header to the top or the footer to the bottom in the [list item group](ts-container-listitemgroup.md), if set. To support both the pin-to-top and pin-to-bottom features, set **sticky** to **StickyStyle.Header \| StickyStyle.Footer**.
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci**Parameters**
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci| Name| Type                                | Mandatory| Description                                                      |
300e41f4b71Sopenharmony_ci| ------ | ------------------------------------ | ---- | ---------------------------------------------------------- |
301e41f4b71Sopenharmony_ci| value  | [StickyStyle](#stickystyle9) | Yes  | Whether to pin the header to the top or the footer to the bottom in the list item group.<br>Default value: **StickyStyle.None**|
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci### scrollSnapAlign<sup>10+</sup>
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ciscrollSnapAlign(value: ScrollSnapAlign)
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ciSets the alignment mode of list items when scrolling ends.
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ciThis attribute is effective only when the heights of list items are the same.
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ciIt does not take effect after scrolling by a touchpad or mouse device ends.
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci**Parameters**
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci| Name| Type                                         | Mandatory| Description                                                     |
320e41f4b71Sopenharmony_ci| ------ | --------------------------------------------- | ---- | --------------------------------------------------------- |
321e41f4b71Sopenharmony_ci| value  | [ScrollSnapAlign](#scrollsnapalign10) | Yes  | Alignment mode of list items when scrolling ends.<br>Default value: **ScrollSnapAlign.NONE**|
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci### enableScrollInteraction<sup>10+</sup>
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_cienableScrollInteraction(value: boolean)
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ciSets whether to support scroll gestures. When this attribute is set to **false**, scrolling by finger or mouse is not supported, but the scroll controller API is not affected.
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci**Parameters**
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                               |
336e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ----------------------------------- |
337e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether to support scroll gestures.<br>Default value: **true**|
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci### nestedScroll<sup>10+</sup>
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_cinestedScroll(value: NestedScrollOptions)
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ciSets the nested scrolling options. You can set the nested scrolling mode in the forward and backward directions to implement scrolling linkage with the parent component.
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci**Parameters**
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description          |
352e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | -------------- |
353e41f4b71Sopenharmony_ci| value  | [NestedScrollOptions](ts-container-scrollable-common.md#nestedscrolloptions10) | Yes  | Nested scrolling options.|
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci### friction<sup>10+</sup>
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_cifriction(value: number | Resource)
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ciSets the friction coefficient. It applies only to gestures in the scrolling area, and it affects only indirectly the scroll chaining during the inertial scrolling process. A value less than or equal to 0 evaluates to the default value.
360e41f4b71Sopenharmony_ci
361e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci**Parameters**
366e41f4b71Sopenharmony_ci
367e41f4b71Sopenharmony_ci| Name| Type                                                | Mandatory| Description                                                        |
368e41f4b71Sopenharmony_ci| ------ | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
369e41f4b71Sopenharmony_ci| value  | number \| [Resource](ts-types.md#resource) | Yes  | Friction coefficient.<br>Default value: **0.9** for wearable devices and **0.6** for non-wearable devices.<br>Since API version 11, the default value for non-wearable devices is **0.7**.<br>Since API version 12, the default value for non-wearable devices is **0.75**.|
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ci### contentStartOffset<sup>11+</sup>
372e41f4b71Sopenharmony_ci
373e41f4b71Sopenharmony_cicontentStartOffset(value: number)
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ciSets the offset from the start of the list content to the boundary of the list display area.
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
380e41f4b71Sopenharmony_ci
381e41f4b71Sopenharmony_ci**Parameters**
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                           |
384e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ----------------------------------------------- |
385e41f4b71Sopenharmony_ci| value  | number | Yes  | Offset from the start of the list content to the boundary of the list display area.<br>Default value: **0**<br>Unit: vp|
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci### contentEndOffset<sup>11+</sup>
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_cicontentEndOffset(value: number)
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_ciSets the offset from the end of the list content to the boundary of the list display area.
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci**Parameters**
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                         |
400e41f4b71Sopenharmony_ci| ------ | ------ | ---- | --------------------------------------------- |
401e41f4b71Sopenharmony_ci| value  | number | Yes  | Offset from the end of the list content to the boundary of the list display area.<br>Default value: **0**<br>Unit: vp|
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci### childrenMainSize<sup>12+</sup>
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_cichildrenMainSize(value: ChildrenMainSize)
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ciSets the size information of the child components of a **List** component along the main axis.
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci**Parameters**
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory| Description                           |
416e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ------------------------------- |
417e41f4b71Sopenharmony_ci| value | [ChildrenMainSize](ts-container-scrollable-common.md#childrenmainsize12) | Yes  | 1. Purpose:<br>By providing a **ChildrenMainSize** object to the **List** component, it accurately conveys the size information of all child components along the main axis. This enables the **List** component to maintain an accurate scroll position even when child components have varying sizes on the main axis, when child components are added or removed, or when [scrollToIndex](ts-container-scroll.md#scrolltoindex) is used. This ensures that [scrollTo](ts-container-scroll.md#scrollto) can jump to an exact specified location, [currentOffset](ts-container-scroll.md#currentoffset) can obtain the current exact scroll position, and the built-in scrollbar can move smoothly without any discontinuities.<br>2. Constraints:<br>(1) The provided size along the main axis must be consistent with the actual size of the child components on the main axis. Any changes in size or additions/removals of child components must be communicated to the **List** component through the **ChildrenMainSize** object method.<br>(2) When the child component is a list item group, the overall size of the list item group along the main axis must be accurately calculated based on the number of columns in the list item group, the spacing between list items along the main axis, and the size of the header, footer, and list items within the list item group. The calculated size must then be provided to the **List** component.<br>(3) If child components include list item groups, the **childrenMainSize** attribute must be set for each individual list item group. Each list item group, as well as the **List** component itself, must be bound one-to-one with a **ChildrenMainSize** object through the **childrenMainSize** attribute.<br>(4) For a multi-column list where child components are generated using **LazyForEach**, ensure that **LazyForEach** generates either all **ListItemGroup** components or all** ListItem** components. |
418e41f4b71Sopenharmony_ci
419e41f4b71Sopenharmony_ci## ListItemAlign<sup>9+</sup>
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
426e41f4b71Sopenharmony_ci
427e41f4b71Sopenharmony_ci| Name    |  Value | Description                       |
428e41f4b71Sopenharmony_ci| ------ | ------ | ------------------------- |
429e41f4b71Sopenharmony_ci| Start  | 0 | The list items are packed toward the start edge of the **List** component along the cross axis.|
430e41f4b71Sopenharmony_ci| Center | 1 | The list items are centered in the **List** component along the cross axis.|
431e41f4b71Sopenharmony_ci| End    | 2 | The list items are packed toward the end edge of the **List** component along the cross axis.|
432e41f4b71Sopenharmony_ci
433e41f4b71Sopenharmony_ci## StickyStyle<sup>9+</sup>
434e41f4b71Sopenharmony_ci
435e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
438e41f4b71Sopenharmony_ci
439e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ci| Name    |  Value | Description                                |
442e41f4b71Sopenharmony_ci| ------ | ------ | ---------------------------------- |
443e41f4b71Sopenharmony_ci| None   | 0 | In the **ListItemGroup** component, the header is not pinned to the top, and the footer is not pinned to the bottom.|
444e41f4b71Sopenharmony_ci| Header | 1 | In the **ListItemGroup** component, the header is pinned to the top, and the footer is not pinned to the bottom. |
445e41f4b71Sopenharmony_ci| Footer | 2 | In the **ListItemGroup** component, the footer is pinned to the bottom, and the header is not pinned to the top. |
446e41f4b71Sopenharmony_ci
447e41f4b71Sopenharmony_ci## ScrollSnapAlign<sup>10+</sup>
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_ciEnumerates the alignment modes of list items when scrolling ends.
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ciWhen list items are left-, right-, top-, or bottom-aligned, the items at the end must be completely displayed, without exposure of any blank area of the boundary; the items at the other end can be out of alignment.
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ciThis API is available only when the heights of list items are the same.
454e41f4b71Sopenharmony_ci
455e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
456e41f4b71Sopenharmony_ci
457e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
458e41f4b71Sopenharmony_ci
459e41f4b71Sopenharmony_ci| Name    |  Value | Description                                      |
460e41f4b71Sopenharmony_ci| ------ | ------ | ---------------------------------------- |
461e41f4b71Sopenharmony_ci| NONE   | 0 | No alignment. This is the default value.           |
462e41f4b71Sopenharmony_ci| START  | 1 | The first item in the view is aligned at the start of the list.<br>**NOTE**<br>When the list hits the end, the items at the end must be completely displayed. In this case, the items at the start may not be aligned.|
463e41f4b71Sopenharmony_ci| CENTER | 2 | The middle items in the view are aligned in the center of the list.<br>**NOTE**<br>The top and end items can be aligned in the center of the list. In this case, a blank area may result,<br>and the first or last item is aligned to the center of the list.|
464e41f4b71Sopenharmony_ci| END    | 3 | The last item in the view is aligned at the end of the list.<br>**NOTE**<br>When the list hits the start, the items at the start must be completely displayed. In this case, the items at the end may not be aligned.|
465e41f4b71Sopenharmony_ci## CloseSwipeActionOptions<sup>11+</sup>
466e41f4b71Sopenharmony_ci
467e41f4b71Sopenharmony_ciImplements the callbacks and events for the [ListItem](ts-container-listitem.md) in the [expanded](ts-container-listitem.md#swipeactionstate11) state.
468e41f4b71Sopenharmony_ci
469e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
470e41f4b71Sopenharmony_ci
471e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
472e41f4b71Sopenharmony_ci
473e41f4b71Sopenharmony_ci| Name    | Type    | Mandatory| Description                  |
474e41f4b71Sopenharmony_ci| :------- | -------- | ---- | ---------------------- |
475e41f4b71Sopenharmony_ci| onFinish | ()=>void | No  | Triggered after the collapse animation is complete.|
476e41f4b71Sopenharmony_ci
477e41f4b71Sopenharmony_ci## Events
478e41f4b71Sopenharmony_ci
479e41f4b71Sopenharmony_ciIn addition to [universal events](ts-universal-events-click.md) and [scrollable component common events](ts-container-scrollable-common.md#events), the following events are also supported.
480e41f4b71Sopenharmony_ci
481e41f4b71Sopenharmony_ci### onItemDelete<sup>(deprecated)</sup>
482e41f4b71Sopenharmony_ci
483e41f4b71Sopenharmony_cionItemDelete(event: (index: number) => boolean)
484e41f4b71Sopenharmony_ci
485e41f4b71Sopenharmony_ciTriggered when a list item is deleted.
486e41f4b71Sopenharmony_ci
487e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. There is no substitute API.
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
490e41f4b71Sopenharmony_ci
491e41f4b71Sopenharmony_ci**Parameters**
492e41f4b71Sopenharmony_ci
493e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                    |
494e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------ |
495e41f4b71Sopenharmony_ci| index  | number | Yes  | Index of the deleted list item.|
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_ci**Return value**
498e41f4b71Sopenharmony_ci
499e41f4b71Sopenharmony_ci| Type   | Description          |
500e41f4b71Sopenharmony_ci| ------- | -------------- |
501e41f4b71Sopenharmony_ci| boolean | Whether the list item is deleted.|
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci### onScrollIndex
504e41f4b71Sopenharmony_ci
505e41f4b71Sopenharmony_cionScrollIndex(event: (start: number, end: number, center: number) => void)
506e41f4b71Sopenharmony_ci
507e41f4b71Sopenharmony_ciTriggered when a child component enters or leaves the list display area. During index calculation, each **ListItemGroup** component is taken as a whole and assigned an index, and the indexes of the list items within are not included in the calculation.
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_ciWhen the list edge scrolling effect is the spring effect, the **onScrollIndex** event is not triggered when the user scrolls the list to the edge or releases the list to rebound.
510e41f4b71Sopenharmony_ci
511e41f4b71Sopenharmony_ciThis event is triggered once when the list is initialized and when the index of the first list item or the next list item in the list display area changes.
512e41f4b71Sopenharmony_ci
513e41f4b71Sopenharmony_ciSince API version 10, this event is also triggered when the child component in the center of the list display area changes.
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
516e41f4b71Sopenharmony_ci
517e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_ci**Parameters**
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ci| Name              | Type  | Mandatory| Description                                  |
524e41f4b71Sopenharmony_ci| -------------------- | ------ | ---- | -------------------------------------- |
525e41f4b71Sopenharmony_ci| start                | number | Yes  | Index of the first child component in the list display area.    |
526e41f4b71Sopenharmony_ci| end                  | number | Yes  | Index of the last child component in the list display area.|
527e41f4b71Sopenharmony_ci| center<sup>10+</sup> | number | Yes  | Index of the center child component in the list display area.|
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci### onReachStart
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_cionReachStart(event: () => void)
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ciTriggered when the list reaches the start position.
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ciThis event is triggered once when **initialIndex** is **0** during list initialization and once when the list scrolls to the start position. When the list edge scrolling effect is the spring effect, this event is triggered once when the list passes the start position and is triggered again when the list returns to the start position.
536e41f4b71Sopenharmony_ci
537e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
540e41f4b71Sopenharmony_ci
541e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
542e41f4b71Sopenharmony_ci
543e41f4b71Sopenharmony_ci### onReachEnd
544e41f4b71Sopenharmony_ci
545e41f4b71Sopenharmony_cionReachEnd(event: () => void)
546e41f4b71Sopenharmony_ci
547e41f4b71Sopenharmony_ciTriggered when the list reaches the end position.
548e41f4b71Sopenharmony_ci
549e41f4b71Sopenharmony_ciWhen the list edge scrolling effect is the spring effect, this event is triggered once when the list passes the end position and is triggered again when the list returns to the end position.
550e41f4b71Sopenharmony_ci
551e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
556e41f4b71Sopenharmony_ci
557e41f4b71Sopenharmony_ci### onScrollFrameBegin<sup>9+</sup>
558e41f4b71Sopenharmony_ci
559e41f4b71Sopenharmony_cionScrollFrameBegin(event: (offset: number, state: ScrollState) => { offsetRemain: number })
560e41f4b71Sopenharmony_ci
561e41f4b71Sopenharmony_ciTriggered when the list starts to scroll. The input parameters indicate the amount by which the list will scroll. The event handler then works out the amount by which the list needs to scroll based on the real-world situation and returns the result.
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_ciIf **listDirection** is set to **Axis.Vertical**, the return value is the amount by which the list needs to scroll in the vertical direction. If **listDirection** is set to **Axis.Horizontal**, the return value is the amount by which the list needs to scroll in the horizontal direction.
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_ciThis event is triggered when the user starts dragging the list or the list starts inertial scrolling. It is not triggered when the component rebounds, the scrolling controller is used, or the scrollbar is dragged.
566e41f4b71Sopenharmony_ci
567e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
568e41f4b71Sopenharmony_ci
569e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
570e41f4b71Sopenharmony_ci
571e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ci**Parameters**
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ci| Name| Type                               | Mandatory| Description                      |
576e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | -------------------------- |
577e41f4b71Sopenharmony_ci| offset | number                              | Yes  | Amount to scroll by, in vp.|
578e41f4b71Sopenharmony_ci| state  | [ScrollState](#scrollstate) | Yes  | Current scroll state.            |
579e41f4b71Sopenharmony_ci
580e41f4b71Sopenharmony_ci**Return value**
581e41f4b71Sopenharmony_ci
582e41f4b71Sopenharmony_ci| Type                    | Description                |
583e41f4b71Sopenharmony_ci| ------------------------ | -------------------- |
584e41f4b71Sopenharmony_ci| { offsetRemain: number } | Actual amount by which the grid scrolls, in vp.|
585e41f4b71Sopenharmony_ci
586e41f4b71Sopenharmony_ci### onScrollStart<sup>9+</sup>
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_cionScrollStart(event: () => void)
589e41f4b71Sopenharmony_ci
590e41f4b71Sopenharmony_ciTriggered when the list starts scrolling initiated by the user's finger dragging the list or its scrollbar. This event is also triggered when the animation contained in the scrolling triggered by [Scroller](ts-container-scroll.md#scroller) starts.
591e41f4b71Sopenharmony_ci
592e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
593e41f4b71Sopenharmony_ci
594e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ci### onScrollStop
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_cionScrollStop(event: () => void)
601e41f4b71Sopenharmony_ci
602e41f4b71Sopenharmony_ciTriggered when the list stops scrolling after the user's finger leaves the screen. This event is also triggered when the animation contained in the scrolling triggered by [Scroller](ts-container-scroll.md#scroller) stops.
603e41f4b71Sopenharmony_ci
604e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
605e41f4b71Sopenharmony_ci
606e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
607e41f4b71Sopenharmony_ci
608e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
609e41f4b71Sopenharmony_ci
610e41f4b71Sopenharmony_ci### onItemMove
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_cionItemMove(event: (from: number, to: number) => boolean)
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ciTriggered when a list item moves.
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci**Parameters**
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description          |
623e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------- |
624e41f4b71Sopenharmony_ci| from   | number | Yes  | Index of the item before moving.|
625e41f4b71Sopenharmony_ci| to     | number | Yes  | Index of the item after moving.|
626e41f4b71Sopenharmony_ci
627e41f4b71Sopenharmony_ci**Return value**
628e41f4b71Sopenharmony_ci
629e41f4b71Sopenharmony_ci| Type   | Description          |
630e41f4b71Sopenharmony_ci| ------- | -------------- |
631e41f4b71Sopenharmony_ci| boolean | Whether the item is moved.|
632e41f4b71Sopenharmony_ci
633e41f4b71Sopenharmony_ci### onItemDragStart<sup>8+</sup>
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_cionItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => ((() => any) \| void))
636e41f4b71Sopenharmony_ci
637e41f4b71Sopenharmony_ciTriggered when a list item starts to be dragged.
638e41f4b71Sopenharmony_ci
639e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
640e41f4b71Sopenharmony_ci
641e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
642e41f4b71Sopenharmony_ci
643e41f4b71Sopenharmony_ci**Parameters**
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_ci| Name   | Type                                                     | Mandatory| Description                  |
646e41f4b71Sopenharmony_ci| --------- | --------------------------------------------------------- | ---- | ---------------------- |
647e41f4b71Sopenharmony_ci| event     | [ItemDragInfo](ts-container-scrollable-common.md#itemdraginfo) | Yes  | Information about the drag point.        |
648e41f4b71Sopenharmony_ci| itemIndex | number                                                    | Yes  | Index of the dragged item.|
649e41f4b71Sopenharmony_ci
650e41f4b71Sopenharmony_ci### onItemDragEnter<sup>8+</sup>
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_cionItemDragEnter(event: (event: ItemDragInfo) => void)
653e41f4b71Sopenharmony_ci
654e41f4b71Sopenharmony_ciTriggered when the dragged item enters the drop target of the list.
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ci**Parameters**
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ci| Name| Type                                                     | Mandatory| Description          |
663e41f4b71Sopenharmony_ci| ------ | --------------------------------------------------------- | ---- | -------------- |
664e41f4b71Sopenharmony_ci| event  | [ItemDragInfo](ts-container-scrollable-common.md#itemdraginfo) | Yes  | Information about the drag point.|
665e41f4b71Sopenharmony_ci
666e41f4b71Sopenharmony_ci### onItemDragMove<sup>8+</sup>
667e41f4b71Sopenharmony_ci
668e41f4b71Sopenharmony_cionItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void)
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_ciTriggered when the dragged item moves over the drop target of the list.
671e41f4b71Sopenharmony_ci
672e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
673e41f4b71Sopenharmony_ci
674e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
675e41f4b71Sopenharmony_ci
676e41f4b71Sopenharmony_ci**Parameters**
677e41f4b71Sopenharmony_ci
678e41f4b71Sopenharmony_ci| Name     | Type                                                     | Mandatory| Description          |
679e41f4b71Sopenharmony_ci| ----------- | --------------------------------------------------------- | ---- | -------------- |
680e41f4b71Sopenharmony_ci| event       | [ItemDragInfo](ts-container-scrollable-common.md#itemdraginfo) | Yes  | Information about the drag point.|
681e41f4b71Sopenharmony_ci| itemIndex   | number                                                    | Yes  | Initial position of the dragged item.|
682e41f4b71Sopenharmony_ci| insertIndex | number                                                    | Yes  | Index of the position to which the dragged item is dropped.|
683e41f4b71Sopenharmony_ci
684e41f4b71Sopenharmony_ci### onItemDragLeave<sup>8+</sup>
685e41f4b71Sopenharmony_ci
686e41f4b71Sopenharmony_cionItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void)
687e41f4b71Sopenharmony_ci
688e41f4b71Sopenharmony_ciTriggered when the dragged item leaves the drop target of the list.
689e41f4b71Sopenharmony_ci
690e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
691e41f4b71Sopenharmony_ci
692e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
693e41f4b71Sopenharmony_ci
694e41f4b71Sopenharmony_ci**Parameters**
695e41f4b71Sopenharmony_ci
696e41f4b71Sopenharmony_ci| Name   | Type                                                     | Mandatory| Description                      |
697e41f4b71Sopenharmony_ci| --------- | --------------------------------------------------------- | ---- | -------------------------- |
698e41f4b71Sopenharmony_ci| event     | [ItemDragInfo](ts-container-scrollable-common.md#itemdraginfo) | Yes  | Information about the drag point.            |
699e41f4b71Sopenharmony_ci| itemIndex | number                                                    | Yes  | Index of the dragged item.|
700e41f4b71Sopenharmony_ci
701e41f4b71Sopenharmony_ci### onItemDrop<sup>8+</sup>
702e41f4b71Sopenharmony_ci
703e41f4b71Sopenharmony_cionItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void)
704e41f4b71Sopenharmony_ci
705e41f4b71Sopenharmony_ciTriggered when the dragged item is dropped on the drop target of the list.
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ciDuring dragging across lists, **true** is returned if the drop target is bound to **onItemDrop**. Otherwise, **false** is returned. During dragging within a list, **isSuccess** is the return value of the **onItemMove** event.
708e41f4b71Sopenharmony_ci
709e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
710e41f4b71Sopenharmony_ci
711e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_ci**Parameters**
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_ci| Name     | Type                                                     | Mandatory| Description          |
716e41f4b71Sopenharmony_ci| ----------- | --------------------------------------------------------- | ---- | -------------- |
717e41f4b71Sopenharmony_ci| event       | [ItemDragInfo](ts-container-scrollable-common.md#itemdraginfo) | Yes  | Information about the drag point.|
718e41f4b71Sopenharmony_ci| itemIndex   | number                                                    | Yes  | Initial position of the dragged item.|
719e41f4b71Sopenharmony_ci| insertIndex | number                                                    | Yes  | Index of the position to which the dragged item is dropped.|
720e41f4b71Sopenharmony_ci| isSuccess   | boolean                                                   | Yes  | Whether the dragged item is successfully dropped.  |
721e41f4b71Sopenharmony_ci
722e41f4b71Sopenharmony_ci
723e41f4b71Sopenharmony_ci### onScroll<sup>(deprecated)</sup>
724e41f4b71Sopenharmony_cionScroll(event: (scrollOffset: number, scrollState: [ScrollState](#scrollstate)) => void) 
725e41f4b71Sopenharmony_ci
726e41f4b71Sopenharmony_ciTriggered when the list scrolls.
727e41f4b71Sopenharmony_ci
728e41f4b71Sopenharmony_ciThis API is deprecated since API version 12. You are advised to use [onDidScroll](#ondidscroll12) instead.
729e41f4b71Sopenharmony_ci
730e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
731e41f4b71Sopenharmony_ci
732e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
733e41f4b71Sopenharmony_ci
734e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
735e41f4b71Sopenharmony_ci
736e41f4b71Sopenharmony_ci**Parameters**
737e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
738e41f4b71Sopenharmony_ci| ------ | ------ | ------ | ------|
739e41f4b71Sopenharmony_ci| scrollOffset | number | Yes| Scroll offset of each frame. The offset is positive when the list is scrolled up and negative when the list is scrolled down.<br>Unit: vp|
740e41f4b71Sopenharmony_ci| scrollState | [ScrollState](ts-container-list.md#scrollstate) | Yes| Current scroll state.|
741e41f4b71Sopenharmony_ci
742e41f4b71Sopenharmony_ci### onWillScroll<sup>12+</sup>
743e41f4b71Sopenharmony_cionWillScroll(handler: Optional&lt;OnWillScrollCallback&gt;)
744e41f4b71Sopenharmony_ci
745e41f4b71Sopenharmony_ciTriggered when the list is about to scroll. The callback provides the amount of offset that is about to be scrolled in the current frame, along with the current scroll state and the source of the scroll operation. The offset provided in the callback is the calculated intended scrolling offset, not the final actual scrolling offset. You can specify the intended scrolling offset through the return value of this callback.
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 12.
748e41f4b71Sopenharmony_ci
749e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
750e41f4b71Sopenharmony_ci
751e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
752e41f4b71Sopenharmony_ci
753e41f4b71Sopenharmony_ci**Parameters**
754e41f4b71Sopenharmony_ci
755e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
756e41f4b71Sopenharmony_ci| ------ | ------ | ------ | ------|
757e41f4b71Sopenharmony_ci| handler | Optional&lt;[OnWillScrollCallback](ts-container-scrollable-common.md#onwillscrollcallback12)&gt; | Yes| Callback invoked when the list is about to scroll.|
758e41f4b71Sopenharmony_ci
759e41f4b71Sopenharmony_ci> **NOTE**
760e41f4b71Sopenharmony_ci> 
761e41f4b71Sopenharmony_ci> When **ScrollEdge** and **ScrollToIndex** that does not involve animation is called, **onWillScroll** is not invoked.
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci### onDidScroll<sup>12+</sup>
764e41f4b71Sopenharmony_cionDidScroll(handler: OnScrollCallback)
765e41f4b71Sopenharmony_ci
766e41f4b71Sopenharmony_ciTriggered when the list scrolls. The return value is the offset amount by which the list has scrolled and the current scroll state.
767e41f4b71Sopenharmony_ci
768e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 12.
769e41f4b71Sopenharmony_ci
770e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
771e41f4b71Sopenharmony_ci
772e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
773e41f4b71Sopenharmony_ci
774e41f4b71Sopenharmony_ci**Parameters**
775e41f4b71Sopenharmony_ci
776e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
777e41f4b71Sopenharmony_ci| ------ | ------ | ------ | ------|
778e41f4b71Sopenharmony_ci| handler | [OnScrollCallback](ts-container-scrollable-common.md#onscrollcallback12) | Yes| Callback invoked when the list scrolls.|
779e41f4b71Sopenharmony_ci
780e41f4b71Sopenharmony_ci### onScrollVisibleContentChange<sup>12+</sup>
781e41f4b71Sopenharmony_cionScrollVisibleContentChange(handler: OnScrollVisibleContentChangeCallback)
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ciTriggered when a child component enters or leaves the list display area. During index calculation, list item, header of the list item group, and footer of the list item group each are counted as a child component.
784e41f4b71Sopenharmony_ci
785e41f4b71Sopenharmony_ciWhen the list edge scrolling effect is the spring effect, the **onScrollVisibleContentChange** event is not triggered when the user scrolls the list to the edge or releases the list to rebound.
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ciThis event is triggered once when the list is initialized and when the index of the first child component or the next child component in the list display area changes.
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
790e41f4b71Sopenharmony_ci
791e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
792e41f4b71Sopenharmony_ci
793e41f4b71Sopenharmony_ci**Parameters**
794e41f4b71Sopenharmony_ci
795e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
796e41f4b71Sopenharmony_ci| ------ | ------ | ------ | ------|
797e41f4b71Sopenharmony_ci| handler | [OnScrollVisibleContentChangeCallback](#onscrollvisiblecontentchangecallback12) | Yes| Callback invoked when the displayed content changes.|
798e41f4b71Sopenharmony_ci
799e41f4b71Sopenharmony_ci## ScrollState
800e41f4b71Sopenharmony_ci
801e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 9.
802e41f4b71Sopenharmony_ci
803e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
804e41f4b71Sopenharmony_ci
805e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
806e41f4b71Sopenharmony_ci
807e41f4b71Sopenharmony_ci| Name    |  Value | Description                                      |
808e41f4b71Sopenharmony_ci| ------ | ------ | ---------------------------------------- |
809e41f4b71Sopenharmony_ci| Idle   |  0  | Idle state. Triggered when the scroll state returns to idle, and when the controller's non-animated methods are used to control the scroll.|
810e41f4b71Sopenharmony_ci| Scroll |  1  | Scrolling state. Triggered when the list is dragged with the finger, when the scrollbar is dragged, or when the mouse scroll wheel is used.|
811e41f4b71Sopenharmony_ci| Fling  |  2  | Inertial scrolling state. Triggered by all animated scroll actions. This includes:<br>- Inertial scrolling that occurs after a fling<br>- Bounce-back scrolling when the swipe reaches the edge<br>- Inertial scrolling after quickly dragging the built-in scrollbar and releasing<br>- Scrolling controlled by the animated methods provided by the scroller |
812e41f4b71Sopenharmony_ci
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ci## ListScroller<sup>11+</sup>
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_ciImplements the scroll controller of the **List** component. A **List** component is bound to a **ListScroller** on a one-to-one basis.
817e41f4b71Sopenharmony_ci
818e41f4b71Sopenharmony_ci
819e41f4b71Sopenharmony_ci>  **NOTE**
820e41f4b71Sopenharmony_ci>
821e41f4b71Sopenharmony_ci>  **ListScroller** inherits from [Scroller](ts-container-scroll.md#scroller) and has all methods of [Scroller](ts-container-scroll.md#scroller).
822e41f4b71Sopenharmony_ci
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ci### Objects to Import
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_ci```
827e41f4b71Sopenharmony_cilistScroller: ListScroller = new ListScroller()
828e41f4b71Sopenharmony_ci```
829e41f4b71Sopenharmony_ci
830e41f4b71Sopenharmony_ci
831e41f4b71Sopenharmony_ci### getItemRectInGroup<sup>11+</sup>
832e41f4b71Sopenharmony_ci
833e41f4b71Sopenharmony_cigetItemRectInGroup(index: number, indexInGroup: number): RectResult
834e41f4b71Sopenharmony_ci
835e41f4b71Sopenharmony_ciObtains the size of a [list item](ts-container-listitem.md) in a [list item group](ts-container-listitemgroup.md) and its position relative to the list.
836e41f4b71Sopenharmony_ci
837e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
838e41f4b71Sopenharmony_ci
839e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
840e41f4b71Sopenharmony_ci
841e41f4b71Sopenharmony_ci**Parameters**
842e41f4b71Sopenharmony_ci
843e41f4b71Sopenharmony_ci| Name  | Type  | Mandatory  | Description             |
844e41f4b71Sopenharmony_ci| ----- | ------ | ---- | ----------------- |
845e41f4b71Sopenharmony_ci| index | number | Yes   | Index of the list item group in the list.|
846e41f4b71Sopenharmony_ci| indexInGroup | number | Yes   | Index of the list item in the list item group.|
847e41f4b71Sopenharmony_ci
848e41f4b71Sopenharmony_ci> **NOTE**
849e41f4b71Sopenharmony_ci>
850e41f4b71Sopenharmony_ci> - The value of **index** must be the index of a child component visible in the display area. Otherwise, the value is considered invalid.
851e41f4b71Sopenharmony_ci> - The child component for which **index** is set must be a list item group. Otherwise, the **index **value is considered invalid.
852e41f4b71Sopenharmony_ci> - The value of **indexInGroup** must be the index of a list item in the list item group visible in the display area. Otherwise, the value is considered invalid.
853e41f4b71Sopenharmony_ci> - When **index** or **indexInGroup** is set to an invalid value, the returned size and position are both **0**.
854e41f4b71Sopenharmony_ci
855e41f4b71Sopenharmony_ci**Return value**
856e41f4b71Sopenharmony_ci
857e41f4b71Sopenharmony_ci| Type      | Description      |
858e41f4b71Sopenharmony_ci| -------------------  | -------- |
859e41f4b71Sopenharmony_ci| [RectResult](ts-types.md#rectresult10) | Size of the list item in the list item group and its position relative to the list.<br>Unit: vp|
860e41f4b71Sopenharmony_ci
861e41f4b71Sopenharmony_ci
862e41f4b71Sopenharmony_ci**Error codes**
863e41f4b71Sopenharmony_ci
864e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../../errorcode-universal.md).
865e41f4b71Sopenharmony_ci
866e41f4b71Sopenharmony_ci| ID| Error Message|
867e41f4b71Sopenharmony_ci| ------- | -------- |
868e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3. Parameter verification failed.   |
869e41f4b71Sopenharmony_ci| 100004   | Controller not bound to component.                               |
870e41f4b71Sopenharmony_ci
871e41f4b71Sopenharmony_ci### scrollToItemInGroup<sup>11+</sup>
872e41f4b71Sopenharmony_ci
873e41f4b71Sopenharmony_ciscrollToItemInGroup(index: number, indexInGroup: number, smooth?: boolean, align?: ScrollAlign): void
874e41f4b71Sopenharmony_ci
875e41f4b71Sopenharmony_ciScrolls to the specified list item in the specified list item group.
876e41f4b71Sopenharmony_ci
877e41f4b71Sopenharmony_ciWhen **smooth** is set to **true**, all passed items are loaded and counted in layout calculation. This may result in performance issues if a large number of items are involved.
878e41f4b71Sopenharmony_ci
879e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
880e41f4b71Sopenharmony_ci
881e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
882e41f4b71Sopenharmony_ci
883e41f4b71Sopenharmony_ci**Parameters**
884e41f4b71Sopenharmony_ci
885e41f4b71Sopenharmony_ci| Name               | Type| Mandatory| Description                                                    |
886e41f4b71Sopenharmony_ci| --------------------- | -------- | ---- | ------------------------------------------------------------ |
887e41f4b71Sopenharmony_ci| index                 | number   | Yes  | Index of the target list item group in the current container.<br>**NOTE**<br>If the value set is a negative value or greater than the maximum index of the items in the container, the value is deemed abnormal, and no scrolling will be performed.                    |
888e41f4b71Sopenharmony_ci| indexInGroup          | number   | Yes  | Index of the target list item in the list item group specified by **index**.<br>**NOTE**<br>If the value set is a negative value or greater than the maximum index of the items in the list item group, the value is deemed abnormal, and no scrolling will be performed.|
889e41f4b71Sopenharmony_ci| smooth                | boolean  | No  | Whether to enable the smooth animation for scrolling to the item with the specified index. The value **true** means to enable that the smooth animation, and **false** means the opposite.<br>Default value: **false**|
890e41f4b71Sopenharmony_ci| align                 | [ScrollAlign](ts-container-scroll.md#scrollalign10)  | No  | How the list item to scroll to is aligned with the container.<br>Default value: **ScrollAlign.START**|
891e41f4b71Sopenharmony_ci
892e41f4b71Sopenharmony_ci**Error codes**
893e41f4b71Sopenharmony_ci
894e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../../errorcode-universal.md).
895e41f4b71Sopenharmony_ci
896e41f4b71Sopenharmony_ci| ID| Error Message|
897e41f4b71Sopenharmony_ci| ------- | -------- |
898e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3. Parameter verification failed.   |
899e41f4b71Sopenharmony_ci| 100004   | Controller not bound to component.                               |
900e41f4b71Sopenharmony_ci
901e41f4b71Sopenharmony_ci### closeAllSwipeActions<sup>11+</sup>
902e41f4b71Sopenharmony_ci
903e41f4b71Sopenharmony_cicloseAllSwipeActions(options?: [CloseSwipeActionOptions](#closeswipeactionoptions11)): void
904e41f4b71Sopenharmony_ci
905e41f4b71Sopenharmony_ciCollapses the [list items](ts-container-listitem.md) in the [EXPANDED](ts-container-listitem.md#swipeactionstate11) state and sets callback events.
906e41f4b71Sopenharmony_ci
907e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
908e41f4b71Sopenharmony_ci
909e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
910e41f4b71Sopenharmony_ci
911e41f4b71Sopenharmony_ci**Parameters**
912e41f4b71Sopenharmony_ci
913e41f4b71Sopenharmony_ci| Name | Type                                                  | Mandatory| Description                                                    |
914e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
915e41f4b71Sopenharmony_ci| options | [CloseSwipeActionOptions](#closeswipeactionoptions11) | No  | Callback events for collapsing [list items](ts-container-listitem.md) in the [EXPANDED](ts-container-listitem.md#swipeactionstate11) state.|
916e41f4b71Sopenharmony_ci
917e41f4b71Sopenharmony_ci
918e41f4b71Sopenharmony_ci**Error codes**
919e41f4b71Sopenharmony_ci
920e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../../errorcode-universal.md).
921e41f4b71Sopenharmony_ci
922e41f4b71Sopenharmony_ci| ID| Error Message|
923e41f4b71Sopenharmony_ci| ------- | -------- |
924e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3. Parameter verification failed.   |
925e41f4b71Sopenharmony_ci| 100004   | Controller not bound to component.                               |
926e41f4b71Sopenharmony_ci
927e41f4b71Sopenharmony_ci> **NOTE**
928e41f4b71Sopenharmony_ci>
929e41f4b71Sopenharmony_ci> - A **ListScroller** must be bound to the **List** component.
930e41f4b71Sopenharmony_ci
931e41f4b71Sopenharmony_ci## OnScrollVisibleContentChangeCallback<sup>12+</sup>
932e41f4b71Sopenharmony_ci
933e41f4b71Sopenharmony_citype OnScrollVisibleContentChangeCallback = (start: VisibleListContentInfo, end: VisibleListContentInfo) => void
934e41f4b71Sopenharmony_ci
935e41f4b71Sopenharmony_ciCalled when a child component enters or leaves the list display area.
936e41f4b71Sopenharmony_ci
937e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
938e41f4b71Sopenharmony_ci
939e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
940e41f4b71Sopenharmony_ci
941e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
942e41f4b71Sopenharmony_ci| ------ | ------ | ------ | ------|
943e41f4b71Sopenharmony_ci| start | [VisibleListContentInfo](#visiblelistcontentinfo12) | Yes| Information about the currently displayed first list item or list item group.|
944e41f4b71Sopenharmony_ci| end | [VisibleListContentInfo](#visiblelistcontentinfo12) | Yes| Information about the currently displayed last list item or list item group.|
945e41f4b71Sopenharmony_ci
946e41f4b71Sopenharmony_ci## VisibleListContentInfo<sup>12+</sup>
947e41f4b71Sopenharmony_ci
948e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
949e41f4b71Sopenharmony_ci
950e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
951e41f4b71Sopenharmony_ci
952e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
953e41f4b71Sopenharmony_ci| ------ | ------ | ------ | ------|
954e41f4b71Sopenharmony_ci| index | number | Yes| Index of the list item or list item group in the list display area.|
955e41f4b71Sopenharmony_ci| itemGroupArea | [ListItemGroupArea](#listitemgrouparea12) | No| Position of the top or bottom edge of the viewport in the list item group to which the edge is located, if applicable.|
956e41f4b71Sopenharmony_ci| itemIndexInGroup | number | No| Index of the starting or ending list item in the list item group to which the top or bottom edge of the viewport is located.|
957e41f4b71Sopenharmony_ci
958e41f4b71Sopenharmony_ci## ListItemGroupArea<sup>12+</sup>
959e41f4b71Sopenharmony_ci
960e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
961e41f4b71Sopenharmony_ci
962e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
963e41f4b71Sopenharmony_ci
964e41f4b71Sopenharmony_ci| Name    |  Value | Description                                      |
965e41f4b71Sopenharmony_ci| ------ | ------ | ---------------------------------------- |
966e41f4b71Sopenharmony_ci| NONE |  0  | The edge of the viewport is in the position of **none**. Applicable when the list item group does not contain any header, footer, or list item.|
967e41f4b71Sopenharmony_ci| IN_LIST_ITEM_AREA |  1  | The edge of the viewport is in the position of a list item.|
968e41f4b71Sopenharmony_ci| IN_HEADER_AREA |  2  | The edge of the viewport is in the position of a header.|
969e41f4b71Sopenharmony_ci| IN_FOOTER_AREA |  3  | The edge of the viewport is in the position of a footer.|
970e41f4b71Sopenharmony_ci
971e41f4b71Sopenharmony_ci## Example
972e41f4b71Sopenharmony_ci
973e41f4b71Sopenharmony_ci### Example 1
974e41f4b71Sopenharmony_ciIn this example, a vertical list is implemented, and a callback is invoked when the first or last item displayed in the list changes.
975e41f4b71Sopenharmony_ci```ts
976e41f4b71Sopenharmony_ci// xxx.ets
977e41f4b71Sopenharmony_ci@Entry
978e41f4b71Sopenharmony_ci@Component
979e41f4b71Sopenharmony_cistruct ListExample {
980e41f4b71Sopenharmony_ci  private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
981e41f4b71Sopenharmony_ci
982e41f4b71Sopenharmony_ci  build() {
983e41f4b71Sopenharmony_ci    Column() {
984e41f4b71Sopenharmony_ci      List({ space: 20, initialIndex: 0 }) {
985e41f4b71Sopenharmony_ci        ForEach(this.arr, (item: number) => {
986e41f4b71Sopenharmony_ci          ListItem() {
987e41f4b71Sopenharmony_ci            Text('' + item)
988e41f4b71Sopenharmony_ci              .width('100%').height(100).fontSize(16)
989e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF)
990e41f4b71Sopenharmony_ci          }
991e41f4b71Sopenharmony_ci        }, (item: string) => item)
992e41f4b71Sopenharmony_ci      }
993e41f4b71Sopenharmony_ci      .listDirection(Axis.Vertical) // Arrangement direction
994e41f4b71Sopenharmony_ci      .scrollBar(BarState.Off)
995e41f4b71Sopenharmony_ci      .friction(0.6)
996e41f4b71Sopenharmony_ci      .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // Divider
997e41f4b71Sopenharmony_ci      .edgeEffect(EdgeEffect.Spring) // Set the edge scrolling effect to Spring.
998e41f4b71Sopenharmony_ci      .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
999e41f4b71Sopenharmony_ci        console.info('first' + firstIndex)
1000e41f4b71Sopenharmony_ci        console.info('last' + lastIndex)
1001e41f4b71Sopenharmony_ci        console.info('center' + centerIndex)
1002e41f4b71Sopenharmony_ci      })
1003e41f4b71Sopenharmony_ci      .onScrollVisibleContentChange((start: VisibleListContentInfo, end: VisibleListContentInfo) => {
1004e41f4b71Sopenharmony_ci        console.log(' start index: ' + start.index +
1005e41f4b71Sopenharmony_ci                    ' start item group area: ' + start.itemGroupArea +
1006e41f4b71Sopenharmony_ci                    ' start index in group: ' + start.itemIndexInGroup)
1007e41f4b71Sopenharmony_ci        console.log(' end index: ' + end.index +
1008e41f4b71Sopenharmony_ci                    ' end item group area: ' + end.itemGroupArea +
1009e41f4b71Sopenharmony_ci                    ' end index in group: ' + end.itemIndexInGroup)
1010e41f4b71Sopenharmony_ci      })
1011e41f4b71Sopenharmony_ci      .onDidScroll((scrollOffset: number, scrollState: ScrollState) => {
1012e41f4b71Sopenharmony_ci        console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset)
1013e41f4b71Sopenharmony_ci      })
1014e41f4b71Sopenharmony_ci      .width('90%')
1015e41f4b71Sopenharmony_ci    }
1016e41f4b71Sopenharmony_ci    .width('100%')
1017e41f4b71Sopenharmony_ci    .height('100%')
1018e41f4b71Sopenharmony_ci    .backgroundColor(0xDCDCDC)
1019e41f4b71Sopenharmony_ci    .padding({ top: 5 })
1020e41f4b71Sopenharmony_ci  }
1021e41f4b71Sopenharmony_ci}
1022e41f4b71Sopenharmony_ci```
1023e41f4b71Sopenharmony_ci
1024e41f4b71Sopenharmony_ci![en-us_image_0000001174264378](figures/en-us_image_0000001174264378.gif)
1025e41f4b71Sopenharmony_ci
1026e41f4b71Sopenharmony_ci
1027e41f4b71Sopenharmony_ci### Example 2
1028e41f4b71Sopenharmony_ci
1029e41f4b71Sopenharmony_ci```ts
1030e41f4b71Sopenharmony_ci// xxx.ets
1031e41f4b71Sopenharmony_ci@Entry
1032e41f4b71Sopenharmony_ci@Component
1033e41f4b71Sopenharmony_cistruct ListLanesExample {
1034e41f4b71Sopenharmony_ci  @State arr: string[] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]
1035e41f4b71Sopenharmony_ci  @State alignListItem: ListItemAlign = ListItemAlign.Start
1036e41f4b71Sopenharmony_ci
1037e41f4b71Sopenharmony_ci  build() {
1038e41f4b71Sopenharmony_ci    Column() {
1039e41f4b71Sopenharmony_ci      List({ space: 20, initialIndex: 0 }) {
1040e41f4b71Sopenharmony_ci        ForEach(this.arr, (item: string) => {
1041e41f4b71Sopenharmony_ci          ListItem() {
1042e41f4b71Sopenharmony_ci            Text('' + item)
1043e41f4b71Sopenharmony_ci              .width('100%')
1044e41f4b71Sopenharmony_ci              .height(100)
1045e41f4b71Sopenharmony_ci              .fontSize(16)
1046e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
1047e41f4b71Sopenharmony_ci              .borderRadius(10)
1048e41f4b71Sopenharmony_ci              .backgroundColor(0xFFFFFF)
1049e41f4b71Sopenharmony_ci          }
1050e41f4b71Sopenharmony_ci          .border({ width: 2, color: Color.Green })
1051e41f4b71Sopenharmony_ci        }, (item: string) => item)
1052e41f4b71Sopenharmony_ci      }
1053e41f4b71Sopenharmony_ci      .height(300)
1054e41f4b71Sopenharmony_ci      .width("90%")
1055e41f4b71Sopenharmony_ci      .friction(0.6)
1056e41f4b71Sopenharmony_ci      .border({ width: 3, color: Color.Red })
1057e41f4b71Sopenharmony_ci      .lanes({ minLength: 40, maxLength: 40 })
1058e41f4b71Sopenharmony_ci      .alignListItem(this.alignListItem)
1059e41f4b71Sopenharmony_ci      .scrollBar(BarState.Off)
1060e41f4b71Sopenharmony_ci
1061e41f4b71Sopenharmony_ci      Button("Change alignListItem: "+ this.alignListItem).onClick(() => {
1062e41f4b71Sopenharmony_ci        if (this.alignListItem == ListItemAlign.Start) {
1063e41f4b71Sopenharmony_ci          this.alignListItem = ListItemAlign.Center
1064e41f4b71Sopenharmony_ci        } else if (this.alignListItem == ListItemAlign.Center) {
1065e41f4b71Sopenharmony_ci          this.alignListItem = ListItemAlign.End
1066e41f4b71Sopenharmony_ci        } else {
1067e41f4b71Sopenharmony_ci          this.alignListItem = ListItemAlign.Start
1068e41f4b71Sopenharmony_ci        }
1069e41f4b71Sopenharmony_ci      })
1070e41f4b71Sopenharmony_ci    }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
1071e41f4b71Sopenharmony_ci  }
1072e41f4b71Sopenharmony_ci}
1073e41f4b71Sopenharmony_ci```
1074e41f4b71Sopenharmony_ci
1075e41f4b71Sopenharmony_ci![list](figures/list-alignListItem.gif)
1076e41f4b71Sopenharmony_ci
1077e41f4b71Sopenharmony_ci
1078e41f4b71Sopenharmony_ci### Example 3
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_ci```ts
1081e41f4b71Sopenharmony_ci// xxx.ets
1082e41f4b71Sopenharmony_ci@Entry
1083e41f4b71Sopenharmony_ci@Component
1084e41f4b71Sopenharmony_cistruct ListExample {
1085e41f4b71Sopenharmony_ci  @State arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
1086e41f4b71Sopenharmony_ci  @State editFlag: boolean = false
1087e41f4b71Sopenharmony_ci
1088e41f4b71Sopenharmony_ci  build() {
1089e41f4b71Sopenharmony_ci    Stack({ alignContent: Alignment.TopStart }) {
1090e41f4b71Sopenharmony_ci      Column() {
1091e41f4b71Sopenharmony_ci        List({ space: 20, initialIndex: 0 }) {
1092e41f4b71Sopenharmony_ci          ForEach(this.arr, (item: number, index?: number) => {
1093e41f4b71Sopenharmony_ci            ListItem() {
1094e41f4b71Sopenharmony_ci              Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
1095e41f4b71Sopenharmony_ci                Text('' + item)
1096e41f4b71Sopenharmony_ci                  .width('100%')
1097e41f4b71Sopenharmony_ci                  .height(80)
1098e41f4b71Sopenharmony_ci                  .fontSize(20)
1099e41f4b71Sopenharmony_ci                  .textAlign(TextAlign.Center)
1100e41f4b71Sopenharmony_ci                  .borderRadius(10)
1101e41f4b71Sopenharmony_ci                  .backgroundColor(0xFFFFFF)
1102e41f4b71Sopenharmony_ci                  .flexShrink(1)
1103e41f4b71Sopenharmony_ci                if (this.editFlag) {
1104e41f4b71Sopenharmony_ci                  Button() {
1105e41f4b71Sopenharmony_ci                    Text("delete").fontSize(16)
1106e41f4b71Sopenharmony_ci                  }.width('30%').height(40)
1107e41f4b71Sopenharmony_ci                  .onClick(() => {
1108e41f4b71Sopenharmony_ci                    if (index != undefined) {
1109e41f4b71Sopenharmony_ci                      console.info(this.arr[index] + 'Delete')
1110e41f4b71Sopenharmony_ci                      this.arr.splice(index, 1)
1111e41f4b71Sopenharmony_ci                      console.info(JSON.stringify(this.arr))
1112e41f4b71Sopenharmony_ci                      this.editFlag = false
1113e41f4b71Sopenharmony_ci                    }
1114e41f4b71Sopenharmony_ci                  }).stateEffect(true)
1115e41f4b71Sopenharmony_ci                }
1116e41f4b71Sopenharmony_ci              }
1117e41f4b71Sopenharmony_ci            }
1118e41f4b71Sopenharmony_ci          }, (item: string) => item)
1119e41f4b71Sopenharmony_ci        }.width('90%')
1120e41f4b71Sopenharmony_ci        .scrollBar(BarState.Off)
1121e41f4b71Sopenharmony_ci        .friction(0.6)
1122e41f4b71Sopenharmony_ci      }.width('100%')
1123e41f4b71Sopenharmony_ci
1124e41f4b71Sopenharmony_ci      Button('edit list')
1125e41f4b71Sopenharmony_ci        .onClick(() => {
1126e41f4b71Sopenharmony_ci          this.editFlag = !this.editFlag
1127e41f4b71Sopenharmony_ci        }).margin({ top: 5, left: 20 })
1128e41f4b71Sopenharmony_ci    }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
1129e41f4b71Sopenharmony_ci  }
1130e41f4b71Sopenharmony_ci}
1131e41f4b71Sopenharmony_ci```
1132e41f4b71Sopenharmony_ci
1133e41f4b71Sopenharmony_ci![list](figures/list3.gif)
1134e41f4b71Sopenharmony_ci
1135e41f4b71Sopenharmony_ci### Example 4
1136e41f4b71Sopenharmony_ci
1137e41f4b71Sopenharmony_ci```ts
1138e41f4b71Sopenharmony_ci// xxx.ets
1139e41f4b71Sopenharmony_ci@Entry
1140e41f4b71Sopenharmony_ci@Component
1141e41f4b71Sopenharmony_cistruct ListExample {
1142e41f4b71Sopenharmony_ci  private arr: number[] = []
1143e41f4b71Sopenharmony_ci  private scrollerForList: Scroller = new Scroller()
1144e41f4b71Sopenharmony_ci
1145e41f4b71Sopenharmony_ci  aboutToAppear() {
1146e41f4b71Sopenharmony_ci    for (let i = 0; i < 20; i++) {
1147e41f4b71Sopenharmony_ci      this.arr.push(i)
1148e41f4b71Sopenharmony_ci    }
1149e41f4b71Sopenharmony_ci  }
1150e41f4b71Sopenharmony_ci  build() {
1151e41f4b71Sopenharmony_ci    Column() {
1152e41f4b71Sopenharmony_ci      Row() {
1153e41f4b71Sopenharmony_ci        List({ space: 20, initialIndex: 3, scroller: this.scrollerForList }) {
1154e41f4b71Sopenharmony_ci          ForEach(this.arr, (item: number) => {
1155e41f4b71Sopenharmony_ci            ListItem() {
1156e41f4b71Sopenharmony_ci              Text('' + item)
1157e41f4b71Sopenharmony_ci                .width('100%').height(100).fontSize(16)
1158e41f4b71Sopenharmony_ci                .textAlign(TextAlign.Center)
1159e41f4b71Sopenharmony_ci            }
1160e41f4b71Sopenharmony_ci            .borderRadius(10).backgroundColor(0xFFFFFF)
1161e41f4b71Sopenharmony_ci            .width('60%')
1162e41f4b71Sopenharmony_ci            .height('80%')
1163e41f4b71Sopenharmony_ci          }, (item: number) => JSON.stringify(item))
1164e41f4b71Sopenharmony_ci        }
1165e41f4b71Sopenharmony_ci        .chainAnimation(true)
1166e41f4b71Sopenharmony_ci        .edgeEffect(EdgeEffect.Spring)
1167e41f4b71Sopenharmony_ci        .listDirection(Axis.Horizontal)
1168e41f4b71Sopenharmony_ci        .height('100%')
1169e41f4b71Sopenharmony_ci        .width('100%')
1170e41f4b71Sopenharmony_ci        .scrollSnapAlign(ScrollSnapAlign.CENTER)
1171e41f4b71Sopenharmony_ci        .borderRadius(10)
1172e41f4b71Sopenharmony_ci        .backgroundColor(0xDCDCDC)
1173e41f4b71Sopenharmony_ci      }
1174e41f4b71Sopenharmony_ci      .width('100%')
1175e41f4b71Sopenharmony_ci      .height('100%')
1176e41f4b71Sopenharmony_ci      .backgroundColor(0xDCDCDC)
1177e41f4b71Sopenharmony_ci      .padding({ top: 10 })
1178e41f4b71Sopenharmony_ci    }
1179e41f4b71Sopenharmony_ci  }
1180e41f4b71Sopenharmony_ci}
1181e41f4b71Sopenharmony_ci
1182e41f4b71Sopenharmony_ci```
1183e41f4b71Sopenharmony_ci
1184e41f4b71Sopenharmony_ci![list](figures/list4.gif)
1185e41f4b71Sopenharmony_ci
1186e41f4b71Sopenharmony_ci### Example 5
1187e41f4b71Sopenharmony_ciThis example shows that, by setting the **childrenMainSize** attribute, the list can jump to an exact specific location when the **scrollTo** API is called, even when the heights of the child components are inconsistent.
1188e41f4b71Sopenharmony_ci```ts
1189e41f4b71Sopenharmony_ci// xxx.ets
1190e41f4b71Sopenharmony_ci@Entry
1191e41f4b71Sopenharmony_ci@Component
1192e41f4b71Sopenharmony_cistruct ListExample {
1193e41f4b71Sopenharmony_ci  private arr: number[] = []
1194e41f4b71Sopenharmony_ci  private scroller: ListScroller = new ListScroller()
1195e41f4b71Sopenharmony_ci  @State listSpace: number = 10
1196e41f4b71Sopenharmony_ci  @State listChildrenSize: ChildrenMainSize = new ChildrenMainSize(100)
1197e41f4b71Sopenharmony_ci  aboutToAppear(){
1198e41f4b71Sopenharmony_ci    // Initialize the data source.
1199e41f4b71Sopenharmony_ci    for (let i = 0; i < 10; i++) {
1200e41f4b71Sopenharmony_ci      this.arr.push(i)
1201e41f4b71Sopenharmony_ci    }
1202e41f4b71Sopenharmony_ci    // The first five items do not have a default main axis size of 100; therefore, it is necessary to inform the list through the ChildrenMainSize.
1203e41f4b71Sopenharmony_ci    this.listChildrenSize.splice(0, 5, [300, 300, 300, 300, 300])
1204e41f4b71Sopenharmony_ci  }
1205e41f4b71Sopenharmony_ci  build() {
1206e41f4b71Sopenharmony_ci    Column() {
1207e41f4b71Sopenharmony_ci      List({ space: this.listSpace, initialIndex: 4, scroller: this.scroller }) {
1208e41f4b71Sopenharmony_ci        ForEach(this.arr, (item: number) => {
1209e41f4b71Sopenharmony_ci          ListItem() {
1210e41f4b71Sopenharmony_ci            Text('item-' + item)
1211e41f4b71Sopenharmony_ci              .height( item < 5 ? 300 : this.listChildrenSize.childDefaultSize)
1212e41f4b71Sopenharmony_ci              .width('90%')
1213e41f4b71Sopenharmony_ci              .fontSize(16)
1214e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
1215e41f4b71Sopenharmony_ci              .borderRadius(10)
1216e41f4b71Sopenharmony_ci              .backgroundColor(0xFFFFFF)
1217e41f4b71Sopenharmony_ci          }
1218e41f4b71Sopenharmony_ci        }, (item: string) => item)
1219e41f4b71Sopenharmony_ci      }
1220e41f4b71Sopenharmony_ci      .backgroundColor(Color.Gray)
1221e41f4b71Sopenharmony_ci      .layoutWeight(1)
1222e41f4b71Sopenharmony_ci      .scrollBar(BarState.On)
1223e41f4b71Sopenharmony_ci      .childrenMainSize(this.listChildrenSize)
1224e41f4b71Sopenharmony_ci      .alignListItem(ListItemAlign.Center)
1225e41f4b71Sopenharmony_ci      Row(){
1226e41f4b71Sopenharmony_ci        Button() { Text('item size + 50') }.onClick(()=>{
1227e41f4b71Sopenharmony_ci          this.listChildrenSize.childDefaultSize += 50
1228e41f4b71Sopenharmony_ci        }).height('50%').width('30%')
1229e41f4b71Sopenharmony_ci        Button() { Text('item size - 50') }.onClick(()=>{
1230e41f4b71Sopenharmony_ci          if (this.listChildrenSize.childDefaultSize === 0) {
1231e41f4b71Sopenharmony_ci            return
1232e41f4b71Sopenharmony_ci          }
1233e41f4b71Sopenharmony_ci          this.listChildrenSize.childDefaultSize -= 50
1234e41f4b71Sopenharmony_ci        }).height('50%').width('30%')
1235e41f4b71Sopenharmony_ci        Button() { Text('scrollTo (0, 310)') }.onClick(()=>{
1236e41f4b71Sopenharmony_ci          // 310: Jump to the position where the top of item 1 is aligned with the top of the list.
1237e41f4b71Sopenharmony_ci          // If childrenMainSize is not set, the scrollTo API may not work correctly when the heights of the list items are inconsistent.
1238e41f4b71Sopenharmony_ci          this.scroller.scrollTo({xOffset: 0, yOffset: 310})
1239e41f4b71Sopenharmony_ci        }).height('50%').width('30%')
1240e41f4b71Sopenharmony_ci      }.height('20%')
1241e41f4b71Sopenharmony_ci    }
1242e41f4b71Sopenharmony_ci  }
1243e41f4b71Sopenharmony_ci}
1244e41f4b71Sopenharmony_ci
1245e41f4b71Sopenharmony_ci```
1246e41f4b71Sopenharmony_ci
1247e41f4b71Sopenharmony_ci![list](figures/list5.gif)
1248