ts-container-scroll.md 14.8 KB
Newer Older
Z
zengyawen 已提交
1 2 3 4
# Scroll<a name="ZH-CN_TOPIC_0000001192595158"></a>

>![](../../public_sys-resources/icon-note.gif) **说明:** 
>该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
Z
zengyawen 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

可滚动的容器组件,当子组件的布局尺寸超过父组件的视口时,内容可以滚动。

## 权限列表<a name="section1073795814133"></a>



## 子组件<a name="section152511941148"></a>

支持单个子组件。

## 接口<a name="section13412231148"></a>

Scroll\(scroller?: Scroller\)

## 属性<a name="section186841370012"></a>

Z
zengyawen 已提交
22
<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="18.81188118811881%" id="mcps1.1.5.1.1"><p>名称</p>
Z
zengyawen 已提交
23
</th>
Z
zengyawen 已提交
24
<th class="cellrowborder" valign="top" width="18.801880188018803%" id="mcps1.1.5.1.2"><p>参数类型</p>
Z
zengyawen 已提交
25
</th>
Z
zengyawen 已提交
26
<th class="cellrowborder" valign="top" width="14.861486148614864%" id="mcps1.1.5.1.3"><p>默认值</p>
Z
zengyawen 已提交
27
</th>
Z
zengyawen 已提交
28
<th class="cellrowborder" valign="top" width="47.52475247524753%" id="mcps1.1.5.1.4"><p>描述</p>
Z
zengyawen 已提交
29 30 31
</th>
</tr>
</thead>
Z
zengyawen 已提交
32
<tbody><tr><td class="cellrowborder" valign="top" width="18.81188118811881%" headers="mcps1.1.5.1.1 "><p>scrollable</p>
Z
zengyawen 已提交
33
</td>
Z
zengyawen 已提交
34
<td class="cellrowborder" valign="top" width="18.801880188018803%" headers="mcps1.1.5.1.2 "><p><a href="#li1464044171913">ScrollDirection</a></p>
Z
zengyawen 已提交
35
</td>
Z
zengyawen 已提交
36
<td class="cellrowborder" valign="top" width="14.861486148614864%" headers="mcps1.1.5.1.3 "><p>Vertical</p>
Z
zengyawen 已提交
37
</td>
Z
zengyawen 已提交
38
<td class="cellrowborder" valign="top" width="47.52475247524753%" headers="mcps1.1.5.1.4 "><p>设置滚动方法。</p>
Z
zengyawen 已提交
39 40
</td>
</tr>
Z
zengyawen 已提交
41
<tr><td class="cellrowborder" valign="top" width="18.81188118811881%" headers="mcps1.1.5.1.1 "><p>scrollBar</p>
Z
zengyawen 已提交
42
</td>
Z
zengyawen 已提交
43
<td class="cellrowborder" valign="top" width="18.801880188018803%" headers="mcps1.1.5.1.2 "><p><a href="ts-appendix-enums.md#section122549529179">BarState</a></p>
Z
zengyawen 已提交
44
</td>
Z
zengyawen 已提交
45
<td class="cellrowborder" valign="top" width="14.861486148614864%" headers="mcps1.1.5.1.3 "><p>Auto</p>
Z
zengyawen 已提交
46
</td>
Z
zengyawen 已提交
47
<td class="cellrowborder" valign="top" width="47.52475247524753%" headers="mcps1.1.5.1.4 "><p>设置滚动条状态。</p>
Z
zengyawen 已提交
48 49
</td>
</tr>
Z
zengyawen 已提交
50
<tr><td class="cellrowborder" valign="top" width="18.81188118811881%" headers="mcps1.1.5.1.1 "><p>scrollBarColor</p>
Z
zengyawen 已提交
51
</td>
Z
zengyawen 已提交
52
<td class="cellrowborder" valign="top" width="18.801880188018803%" headers="mcps1.1.5.1.2 "><p>Color</p>
Z
zengyawen 已提交
53
</td>
Z
zengyawen 已提交
54
<td class="cellrowborder" valign="top" width="14.861486148614864%" headers="mcps1.1.5.1.3 "><p>-</p>
Z
zengyawen 已提交
55
</td>
Z
zengyawen 已提交
56
<td class="cellrowborder" valign="top" width="47.52475247524753%" headers="mcps1.1.5.1.4 "><p>设置滚动条的颜色。</p>
Z
zengyawen 已提交
57 58
</td>
</tr>
Z
zengyawen 已提交
59
<tr><td class="cellrowborder" valign="top" width="18.81188118811881%" headers="mcps1.1.5.1.1 "><p>scrollBarWidth</p>
Z
zengyawen 已提交
60
</td>
Z
zengyawen 已提交
61
<td class="cellrowborder" valign="top" width="18.801880188018803%" headers="mcps1.1.5.1.2 "><p>Length</p>
Z
zengyawen 已提交
62
</td>
Z
zengyawen 已提交
63
<td class="cellrowborder" valign="top" width="14.861486148614864%" headers="mcps1.1.5.1.3 "><p>-</p>
Z
zengyawen 已提交
64
</td>
Z
zengyawen 已提交
65
<td class="cellrowborder" valign="top" width="47.52475247524753%" headers="mcps1.1.5.1.4 "><p>设置滚动条的宽度。</p>
Z
zengyawen 已提交
66 67 68 69 70 71 72
</td>
</tr>
</tbody>
</table>

