ts-page-transition-animation.md 15.5 KB
Newer Older
Z
zengyawen 已提交
1 2 3 4
# 页面间转场<a name="ZH-CN_TOPIC_0000001237715079"></a>

>![](../../public_sys-resources/icon-note.gif) **说明:** 
>从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
Z
zengyawen 已提交
5 6 7

页面转场通过在全局pageTransition方法内配置页面入场组件和页面退场组件来自定义页面转场动效。

Z
zengyawen 已提交
8
<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="22.12%" id="mcps1.1.4.1.1"><p>名称</p>
Z
zengyawen 已提交
9
</th>
Z
zengyawen 已提交
10
<th class="cellrowborder" valign="top" width="17.31%" id="mcps1.1.4.1.2"><p>参数</p>
Z
zengyawen 已提交
11
</th>
Z
zengyawen 已提交
12
<th class="cellrowborder" valign="top" width="60.57%" id="mcps1.1.4.1.3"><p>参数描述</p>
Z
zengyawen 已提交
13 14 15
</th>
</tr>
</thead>
Z
zengyawen 已提交
16
<tbody><tr><td class="cellrowborder" valign="top" width="22.12%" headers="mcps1.1.4.1.1 "><p>PageTransitionEnter</p>
Z
zengyawen 已提交
17
</td>
Z
zengyawen 已提交
18
<td class="cellrowborder" valign="top" width="17.31%" headers="mcps1.1.4.1.2 "><p>Object</p>
Z
zengyawen 已提交
19
</td>
Z
zengyawen 已提交
20
<td class="cellrowborder" valign="top" width="60.57%" headers="mcps1.1.4.1.3 "><p>页面入场组件,用于自定义当前页面的入场效果,详见<a href="#li1947672255711">动效参数说明</a></p>
Z
zengyawen 已提交
21 22
</td>
</tr>
Z
zengyawen 已提交
23
<tr><td class="cellrowborder" valign="top" width="22.12%" headers="mcps1.1.4.1.1 "><p>PageTransitionExit</p>
Z
zengyawen 已提交
24
</td>
Z
zengyawen 已提交
25
<td class="cellrowborder" valign="top" width="17.31%" headers="mcps1.1.4.1.2 "><p>Object</p>
Z
zengyawen 已提交
26
</td>
Z
zengyawen 已提交
27
<td class="cellrowborder" valign="top" width="60.57%" headers="mcps1.1.4.1.3 "><p>页面退场组件,用于自定义当前页面的退场效果,详见<a href="#li1947672255711">动效参数说明</a></p>
Z
zengyawen 已提交
28 29 30 31 32 33 34
</td>
</tr>
</tbody>
</table>

-   <a name="li1947672255711"></a>动效参数说明

Z
zengyawen 已提交
35
    <table><thead align="left"><tr><th class="cellrowborder" valign="top" width="10.67961165048544%" id="mcps1.1.6.1.1"><p>参数名称</p>
Z
zengyawen 已提交
36
    </th>
Z
zengyawen 已提交
37
    <th class="cellrowborder" valign="top" width="17.47572815533981%" id="mcps1.1.6.1.2"><p>参数类型</p>
Z
zengyawen 已提交
38
    </th>
Z
zengyawen 已提交
39
    <th class="cellrowborder" valign="top" width="10.92233009708738%" id="mcps1.1.6.1.3"><p>默认值</p>
Z
zengyawen 已提交
40
    </th>
Z
zengyawen 已提交
41
    <th class="cellrowborder" valign="top" width="10.116504854368934%" id="mcps1.1.6.1.4"><p>必填</p>
Z
zengyawen 已提交
42
    </th>
Z
zengyawen 已提交
43
    <th class="cellrowborder" valign="top" width="50.80582524271845%" id="mcps1.1.6.1.5"><p>参数描述</p>
Z
zengyawen 已提交
44 45 46
    </th>
    </tr>
    </thead>
Z
zengyawen 已提交
47
    <tbody><tr><td class="cellrowborder" valign="top" width="10.67961165048544%" headers="mcps1.1.6.1.1 "><p>type</p>
Z
zengyawen 已提交
48
    </td>