-   <a name="li1464044171913"></a>ScrollDirection枚举说明

Z
zengyawen 已提交
73
    <table><thead align="left"><tr><th class="cellrowborder" valign="top" width="25.2%" id="mcps1.1.3.1.1"><p>名称</p>
Z
zengyawen 已提交
74
    </th>
Z
zengyawen 已提交
75
    <th class="cellrowborder" valign="top" width="74.8%" id="mcps1.1.3.1.2"><p>描述</p>
Z
zengyawen 已提交
76 77 78
    </th>
    </tr>
    </thead>
Z
zengyawen 已提交
79
    <tbody><tr><td class="cellrowborder" valign="top" width="25.2%" headers="mcps1.1.3.1.1 "><p>Horizontal</p>
Z
zengyawen 已提交
80
    </td>
Z
zengyawen 已提交
81
    <td class="cellrowborder" valign="top" width="74.8%" headers="mcps1.1.3.1.2 "><p>仅支持水平方向滚动。</p>
Z
zengyawen 已提交
82 83
    </td>
    </tr>
Z
zengyawen 已提交
84
    <tr><td class="cellrowborder" valign="top" width="25.2%" headers="mcps1.1.3.1.1 "><p>Vertical</p>
Z
zengyawen 已提交
85
    </td>
Z
zengyawen 已提交
86
    <td class="cellrowborder" valign="top" width="74.8%" headers="mcps1.1.3.1.2 "><p>仅支持竖直方向滚动。</p>
Z
zengyawen 已提交
87 88
    </td>
    </tr>
Z
zengyawen 已提交
89
    <tr><td class="cellrowborder" valign="top" width="25.2%" headers="mcps1.1.3.1.1 "><p>None</p>
Z
zengyawen 已提交
90
    </td>
Z
zengyawen 已提交
91
    <td class="cellrowborder" valign="top" width="74.8%" headers="mcps1.1.3.1.2 "><p>不可滚动。</p>
Z
zengyawen 已提交
92 93 94 95 96 97 98 99 100 101
    </td>
    </tr>
    </tbody>
    </table>


## Scroller<a name="section123902548458"></a>

可滚动容器组件的控制器,可以将此组件绑定至容器组件,然后通过它控制容器组件的滚动,目前支持绑定到List和Scroll组件上。

Z
zengyawen 已提交
102
### 创建对象<a name="section1241383014362"></a>
Z
zengyawen 已提交
103 104 105 106 107 108 109 110 111 112 113 114 115

```
scroller: Scroller = new Scroller()
```

### scroller.scrollTo<a name="section15413203010365"></a>

scrollTo\(value: \{ xOffset: number | string, yOffset: number | string, animation?: \{ duration: number, curve: Curve \} \}\): void

滑动到指定位置。

-   参数

Z
zengyawen 已提交
116
    <table><thead align="left"><tr><th class="cellrowborder" valign="top" width="16.11%" id="mcps1.1.6.1.1"><p>参数名</p>
Z
zengyawen 已提交
117
    </th>
Z
zengyawen 已提交
118
    <th class="cellrowborder" valign="top" width="21.43%" id="mcps1.1.6.1.2"><p>参数类型</p>
Z
zengyawen 已提交
119
    </th>