Z
zengyawen 已提交
49
    <td class="cellrowborder" valign="top" width="17.47572815533981%" headers="mcps1.1.6.1.2 "><p><a href="#li1364031695819">RouteType</a></p>
Z
zengyawen 已提交
50
    </td>
Z
zengyawen 已提交
51
    <td class="cellrowborder" valign="top" width="10.92233009708738%" headers="mcps1.1.6.1.3 "><p>-</p>
Z
zengyawen 已提交
52
    </td>
Z
zengyawen 已提交
53
    <td class="cellrowborder" valign="top" width="10.116504854368934%" headers="mcps1.1.6.1.4 "><p>否</p>
Z
zengyawen 已提交
54
    </td>
Z
zengyawen 已提交
55
    <td class="cellrowborder" valign="top" width="50.80582524271845%" headers="mcps1.1.6.1.5 "><p>不配置时表明pop为push时效果的逆播。</p>
Z
zengyawen 已提交
56 57
    </td>
    </tr>
Z
zengyawen 已提交
58
    <tr><td class="cellrowborder" valign="top" width="10.67961165048544%" headers="mcps1.1.6.1.1 "><p>duration</p>
Z
zengyawen 已提交
59
    </td>
Z
zengyawen 已提交
60
    <td class="cellrowborder" valign="top" width="17.47572815533981%" headers="mcps1.1.6.1.2 "><p>number</p>
Z
zengyawen 已提交
61
    </td>
Z
zengyawen 已提交
62
    <td class="cellrowborder" valign="top" width="10.92233009708738%" headers="mcps1.1.6.1.3 "><p>1000</p>
Z
zengyawen 已提交
63
    </td>
Z
zengyawen 已提交
64
    <td class="cellrowborder" valign="top" width="10.116504854368934%" headers="mcps1.1.6.1.4 "><p>否</p>
Z
zengyawen 已提交
65
    </td>
Z
zengyawen 已提交
66
    <td class="cellrowborder" valign="top" width="50.80582524271845%" headers="mcps1.1.6.1.5 "><p>动画时长,单位为毫秒。</p>
Z
zengyawen 已提交
67 68
    </td>
    </tr>
Z
zengyawen 已提交
69
    <tr><td class="cellrowborder" valign="top" width="10.67961165048544%" headers="mcps1.1.6.1.1 "><p>curve</p>
Z
zengyawen 已提交
70
    </td>
Z
zengyawen 已提交
71
    <td class="cellrowborder" valign="top" width="17.47572815533981%" headers="mcps1.1.6.1.2 "><p>Curve | Curves</p>
Z
zengyawen 已提交
72
    </td>
Z
zengyawen 已提交
73
    <td class="cellrowborder" valign="top" width="10.92233009708738%" headers="mcps1.1.6.1.3 "><p>Linear</p>
Z
zengyawen 已提交
74
    </td>
Z
zengyawen 已提交
75
    <td class="cellrowborder" valign="top" width="10.116504854368934%" headers="mcps1.1.6.1.4 "><p>否</p>
Z
zengyawen 已提交
76
    </td>
Z
zengyawen 已提交
77
    <td class="cellrowborder" valign="top" width="50.80582524271845%" headers="mcps1.1.6.1.5 "><p>动画曲线,有效值参见<a href="ts-animatorproperty.md#li16621545614">Curve</a> 说明。</p>
Z
zengyawen 已提交
78 79
    </td>
    </tr>
Z
zengyawen 已提交
80
    <tr><td class="cellrowborder" valign="top" width="10.67961165048544%" headers="mcps1.1.6.1.1 "><p>delay</p>
Z
zengyawen 已提交
81
    </td>
Z
zengyawen 已提交
82
    <td class="cellrowborder" valign="top" width="17.47572815533981%" headers="mcps1.1.6.1.2 "><p>number</p>
Z
zengyawen 已提交
83
    </td>
Z
zengyawen 已提交
84
    <td class="cellrowborder" valign="top" width="10.92233009708738%" headers="mcps1.1.6.1.3 "><p>0</p>
Z
zengyawen 已提交
85
    </td>
Z
zengyawen 已提交
86
    <td class="cellrowborder" valign="top" width="10.116504854368934%" headers="mcps1.1.6.1.4 "><p>否</p>
Z
zengyawen 已提交
87
    </td>
Z
zengyawen 已提交
88
    <td class="cellrowborder" valign="top" width="50.80582524271845%" headers="mcps1.1.6.1.5 "><p>动画延迟时长,单位为毫秒,默认不延时播放。</p>
Z
zengyawen 已提交
89 90 91 92 93 94 95 96
    </td>
    </tr>
    </tbody>
    </table>


-   <a name="li1364031695819"></a>RouteType枚举说明

Z
zengyawen 已提交
97
    <table><thead align="left"><tr><th class="cellrowborder" valign="top" width="25.2%" id="mcps1.1.3.1.1"><p>名称</p>
Z
zengyawen 已提交
98
    </th>
Z
zengyawen 已提交
99
    <th class="cellrowborder" valign="top" width="74.8%" id="mcps1.1.3.1.2"><p>描述</p>
Z
zengyawen 已提交
100 101 102
    </th>
    </tr>
    </thead>
Z
zengyawen 已提交
103
    <tbody><tr><td class="cellrowborder" valign="top" width="25.2%" headers="mcps1.1.3.1.1 "><p>Pop</p>
Z
zengyawen 已提交
104
    </td>
Z
zengyawen 已提交
105
    <td class="cellrowborder" valign="top" width="74.8%" headers="mcps1.1.3.1.2 "><p>PageA跳转到PageB时,PageA为Exit+Push,PageB为Enter+Push。</p>
Z
zengyawen 已提交
106 107
    </td>
    </tr>
Z
zengyawen 已提交
108
    <tr><td class="cellrowborder" valign="top" width="25.2%" headers="mcps1.1.3.1.1 "><p>Push</p>
Z
zengyawen 已提交
109
    </td>
Z
zengyawen 已提交
110
    <td class="cellrowborder" valign="top" width="74.8%" headers="mcps1.1.3.1.2 "><p>PageB返回至PageA时,PageA为Enter+Pop,PageB为Exit+Pop。</p>
Z
zengyawen 已提交
111 112 113 114 115 116 117 118 119 120
    </td>
    </tr>
    </tbody>
    </table>


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

PageTransitionEnter和PageTransitionExit组件支持的属性:

Z
zengyawen 已提交
121
<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="10.679611650485436%" id="mcps1.1.6.1.1"><p>参数名称</p>
Z
zengyawen 已提交
122
</th>
Z
zengyawen 已提交
123
<th class="cellrowborder" valign="top" width="19.28155339805825%" id="mcps1.1.6.1.2"><p>参数类型</p>
Z
zengyawen 已提交
124
</th>
Z
zengyawen 已提交
125
<th class="cellrowborder" valign="top" width="14.24271844660194%" id="mcps1.1.6.1.3"><p>默认值</p>
Z
zengyawen 已提交
126
</th>
Z
zengyawen 已提交
127
<th class="cellrowborder" valign="top" width="9.155339805825243%" id="mcps1.1.6.1.4"><p>必填</p>
Z
zengyawen 已提交
128
</th>
Z
zengyawen 已提交
129
<th class="cellrowborder" valign="top" width="46.640776699029125%" id="mcps1.1.6.1.5"><p>参数描述</p>
Z
zengyawen 已提交
130 131 132
</th>
</tr>
</thead>
Z
zengyawen 已提交
133
<tbody><tr><td class="cellrowborder" valign="top" width="10.679611650485436%" headers="mcps1.1.6.1.1 "><p>slide</p>
Z
zengyawen 已提交
134
</td>
Z
zengyawen 已提交
135
<td class="cellrowborder" valign="top" width="19.28155339805825%" headers="mcps1.1.6.1.2 "><p>SlideEffect</p>
Z
zengyawen 已提交
136
</td>
Z
zengyawen 已提交
137
<td class="cellrowborder" valign="top" width="14.24271844660194%" headers="mcps1.1.6.1.3 "><p>Right</p>
Z
zengyawen 已提交
138
</td>
Z
zengyawen 已提交
139
<td class="cellrowborder" valign="top" width="9.155339805825243%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
140
</td>
Z
zengyawen 已提交
141
<td class="cellrowborder" valign="top" width="46.640776699029125%" headers="mcps1.1.6.1.5 "><p>设置转场的滑入效果,有效值参见<a href="#li81331342185820">SlideEffect</a>说明。</p>
Z
zengyawen 已提交
142 143
</td>
</tr>
Z
zengyawen 已提交
144
<tr><td class="cellrowborder" valign="top" width="10.679611650485436%" headers="mcps1.1.6.1.1 "><p>translate</p>
Z
zengyawen 已提交
145
</td>
Z
zengyawen 已提交
146 147 148 149 150
<td class="cellrowborder" valign="top" width="19.28155339805825%" headers="mcps1.1.6.1.2 "><p>{</p>
<p>x? : number,</p>
<p>y? : number,</p>
<p>z? : number</p>
<p>}</p>
Z
zengyawen 已提交
151
</td>
Z
zengyawen 已提交
152
<td class="cellrowborder" valign="top" width="14.24271844660194%" headers="mcps1.1.6.1.3 "><p>-</p>
Z
zengyawen 已提交
153
</td>
Z
zengyawen 已提交
154
<td class="cellrowborder" valign="top" width="9.155339805825243%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
155
</td>
Z
zengyawen 已提交
156
<td class="cellrowborder" valign="top" width="46.640776699029125%" headers="mcps1.1.6.1.5 "><p>设置页面转场时的平移效果,为入场时起点和退场时终点的值,和slide同时设置时默认生效slide。</p>
Z
zengyawen 已提交
157 158
</td>
</tr>
Z
zengyawen 已提交
159
<tr><td class="cellrowborder" valign="top" width="10.679611650485436%" headers="mcps1.1.6.1.1 "><p>scale</p>
Z
zengyawen 已提交
160
</td>
Z
zengyawen 已提交
161 162 163 164 165 166 167
<td class="cellrowborder" valign="top" width="19.28155339805825%" headers="mcps1.1.6.1.2 "><p>{</p>
<p>x? : number,</p>
<p>y? : number,</p>
<p>z? : number,</p>
<p>centerX? : number,</p>
<p>centerY? : number</p>
<p>}</p>
Z
zengyawen 已提交
168
</td>
Z
zengyawen 已提交
169
<td class="cellrowborder" valign="top" width="14.24271844660194%" headers="mcps1.1.6.1.3 "><p>-</p>
Z
zengyawen 已提交
170
</td>
Z
zengyawen 已提交
171
<td class="cellrowborder" valign="top" width="9.155339805825243%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
172
</td>
Z
zengyawen 已提交
173
<td class="cellrowborder" valign="top" width="46.640776699029125%" headers="mcps1.1.6.1.5 "><p>设置页面转场时的缩放效果,为入场时起点和退场时终点的值。</p>
Z
zengyawen 已提交
174 175
</td>
</tr>
Z
zengyawen 已提交
176
<tr><td class="cellrowborder" valign="top" width="10.679611650485436%" headers="mcps1.1.6.1.1 "><p>opacity</p>
Z
zengyawen 已提交
177
</td>
Z
zengyawen 已提交
178
<td class="cellrowborder" valign="top" width="19.28155339805825%" headers="mcps1.1.6.1.2 "><p>number</p>
Z
zengyawen 已提交
179
</td>
Z
zengyawen 已提交
180
<td class="cellrowborder" valign="top" width="14.24271844660194%" headers="mcps1.1.6.1.3 "><p>1</p>
Z
zengyawen 已提交
181
</td>
Z
zengyawen 已提交
182
<td class="cellrowborder" valign="top" width="9.155339805825243%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
183
</td>
Z
zengyawen 已提交
184
<td class="cellrowborder" valign="top" width="46.640776699029125%" headers="mcps1.1.6.1.5 "><p>设置入场的起点透明度值或者退场的终点透明度值。</p>
Z
zengyawen 已提交
185 186 187 188 189 190 191
</td>
</tr>
</tbody>
</table>

-   <a name="li81331342185820"></a>SlideEffect枚举说明

Z
zengyawen 已提交
192
    <table><thead align="left"><tr><th class="cellrowborder" valign="top" width="25.2%" id="mcps1.1.3.1.1"><p>名称</p>