Z
zengyawen 已提交
120
    <th class="cellrowborder" valign="top" width="7.08%" id="mcps1.1.6.1.3"><p>必填</p>
Z
zengyawen 已提交
121
    </th>
Z
zengyawen 已提交
122
    <th class="cellrowborder" valign="top" width="13.170000000000002%" id="mcps1.1.6.1.4"><p>默认值</p>
Z
zengyawen 已提交
123
    </th>
Z
zengyawen 已提交
124
    <th class="cellrowborder" valign="top" width="42.21%" id="mcps1.1.6.1.5"><p>参数描述</p>
Z
zengyawen 已提交
125 126 127
    </th>
    </tr>
    </thead>
Z
zengyawen 已提交
128
    <tbody><tr><td class="cellrowborder" valign="top" width="16.11%" headers="mcps1.1.6.1.1 "><p>xOffset</p>
Z
zengyawen 已提交
129
    </td>
Z
zengyawen 已提交
130
    <td class="cellrowborder" valign="top" width="21.43%" headers="mcps1.1.6.1.2 "><p>Length</p>
Z
zengyawen 已提交
131
    </td>
Z
zengyawen 已提交
132
    <td class="cellrowborder" valign="top" width="7.08%" headers="mcps1.1.6.1.3 "><p>是</p>
Z
zengyawen 已提交
133
    </td>
Z
zengyawen 已提交
134
    <td class="cellrowborder" valign="top" width="13.170000000000002%" headers="mcps1.1.6.1.4 "><p>-</p>
Z
zengyawen 已提交
135
    </td>
Z
zengyawen 已提交
136
    <td class="cellrowborder" valign="top" width="42.21%" headers="mcps1.1.6.1.5 "><p>水平滑动偏移。</p>
Z
zengyawen 已提交
137 138
    </td>
    </tr>
Z
zengyawen 已提交
139
    <tr><td class="cellrowborder" valign="top" width="16.11%" headers="mcps1.1.6.1.1 "><p>yOffset</p>
Z
zengyawen 已提交
140
    </td>
Z
zengyawen 已提交
141
    <td class="cellrowborder" valign="top" width="21.43%" headers="mcps1.1.6.1.2 "><p>Length</p>
Z
zengyawen 已提交
142
    </td>
Z
zengyawen 已提交
143
    <td class="cellrowborder" valign="top" width="7.08%" headers="mcps1.1.6.1.3 "><p>是</p>
Z
zengyawen 已提交
144
    </td>
Z
zengyawen 已提交
145
    <td class="cellrowborder" valign="top" width="13.170000000000002%" headers="mcps1.1.6.1.4 "><p>-</p>
Z
zengyawen 已提交
146
    </td>
Z
zengyawen 已提交
147
    <td class="cellrowborder" valign="top" width="42.21%" headers="mcps1.1.6.1.5 "><p>竖直滑动偏移。</p>
Z
zengyawen 已提交
148 149
    </td>
    </tr>
Z
zengyawen 已提交
150 151 152 153 154 155
    <tr><td class="cellrowborder" valign="top" width="16.11%" headers="mcps1.1.6.1.1 "><p>animation</p>
    </td>
    <td class="cellrowborder" valign="top" width="21.43%" headers="mcps1.1.6.1.2 "><p>{</p>
    <p>duration: number,</p>
    <p>curve: <a href="ts-animatorproperty.md#li16621545614">Curve</a> | CubicBezier | SpringCurve</p>
    <p>}</p>
Z
zengyawen 已提交
156
    </td>
Z
zengyawen 已提交
157
    <td class="cellrowborder" valign="top" width="7.08%" headers="mcps1.1.6.1.3 "><p>否</p>
Z
zengyawen 已提交
158
    </td>
Z
zengyawen 已提交
159
    <td class="cellrowborder" valign="top" width="13.170000000000002%" headers="mcps1.1.6.1.4 "><p>-</p>
Z
zengyawen 已提交
160
    </td>
Z
zengyawen 已提交
161 162
    <td class="cellrowborder" valign="top" width="42.21%" headers="mcps1.1.6.1.5 "><p>动画配置:</p>
    <ul><li>duration: 滚动时长设置。</li><li>curve: 滚动曲线设置。</li></ul>
Z
zengyawen 已提交
163 164 165 166 167 168 169 170 171 172 173 174 175 176
    </td>
    </tr>
    </tbody>
    </table>