Z
zengyawen 已提交
193
    </th>
Z
zengyawen 已提交
194
    <th class="cellrowborder" valign="top" width="74.8%" id="mcps1.1.3.1.2"><p>描述</p>
Z
zengyawen 已提交
195 196 197
    </th>
    </tr>
    </thead>
Z
zengyawen 已提交
198
    <tbody><tr><td class="cellrowborder" valign="top" width="25.2%" headers="mcps1.1.3.1.1 "><p>Left</p>
Z
zengyawen 已提交
199
    </td>
Z
zengyawen 已提交
200
    <td class="cellrowborder" valign="top" width="74.8%" headers="mcps1.1.3.1.2 "><p>设置到入场时表示从左边滑入,出场时表示滑出到左边。</p>
Z
zengyawen 已提交
201 202
    </td>
    </tr>
Z
zengyawen 已提交
203
    <tr><td class="cellrowborder" valign="top" width="25.2%" headers="mcps1.1.3.1.1 "><p>Right</p>
Z
zengyawen 已提交
204
    </td>
Z
zengyawen 已提交
205
    <td class="cellrowborder" valign="top" width="74.8%" headers="mcps1.1.3.1.2 "><p>设置到入场时表示从右边滑入,出场时表示滑出到右边。</p>
Z
zengyawen 已提交
206 207
    </td>
    </tr>
Z
zengyawen 已提交
208
    <tr><td class="cellrowborder" valign="top" width="25.2%" headers="mcps1.1.3.1.1 "><p>Top</p>
Z
zengyawen 已提交
209
    </td>
Z
zengyawen 已提交
210
    <td class="cellrowborder" valign="top" width="74.8%" headers="mcps1.1.3.1.2 "><p>设置到入场时表示从上边滑入,出场时表示滑出到上边。</p>
Z
zengyawen 已提交
211 212
    </td>
    </tr>
Z
zengyawen 已提交
213
    <tr><td class="cellrowborder" valign="top" width="25.2%" headers="mcps1.1.3.1.1 "><p>Bottom</p>
Z
zengyawen 已提交
214
    </td>
Z
zengyawen 已提交
215
    <td class="cellrowborder" valign="top" width="74.8%" headers="mcps1.1.3.1.2 "><p>设置到入场时表示从下边滑入,出场时表示滑出到下边。</p>
Z
zengyawen 已提交
216 217 218 219 220 221 222 223 224 225
    </td>
    </tr>
    </tbody>
    </table>


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

PageTransitionEnter和PageTransitionExit组件支持的事件:

Z
zengyawen 已提交
226
<table><thead align="left"><tr><th class="cellrowborder" colspan="2" valign="top" id="mcps1.1.4.1.1"><p>事件</p>
Z
zengyawen 已提交
227
</th>
Z
zengyawen 已提交
228
<th class="cellrowborder" valign="top" id="mcps1.1.4.1.2"><p>功能描述</p>
Z
zengyawen 已提交
229 230 231
</th>
</tr>
</thead>
Z
zengyawen 已提交
232
<tbody><tr><td class="cellrowborder" colspan="2" valign="top" headers="mcps1.1.4.1.1 "><p>onEnter(type: RouteType, progress: number) =&gt; void</p>
Z
zengyawen 已提交
233
</td>
Z
zengyawen 已提交
234
<td class="cellrowborder" valign="top" headers="mcps1.1.4.1.2 "><p>回调入参为当前入场动画的归一化进度[0 - 1]。</p>
Z
zengyawen 已提交
235 236
</td>
</tr>
Z
zengyawen 已提交
237
<tr><td class="cellrowborder" colspan="2" valign="top" headers="mcps1.1.4.1.1 "><p>onExit(type: RouteType, progress: number) =&gt; void</p>
Z
zengyawen 已提交
238
</td>
Z
zengyawen 已提交
239
<td class="cellrowborder" valign="top" headers="mcps1.1.4.1.2 "><p>回调入参为当前退场动画的归一化进度[0 - 1]。</p>
Z
zengyawen 已提交
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 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
</td>
</tr>
</tbody>
</table>

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