### scroller.scrollEdge<a name="section1441583018367"></a>

scrollEdge\(value: Edge\): void

滚动到容器边缘。

-   参数

Z
zengyawen 已提交
177
    <table><thead align="left"><tr><th class="cellrowborder" valign="top" width="16.11%" id="mcps1.1.6.1.1"><p>参数名</p>
Z
zengyawen 已提交
178
    </th>
Z
zengyawen 已提交
179
    <th class="cellrowborder" valign="top" width="14.01%" id="mcps1.1.6.1.2"><p>参数类型</p>
Z
zengyawen 已提交
180
    </th>
Z
zengyawen 已提交
181
    <th class="cellrowborder" valign="top" width="14.499999999999998%" id="mcps1.1.6.1.3"><p>必填</p>
Z
zengyawen 已提交
182
    </th>
Z
zengyawen 已提交
183
    <th class="cellrowborder" valign="top" width="13.170000000000002%" id="mcps1.1.6.1.4"><p>默认值</p>
Z
zengyawen 已提交
184
    </th>
Z
zengyawen 已提交
185
    <th class="cellrowborder" valign="top" width="42.21%" id="mcps1.1.6.1.5"><p>参数描述</p>
Z
zengyawen 已提交
186 187 188
    </th>
    </tr>
    </thead>
Z
zengyawen 已提交
189
    <tbody><tr><td class="cellrowborder" valign="top" width="16.11%" headers="mcps1.1.6.1.1 "><p>value</p>
Z
zengyawen 已提交
190
    </td>
Z
zengyawen 已提交
191
    <td class="cellrowborder" valign="top" width="14.01%" headers="mcps1.1.6.1.2 "><p>Edge</p>
Z
zengyawen 已提交
192
    </td>
Z
zengyawen 已提交
193
    <td class="cellrowborder" valign="top" width="14.499999999999998%" headers="mcps1.1.6.1.3 "><p>是</p>
Z
zengyawen 已提交
194
    </td>
Z
zengyawen 已提交
195 196 197
    <td class="cellrowborder" valign="top" width="13.170000000000002%" headers="mcps1.1.6.1.4 "><p>-</p>
    </td>
    <td class="cellrowborder" valign="top" width="42.21%" headers="mcps1.1.6.1.5 "><p>滚动到的边缘位置。</p>
Z
zengyawen 已提交
198 199 200 201 202 203 204 205
    </td>
    </tr>
    </tbody>
    </table>


### scroller.scrollPage<a name="section2416163018368"></a>

Z
zengyawen 已提交
206 207 208
scrollPage\(value: \{ next: boolean \}\): void

滚动到下一页或者上一页。
Z
zengyawen 已提交
209 210 211

-   参数

Z
zengyawen 已提交
212
    <table><thead align="left"><tr><th class="cellrowborder" valign="top" width="16.11%" id="mcps1.1.6.1.1"><p>参数名</p>
Z
zengyawen 已提交
213
    </th>
Z
zengyawen 已提交
214
    <th class="cellrowborder" valign="top" width="14.01%" id="mcps1.1.6.1.2"><p>参数类型</p>
Z
zengyawen 已提交
215
    </th>
Z
zengyawen 已提交
216
    <th class="cellrowborder" valign="top" width="14.499999999999998%" id="mcps1.1.6.1.3"><p>必填</p>
Z
zengyawen 已提交
217
    </th>
Z
zengyawen 已提交
218
    <th class="cellrowborder" valign="top" width="13.170000000000002%" id="mcps1.1.6.1.4"><p>默认值</p>
Z
zengyawen 已提交
219
    </th>
Z
zengyawen 已提交
220
    <th class="cellrowborder" valign="top" width="42.21%" id="mcps1.1.6.1.5"><p>参数描述</p>
Z
zengyawen 已提交
221 222 223
    </th>
    </tr>
    </thead>
Z
zengyawen 已提交
224
    <tbody><tr><td class="cellrowborder" valign="top" width="16.11%" headers="mcps1.1.6.1.1 "><p>next</p>
Z
zengyawen 已提交
225
    </td>
Z
zengyawen 已提交
226
    <td class="cellrowborder" valign="top" width="14.01%" headers="mcps1.1.6.1.2 "><p>boolean</p>