自定义方式1:配置了当前页面的入场动画为淡入,退场动画为缩小。

```
// index.ets
@Entry
@Component
struct PageTransitionExample1 {
  @State scale: number = 1
  @State opacity: number = 1
  @State active: boolean = false
  build() {
  Column() {
      Navigator({ target: 'pages/page1', type: NavigationType.Push }) {
        Image($r('app.media.bg1')).width("100%").height("100%")
      }
      .onClick(() => {
        this.active = true
      })
    }.scale({ x: this.scale }).opacity(this.opacity)
  }
// 自定义方式1:完全自定义转场过程的效果
  pageTransition() {
    PageTransitionEnter({ duration: 1200, curve: Curve.Linear })
      .onEnter((type: RouteType, progress: number) => {
        this.scale = 1
        this.opacity = progress
      }) // 进场过程中会逐帧触发onEnter回调,入参为动效的归一化进度(0% -- 100%)
    PageTransitionExit({ duration: 1500, curve: Curve.Ease })
      .onExit((type: RouteType, progress: number) => {
        this.scale = 1 - progress
        this.opacity = 1
      }) // 退场过程中会逐帧触发onExit回调,入参为动效的归一化进度(0% -- 100%)
  }
}
```

```
// page1.ets
@Entry
@Component
struct AExample {
  @State scale: number = 1
  @State opacity: number = 1
  @State active: boolean = false
  build() {
    Column() {
      Navigator({ target: 'pages/index' ,type: NavigationType.Push}) {
        Image($r('app.media.bg2')).width("100%").height("100%")
      }
    }.height("100%").width("100%").scale({ x: this.scale }).opacity(this.opacity)
  }
// 自定义方式1:完全自定义转场过程的效果
  pageTransition() {
    PageTransitionEnter({ duration: 1200, curve: Curve.Linear })
      .onEnter((type: RouteType, progress: number) => {
        this.scale = 1
        this.opacity = progress
      }) // 进场过程中会逐帧触发onEnter回调,入参为动效的归一化进度(0% -- 100%)
    PageTransitionExit({ duration: 1500, curve: Curve.Ease })
      .onExit((type: RouteType, progress: number) => {
        this.scale = 1 - progress
        this.opacity = 1
      }) // 退场过程中会逐帧触发onExit回调,入参为动效的归一化进度(0% -- 100%)
  }
}
```

![](figures/PageTransition1.gif)

自定义方式2:配置了当前页面的入场动画为从左侧滑入,退场为缩小加透明度变化。

```
// index.ets 
@Entry
@Component
struct PageTransitionExample {
  @State scale: number = 1
  @State opacity: number = 1
  @State active: boolean = false

  build() {
    Column() {
      Navigator({ target: 'pages/page1', type: NavigationType.Push }) {
        Image($r('app.media.bg1')).width("100%").height("100%")
      }
      .onClick(() => {
        this.active = true
      })
    }.scale({ x: this.scale }).opacity(this.opacity)
  }

// 自定义方式2:使用系统提供的多种默认效果(平移、缩放、透明度等)
  pageTransition() {
    PageTransitionEnter({ duration: 1200 })
      .slide(SlideEffect.Left)
    PageTransitionExit({ delay: 100 })
      .translate({ x: 100.0, y: 100.0 })
      .opacity(0)
  }
}
```

```
// page1.ets
@Entry
@Component
struct PageTransitionExample1 {
  @State scale: number = 1
  @State opacity: number = 1
  @State active: boolean = false

  build() {
    Column() {
      Navigator({ target: 'pages/index', type: NavigationType.Push }) {
        Image($r('app.media.bg2')).width  ("100%").height("100%")
      }
      .onClick(() => {
        this.active = true
      })
    }.scale({ x: this.scale }).opacity(this.opacity)
  }

// 自定义方式2:使用系统提供的多种默认效果(平移、缩放、透明度等)
  pageTransition() {
    PageTransitionEnter({ duration: 1200 })
      .slide(SlideEffect.Left)
    PageTransitionExit({ delay: 100 })
      .translate({ x: 100.0, y: 100.0 })
      .opacity(0)
  }
}
```

![](figures/PageTransition2.gif)