Z
zengyawen 已提交
227
    </td>
Z
zengyawen 已提交
228
    <td class="cellrowborder" valign="top" width="14.499999999999998%" headers="mcps1.1.6.1.3 "><p>是</p>
Z
zengyawen 已提交
229
    </td>
Z
zengyawen 已提交
230
    <td class="cellrowborder" valign="top" width="13.170000000000002%" headers="mcps1.1.6.1.4 "><p>-</p>
Z
zengyawen 已提交
231
    </td>
Z
zengyawen 已提交
232
    <td class="cellrowborder" valign="top" width="42.21%" headers="mcps1.1.6.1.5 "><p>是否向下翻页。true表示向下翻页,false表示向上翻页。</p>
Z
zengyawen 已提交
233 234 235 236 237 238 239 240 241 242 243 244 245 246
    </td>
    </tr>
    </tbody>
    </table>


### scroller.currentOffset<a name="section041711305362"></a>

scroller.currentOffset\(\): Object

返回当前的滚动偏移量。

-   返回值

Z
zengyawen 已提交
247
    <table><thead align="left"><tr><th class="cellrowborder" valign="top" width="25.2%" id="mcps1.1.3.1.1"><p>类型</p>
Z
zengyawen 已提交
248
    </th>
Z
zengyawen 已提交
249
    <th class="cellrowborder" valign="top" width="74.8%" id="mcps1.1.3.1.2"><p>描述</p>
Z
zengyawen 已提交
250 251 252
    </th>
    </tr>
    </thead>
Z
zengyawen 已提交
253 254 255 256
    <tbody><tr><td class="cellrowborder" valign="top" width="25.2%" headers="mcps1.1.3.1.1 "><p>{</p>
    <p>xOffset: number,</p>
    <p>yOffset: number</p>
    <p>}</p>
Z
zengyawen 已提交
257
    </td>
Z
zengyawen 已提交
258 259
    <td class="cellrowborder" valign="top" width="74.8%" headers="mcps1.1.3.1.2 "><p>xOffset: 水平滑动偏移;</p>
    <p>yOffset: 竖直滑动偏移。</p>
Z
zengyawen 已提交
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
    </td>
    </tr>
    </tbody>
    </table>


### scroller.scrollToIndex<a name="section10417103010368"></a>

scroller.scrollToIndex\(value: number\): void

滑动到指定Index。

>![](../../public_sys-resources/icon-note.gif) **说明:** 
>仅支持list组件。

-   参数

Z
zengyawen 已提交
277
    <table><thead align="left"><tr><th class="cellrowborder" valign="top" width="16.11%" id="mcps1.1.6.1.1"><p>参数名</p>
Z
zengyawen 已提交
278
    </th>
Z
zengyawen 已提交
279
    <th class="cellrowborder" valign="top" width="14.01%" id="mcps1.1.6.1.2"><p>参数类型</p>
Z
zengyawen 已提交
280
    </th>
Z
zengyawen 已提交
281
    <th class="cellrowborder" valign="top" width="14.499999999999998%" id="mcps1.1.6.1.3"><p>必填</p>
Z
zengyawen 已提交
282
    </th>
Z
zengyawen 已提交
283
    <th class="cellrowborder" valign="top" width="13.170000000000002%" id="mcps1.1.6.1.4"><p>默认值</p>
Z
zengyawen 已提交
284
    </th>
Z
zengyawen 已提交
285
    <th class="cellrowborder" valign="top" width="42.21%" id="mcps1.1.6.1.5"><p>参数描述</p>
Z
zengyawen 已提交
286 287 288
    </th>
    </tr>
    </thead>
Z
zengyawen 已提交
289
    <tbody><tr><td class="cellrowborder" valign="top" width="16.11%" headers="mcps1.1.6.1.1 "><p>value</p>
Z
zengyawen 已提交
290
    </td>
Z
zengyawen 已提交
291
    <td class="cellrowborder" valign="top" width="14.01%" headers="mcps1.1.6.1.2 "><p>number</p>
Z
zengyawen 已提交
292
    </td>
Z
zengyawen 已提交
293
    <td class="cellrowborder" valign="top" width="14.499999999999998%" headers="mcps1.1.6.1.3 "><p>是</p>
Z
zengyawen 已提交
294
    </td>
Z
zengyawen 已提交
295
    <td class="cellrowborder" valign="top" width="13.170000000000002%" headers="mcps1.1.6.1.4 "><p>-</p>
Z
zengyawen 已提交
296
    </td>
Z
zengyawen 已提交
297
    <td class="cellrowborder" valign="top" width="42.21%" headers="mcps1.1.6.1.5 "><p>要滑动到的列表项在列表中的索引值。</p>
Z
zengyawen 已提交
298 299 300 301 302 303 304 305
    </td>
    </tr>
    </tbody>
    </table>


## 事件<a name="section142174333711"></a>

Z
zengyawen 已提交
306
<table><thead align="left"><tr><th class="cellrowborder" colspan="2" valign="top" id="mcps1.1.4.1.1"><p>名称</p>
Z
zengyawen 已提交
307
</th>
Z
zengyawen 已提交
308
<th class="cellrowborder" valign="top" id="mcps1.1.4.1.2"><p>功能描述</p>
Z
zengyawen 已提交
309 310 311
</th>
</tr>
</thead>
Z
zengyawen 已提交
312
<tbody><tr><td class="cellrowborder" colspan="2" valign="top" headers="mcps1.1.4.1.1 "><p>onScroll(xOffset: number, yOffset: number) =&gt; void</p>
Z
zengyawen 已提交
313
</td>
Z
zengyawen 已提交
314
<td class="cellrowborder" valign="top" headers="mcps1.1.4.1.2 "><p>滚动事件回调, 返回滚动时水平、竖直方向偏移量。</p>
Z
zengyawen 已提交
315 316
</td>
</tr>
Z
zengyawen 已提交
317
<tr><td class="cellrowborder" colspan="2" valign="top" headers="mcps1.1.4.1.1 "><p>onScrollEdge(side: Edge) =&gt; void</p>
Z
zengyawen 已提交
318
</td>
Z
zengyawen 已提交
319
<td class="cellrowborder" valign="top" headers="mcps1.1.4.1.2 "><p>滚动到边缘事件回调。</p>
Z
zengyawen 已提交
320 321
</td>
</tr>
Z
zengyawen 已提交
322
<tr><td class="cellrowborder" colspan="2" valign="top" headers="mcps1.1.4.1.1 "><p>onScrollEnd() =&gt; void</p>
Z
zengyawen 已提交
323
</td>
Z
zengyawen 已提交
324
<td class="cellrowborder" valign="top" headers="mcps1.1.4.1.2 "><p>滚动停止事件回调。</p>
Z
zengyawen 已提交
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
</td>
</tr>
</tbody>
</table>

## 示例<a name="section11271205310156"></a>

```
@Entry
@Component
struct ScrollExample {
  scroller: Scroller = new Scroller()
  private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

  build() {
    Stack({ alignContent: Alignment.TopStart }) {
      Scroll(this.scroller) {
        Column() {
          ForEach(this.arr, (item) => {
            Text(item.toString())
              .width('90%').height(150).backgroundColor(0xFFFFFF)
              .borderRadius(15).fontSize(16).textAlign(TextAlign.Center)
              .margin({ top: 10 })
          }, item => item)
        }.width('100%')
      }
      .scrollable(ScrollDirection.Vertical).scrollBar(BarState.On)
      .scrollBarColor(Color.Gray).scrollBarWidth(30)
      .onScroll((xOffset: number, yOffset: number) => {
        console.info(xOffset + ' ' + yOffset)
      })
      .onScrollEdge((side: Edge) => {
        console.info('To the edge')
      })
      .onScrollEnd(() => {
        console.info('Scroll Stop')
      })

      Button('scroll 100')
        .onClick(() => { // 点击后下滑100.0距离
          this.scroller.scrollTo({ xOffset: 0, yOffset: this.scroller.currentOffset().yOffset + 100 })
        })
        .margin({ top: 10, left: 20 })
      Button('back top')
        .onClick(() => { // 点击后回到顶部
          this.scroller.scrollEdge(Edge.Top)
        })
        .margin({ top: 60, left: 20 })
      Button('next page')
        .onClick(() => { // 点击后下滑到底部
          this.scroller.scrollPage({ next: true })
        })
        .margin({ top: 110, left: 20 })
    }.width('100%').height('100%').backgroundColor(0xDCDCDC)
  }
}
```

![](figures/scroll.gif)