1e41f4b71Sopenharmony_ci# Page Transition (pageTransition) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciYou can customize the page entrance and exit animations in the **pageTransition** API for transition between pages. For details, see [Page Transition Animation](../../../ui/arkts-page-transition-animation.md). 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> To achieve a better transition effect, you are advised to use the [Navigation](../../../ui/arkts-navigation-navigation.md) component and [modal transition](../../../ui/arkts-modal-transition.md). 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## pageTransition 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_cipageTransition?(): void 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ciDefines the transition animation to play when the user accesses this page or is redirected from this page to another page. 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci## PageTransitionEnter 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciPageTransitionEnter(value: PageTransitionOptions) 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ciPage entrance animation. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**Parameters** 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 34e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------ | ---- | -------------------- | 35e41f4b71Sopenharmony_ci| value | [PageTransitionOptions](#pagetransitionoptions) | Yes | Page entrance animation.| 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci## PageTransitionExit 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ciPageTransitionExit(value: PageTransitionOptions) 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ciPage exit animation. 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci**Parameters** 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 50e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------- | ---- | -------------------- | 51e41f4b71Sopenharmony_ci| value | [PageTransitionOptions](#pagetransitionoptions) | Yes | Page exit animation.| 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci## PageTransitionOptions 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 58e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 59e41f4b71Sopenharmony_ci| type | [RouteType](#routetype) | No | Route type for the page transition effect to take effect.<br>Default value: **RouteType.None** | 60e41f4b71Sopenharmony_ci| duration | number | No | Animation duration.<br>Unit: ms<br>Default value: **1000** | 61e41f4b71Sopenharmony_ci| curve | [Curve](ts-appendix-enums.md#curve) \| string \| [ICurve](../js-apis-curve.md#icurve9)<sup>10+</sup> | No | Animation curve. The value of the string type can be any of the following: "ease", "ease-in", "ease-out", "ease-in-out", "extreme-deceleration", "fast-out-linear-in", "fast-out-slow-in", "friction", "linear", "linear-out-slow-in", "rhythm", "sharp", "smooth".<br>Default value: **Curve.Linear**| 62e41f4b71Sopenharmony_ci| delay | number | No | Animation delay.<br>Unit: ms<br>Default value: **0**<br>**NOTE**<br>If no match is found, the default page transition effect is used (which may vary according to the device). To disable the default page transition effect, set **duration** to **0**.| 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci## Attributes 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 70e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 71e41f4b71Sopenharmony_ci| slide | [SlideEffect](#slideeffect) | No | Slide effect during page transition.| 72e41f4b71Sopenharmony_ci| translate | {<br>x? : number \| string;<br>y? : number \| string;<br>z? : number \| string<br>} | No | Translation effect during page transition, which is the value of the start point of entrance and the end point of exit. When this parameter is set together with **slide**, the latter takes effect by default.<br>- **x**: translation distance along the x-axis.<br>- **y**: translation distance along the y-axis.<br>- **z**: translation distance along the y-axis.| 73e41f4b71Sopenharmony_ci| scale | {<br>x? : number;<br>y? : number;<br>z? : number;<br>centerX? : number \| string;<br>centerY? : number \| string<br>} | No | Scaling effect during page transition, which is the value of the start point of entrance and the end point of exit.<br>- **x**: scale ratio along the x-axis.<br>- **y**: scale ratio along the y-axis.<br>- **z**: scale ratio along the z-axis.<br>- **centerX** and **centerY**: scale center point. The default values are both **"50%"**, indicating that the center point of the page.<br>- If the center point is (0, 0), it refers to the upper left corner of the component.<br>| 74e41f4b71Sopenharmony_ci| opacity | number | No | Opacity, which is the opacity value of the start point of entrance or the end point of exit.| 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci## Events 78e41f4b71Sopenharmony_ci### onEnter 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_cionEnter(event: (type: RouteType, progress: number) => void): PageTransitionEnterInterface 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ciInvoked on a per-frame basis until the entrance animation is complete, with the **progress** parameter changing from 0 to 1. 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci**Parameters** 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 91e41f4b71Sopenharmony_ci| ------ | ----------------------------------------------------------------- | ---- | ------------------------------------------------ | 92e41f4b71Sopenharmony_ci| event | (type: [RouteType](#routetype), progress: number) => void | Yes | Callback invoked on a per-frame basis until the entrance animation is complete, with the **progress** parameter changing from 0 to 1.| 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci**Example** 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci```js 97e41f4b71Sopenharmony_ci pageTransition() { 98e41f4b71Sopenharmony_ci PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) 99e41f4b71Sopenharmony_ci // During the transition animation, the entrance animation has a type that represents the route type, and a progress that increases from 0 to 1. 100e41f4b71Sopenharmony_ci .onEnter((type: RouteType, progress: number) => { 101e41f4b71Sopenharmony_ci // Service logic 102e41f4b71Sopenharmony_ci }) 103e41f4b71Sopenharmony_ci } 104e41f4b71Sopenharmony_ci``` 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci### onExit 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_cionExit(event: (type: RouteType, progress: number) => void): PageTransitionExitInterface 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ciInvoked on a per-frame basis until the exit animation is complete, with the **progress** parameter changing from 0 to 1. 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci**Parameters** 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 119e41f4b71Sopenharmony_ci| ------ | ----------------------------------------------------------------- | ---- | ------------------------------------------------ | 120e41f4b71Sopenharmony_ci| event | (type: [RouteType](#routetype), progress: number) => void | Yes | Callback invoked on a per-frame basis until the exit animation is complete, with the **progress** parameter changing from 0 to 1.| 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci**Example** 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci```js 125e41f4b71Sopenharmony_ci pageTransition() { 126e41f4b71Sopenharmony_ci PageTransitionExit({ duration: 1200, curve: Curve.Linear }) 127e41f4b71Sopenharmony_ci // During the transition animation, the exit animation has a type that represents the route type, and a progress that increases from 0 to 1. 128e41f4b71Sopenharmony_ci .onExit((type: RouteType, progress: number) => { 129e41f4b71Sopenharmony_ci // Service logic 130e41f4b71Sopenharmony_ci }) 131e41f4b71Sopenharmony_ci } 132e41f4b71Sopenharmony_ci``` 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci ## RouteType 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci| Name| Description | 142e41f4b71Sopenharmony_ci| ---- | ------------------------------------------------------------ | 143e41f4b71Sopenharmony_ci| Pop | Redirects to a specified page. To redirect the user from page B back to page A, set **RouteType** of **PageTransitionExit** to **None** or **Pop** for page B and set **RouteType** of **PageTransitionEnter** to **None** or **Pop** for page A.| 144e41f4b71Sopenharmony_ci| Push | Redirects to the next page. To redirect the user from page A to page B, set **RouteType** of **PageTransitionExit** to **None** or **Push** for page A and set **RouteType** of **PageTransitionEnter** to **None** or **Push** for page B.| 145e41f4b71Sopenharmony_ci| None | The page is not redirected. The animation specified by **PageTransitionEnter** takes effect for page entrance, and the animation specified by **PageTransitionExit** takes effect for page exit.| 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci## SlideEffect 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci| Name | Description | 150e41f4b71Sopenharmony_ci| ------------------- | ------------------------------------------------------------ | 151e41f4b71Sopenharmony_ci| Left | When set to Enter, slides in from the left. When set to Exit, slides out to the left.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 152e41f4b71Sopenharmony_ci| Right | When set to Enter, slides in from the right. When set to Exit, slides out to the right.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 153e41f4b71Sopenharmony_ci| Top | When set to Enter, slides in from the top. When set to Exit, slides out to the top.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 154e41f4b71Sopenharmony_ci| Bottom | When set to Enter, slides in from the bottom. When set to Exit, slides out to the bottom.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 155e41f4b71Sopenharmony_ci| START<sup>12+</sup> | Left-to-right scripts: When set to Enter, slides in from the left; when set to Exit, slides out to the left. Right-to-left scripts: When set to Enter, slides in from the right; when set to Exit, slides out to the right.<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 156e41f4b71Sopenharmony_ci| END<sup>12+</sup> | Left-to-right scripts: When set to Enter, slides in from the right; when set to Exit, slides out to the right. Right-to-left scripts: When set to Enter, slides in from the left; when set to Exit, slides out to the left.<br>**Atomic service API**: This API can be used in atomic services since API version 12.| 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci## Example 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ci### Example 1 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ciExample 1: Apply different exit and entry animations based on different exit and entry types. 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ci```ts 165e41f4b71Sopenharmony_ci// index.ets 166e41f4b71Sopenharmony_ciimport { router } from '@kit.ArkUI'; 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci@Entry 169e41f4b71Sopenharmony_ci@Component 170e41f4b71Sopenharmony_cistruct Index { 171e41f4b71Sopenharmony_ci @State scale1: number = 1 172e41f4b71Sopenharmony_ci @State opacity1: number = 1 173e41f4b71Sopenharmony_ci 174e41f4b71Sopenharmony_ci build() { 175e41f4b71Sopenharmony_ci Column() { 176e41f4b71Sopenharmony_ci Image($r("app.media.transition_image1")).width('100%').height('100%') 177e41f4b71Sopenharmony_ci } 178e41f4b71Sopenharmony_ci .width('100%') 179e41f4b71Sopenharmony_ci .height('100%') 180e41f4b71Sopenharmony_ci .scale({ x: this.scale1 }) 181e41f4b71Sopenharmony_ci .opacity(this.opacity1) 182e41f4b71Sopenharmony_ci .onClick(() => { 183e41f4b71Sopenharmony_ci router.pushUrl({ url: 'pages/Page1' }) 184e41f4b71Sopenharmony_ci }) 185e41f4b71Sopenharmony_ci } 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ci pageTransition() { 188e41f4b71Sopenharmony_ci PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) 189e41f4b71Sopenharmony_ci .onEnter((type: RouteType, progress: number) => { 190e41f4b71Sopenharmony_ci if (type == RouteType.Push||type == RouteType.Pop) { 191e41f4b71Sopenharmony_ci this.scale1 = progress 192e41f4b71Sopenharmony_ci this.opacity1 = progress 193e41f4b71Sopenharmony_ci } 194e41f4b71Sopenharmony_ci }) 195e41f4b71Sopenharmony_ci PageTransitionExit({ duration: 1200, curve: Curve.Ease }) 196e41f4b71Sopenharmony_ci .onExit((type: RouteType, progress: number) => { 197e41f4b71Sopenharmony_ci if (type == RouteType.Push) { 198e41f4b71Sopenharmony_ci this.scale1 = 1 - progress 199e41f4b71Sopenharmony_ci this.opacity1 = 1 - progress 200e41f4b71Sopenharmony_ci } 201e41f4b71Sopenharmony_ci }) 202e41f4b71Sopenharmony_ci } 203e41f4b71Sopenharmony_ci} 204e41f4b71Sopenharmony_ci``` 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci```ts 207e41f4b71Sopenharmony_ci// page1.ets 208e41f4b71Sopenharmony_ciimport { router } from '@kit.ArkUI'; 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci@Entry 211e41f4b71Sopenharmony_ci@Component 212e41f4b71Sopenharmony_cistruct Page1 { 213e41f4b71Sopenharmony_ci @State scale2: number = 1 214e41f4b71Sopenharmony_ci @State opacity2: number = 1 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci build() { 217e41f4b71Sopenharmony_ci Column() { 218e41f4b71Sopenharmony_ci Image($r("app.media.transition_image2")).width('100%').height('100%') // Store the image in the media folder. 219e41f4b71Sopenharmony_ci } 220e41f4b71Sopenharmony_ci .width('100%') 221e41f4b71Sopenharmony_ci .height('100%') 222e41f4b71Sopenharmony_ci .scale({ x: this.scale2 }) 223e41f4b71Sopenharmony_ci .opacity(this.opacity2) 224e41f4b71Sopenharmony_ci .onClick(() => { 225e41f4b71Sopenharmony_ci router.pushUrl({ url: 'pages/Index' }) 226e41f4b71Sopenharmony_ci }) 227e41f4b71Sopenharmony_ci } 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci pageTransition() { 230e41f4b71Sopenharmony_ci PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) 231e41f4b71Sopenharmony_ci .onEnter((type: RouteType, progress: number) => { 232e41f4b71Sopenharmony_ci if(type==RouteType.Push || type == RouteType.Pop) 233e41f4b71Sopenharmony_ci this.scale2 = progress 234e41f4b71Sopenharmony_ci this.opacity2 = progress 235e41f4b71Sopenharmony_ci 236e41f4b71Sopenharmony_ci }) 237e41f4b71Sopenharmony_ci PageTransitionExit({ duration: 1200, curve: Curve.Ease }) 238e41f4b71Sopenharmony_ci .onExit((type: RouteType, progress: number) => { 239e41f4b71Sopenharmony_ci if (type == RouteType.Pop) { 240e41f4b71Sopenharmony_ci this.scale2 = 1 - progress 241e41f4b71Sopenharmony_ci this.opacity2 = 1 - progress 242e41f4b71Sopenharmony_ci } 243e41f4b71Sopenharmony_ci }) 244e41f4b71Sopenharmony_ci } 245e41f4b71Sopenharmony_ci} 246e41f4b71Sopenharmony_ci``` 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ciExample 2: Apply the entrance animation of sliding in from the left and the exit animation of translating with opacity change. 251e41f4b71Sopenharmony_ci 252e41f4b71Sopenharmony_ci```ts 253e41f4b71Sopenharmony_ci// index.ets 254e41f4b71Sopenharmony_ci@Entry 255e41f4b71Sopenharmony_ci@Component 256e41f4b71Sopenharmony_cistruct PageTransitionExample { 257e41f4b71Sopenharmony_ci build() { 258e41f4b71Sopenharmony_ci Column() { 259e41f4b71Sopenharmony_ci Navigator({ target: 'pages/page1', type: NavigationType.Push }) { 260e41f4b71Sopenharmony_ci Image($r('app.media.bg1')).width('100%').height('100%') // Store the image in the media folder. 261e41f4b71Sopenharmony_ci } 262e41f4b71Sopenharmony_ci } 263e41f4b71Sopenharmony_ci } 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci // Use the default effects provided by the system, such as translation, scaling, and opacity. 266e41f4b71Sopenharmony_ci pageTransition() { 267e41f4b71Sopenharmony_ci // Set the duration of the entrance animation to 1200 ms, in the purpose of matching the duration of the exit animation of the other page. 268e41f4b71Sopenharmony_ci PageTransitionEnter({ duration: 1200 }) 269e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 270e41f4b71Sopenharmony_ci // Set the duration of the exit animation to 1000 ms, in the purpose of matching the duration of the entrance animation of the other page. 271e41f4b71Sopenharmony_ci PageTransitionExit({ duration: 1000 }) 272e41f4b71Sopenharmony_ci .translate({ x: 100.0, y: 100.0 }) 273e41f4b71Sopenharmony_ci .opacity(0) 274e41f4b71Sopenharmony_ci } 275e41f4b71Sopenharmony_ci} 276e41f4b71Sopenharmony_ci``` 277e41f4b71Sopenharmony_ci 278e41f4b71Sopenharmony_ci```ts 279e41f4b71Sopenharmony_ci// page1.ets 280e41f4b71Sopenharmony_ci@Entry 281e41f4b71Sopenharmony_ci@Component 282e41f4b71Sopenharmony_cistruct PageTransitionExample1 { 283e41f4b71Sopenharmony_ci build() { 284e41f4b71Sopenharmony_ci Column() { 285e41f4b71Sopenharmony_ci Navigator({ target: 'pages/index', type: NavigationType.Push }) { 286e41f4b71Sopenharmony_ci Image($r('app.media.bg2')).width('100%').height('100%') // Store the image in the media folder. 287e41f4b71Sopenharmony_ci } 288e41f4b71Sopenharmony_ci } 289e41f4b71Sopenharmony_ci } 290e41f4b71Sopenharmony_ci 291e41f4b71Sopenharmony_ci // Use the default effects provided by the system, such as translation, scaling, and opacity. 292e41f4b71Sopenharmony_ci pageTransition() { 293e41f4b71Sopenharmony_ci // Set the duration of the entrance animation to 1000 ms, in the purpose of matching the duration of the exit animation of the other page. 294e41f4b71Sopenharmony_ci PageTransitionEnter({ duration: 1000 }) 295e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 296e41f4b71Sopenharmony_ci // Set the duration of the exit animation to 1200 ms, in the purpose of matching the duration of the entrance animation of the other page. 297e41f4b71Sopenharmony_ci PageTransitionExit({ duration: 1200 }) 298e41f4b71Sopenharmony_ci .translate({ x: 100.0, y: 100.0 }) 299e41f4b71Sopenharmony_ci .opacity(0) 300e41f4b71Sopenharmony_ci } 301e41f4b71Sopenharmony_ci} 302e41f4b71Sopenharmony_ci``` 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci 305e41f4b71Sopenharmony_ci 306e41f4b71Sopenharmony_ci### Example 2 307e41f4b71Sopenharmony_ci 308e41f4b71Sopenharmony_ciCustomization method 1: Configure the various entrance and exit translation effects provided, with the system language layout mode set to right-to-left (RTL). 309e41f4b71Sopenharmony_ci 310e41f4b71Sopenharmony_ci```ts 311e41f4b71Sopenharmony_ci// index.ets 312e41f4b71Sopenharmony_ciimport { router } from '@kit.ArkUI' 313e41f4b71Sopenharmony_ci 314e41f4b71Sopenharmony_ci@Entry 315e41f4b71Sopenharmony_ci@Component 316e41f4b71Sopenharmony_cistruct PageTransitionExample { 317e41f4b71Sopenharmony_ci @State scale1: number = 1 318e41f4b71Sopenharmony_ci @State opacity1: number = 1 319e41f4b71Sopenharmony_ci 320e41f4b71Sopenharmony_ci build() { 321e41f4b71Sopenharmony_ci Column() { 322e41f4b71Sopenharmony_ci Button("Page 1").onClick(()=>{ 323e41f4b71Sopenharmony_ci router.pushUrl({ 324e41f4b71Sopenharmony_ci url:"pages/page1" 325e41f4b71Sopenharmony_ci }) 326e41f4b71Sopenharmony_ci }) 327e41f4b71Sopenharmony_ci .width(200) 328e41f4b71Sopenharmony_ci .height(60) 329e41f4b71Sopenharmony_ci .fontSize(36) 330e41f4b71Sopenharmony_ci Text("START") 331e41f4b71Sopenharmony_ci .fontSize(36) 332e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 333e41f4b71Sopenharmony_ci }.scale({ x: this.scale1 }).opacity(this.opacity1).height("100%").width("100%").justifyContent(FlexAlign.Center) 334e41f4b71Sopenharmony_ci } 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ci // Use the default effects provided by the system, such as translation, scaling, and opacity. 337e41f4b71Sopenharmony_ci pageTransition() { 338e41f4b71Sopenharmony_ci // Set the entrance animation. 339e41f4b71Sopenharmony_ci PageTransitionEnter({ duration: 200 }) 340e41f4b71Sopenharmony_ci .slide(SlideEffect.START) 341e41f4b71Sopenharmony_ci // Set the exit animation. 342e41f4b71Sopenharmony_ci PageTransitionExit({ delay: 100 }) 343e41f4b71Sopenharmony_ci .slide(SlideEffect.START) //Left 344e41f4b71Sopenharmony_ci } 345e41f4b71Sopenharmony_ci} 346e41f4b71Sopenharmony_ci``` 347e41f4b71Sopenharmony_ci 348e41f4b71Sopenharmony_ci```ts 349e41f4b71Sopenharmony_ci// page1.ets 350e41f4b71Sopenharmony_ciimport { router } from '@kit.ArkUI' 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_ci@Entry 353e41f4b71Sopenharmony_ci@Component 354e41f4b71Sopenharmony_cistruct PageTransitionExample { 355e41f4b71Sopenharmony_ci @State scale1: number = 1 356e41f4b71Sopenharmony_ci @State opacity1: number = 1 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ci build() { 359e41f4b71Sopenharmony_ci Column() { 360e41f4b71Sopenharmony_ci Button("Page 2").onClick(()=>{ 361e41f4b71Sopenharmony_ci router.pushUrl({ 362e41f4b71Sopenharmony_ci url:"pages/Index" 363e41f4b71Sopenharmony_ci }) 364e41f4b71Sopenharmony_ci }) 365e41f4b71Sopenharmony_ci .width(200) 366e41f4b71Sopenharmony_ci .height(60) 367e41f4b71Sopenharmony_ci .fontSize(36) 368e41f4b71Sopenharmony_ci Text("END") 369e41f4b71Sopenharmony_ci .fontSize(36) 370e41f4b71Sopenharmony_ci .textAlign(TextAlign.Center) 371e41f4b71Sopenharmony_ci }.scale({ x: this.scale1 }).opacity(this.opacity1).height("100%").width("100%").justifyContent(FlexAlign.Center) 372e41f4b71Sopenharmony_ci } 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_ci // Use the default effects provided by the system, such as translation, scaling, and opacity. 375e41f4b71Sopenharmony_ci pageTransition() { 376e41f4b71Sopenharmony_ci PageTransitionEnter({ duration: 200 }) 377e41f4b71Sopenharmony_ci .slide(SlideEffect.END) //Right 378e41f4b71Sopenharmony_ci PageTransitionExit({ delay:100 }) 379e41f4b71Sopenharmony_ci .slide(SlideEffect.END) //Right 380e41f4b71Sopenharmony_ci } 381e41f4b71Sopenharmony_ci} 382e41f4b71Sopenharmony_ci 383e41f4b71Sopenharmony_ci``` 384e41f4b71Sopenharmony_ci 385e41f4b71Sopenharmony_ci 386e41f4b71Sopenharmony_ci 387e41f4b71Sopenharmony_ciCustomization method 2: Use the system's default entrance and exit effects, with the system language layout mode set to right-to-left (RTL). 388e41f4b71Sopenharmony_ci 389e41f4b71Sopenharmony_ci```ts 390e41f4b71Sopenharmony_ci// index.ets 391e41f4b71Sopenharmony_ciimport { router } from '@kit.ArkUI' 392e41f4b71Sopenharmony_ci 393e41f4b71Sopenharmony_ci@Entry 394e41f4b71Sopenharmony_ci@Component 395e41f4b71Sopenharmony_cistruct PageTransitionExample { 396e41f4b71Sopenharmony_ci @State scale1: number = 1 397e41f4b71Sopenharmony_ci @State opacity1: number = 1 398e41f4b71Sopenharmony_ci 399e41f4b71Sopenharmony_ci build() { 400e41f4b71Sopenharmony_ci Column() { 401e41f4b71Sopenharmony_ci Button("Page 1").onClick(()=>{ 402e41f4b71Sopenharmony_ci router.pushUrl({ 403e41f4b71Sopenharmony_ci url:"pages/page1" 404e41f4b71Sopenharmony_ci }) 405e41f4b71Sopenharmony_ci }) 406e41f4b71Sopenharmony_ci .width(200) 407e41f4b71Sopenharmony_ci .height(60) 408e41f4b71Sopenharmony_ci .fontSize(36) 409e41f4b71Sopenharmony_ci }.scale({ x: this.scale1 }).opacity(this.opacity1).height("100%").width("100%").justifyContent(FlexAlign.Center) 410e41f4b71Sopenharmony_ci } 411e41f4b71Sopenharmony_ci} 412e41f4b71Sopenharmony_ci``` 413e41f4b71Sopenharmony_ci 414e41f4b71Sopenharmony_ci```ts 415e41f4b71Sopenharmony_ci// page1.ets 416e41f4b71Sopenharmony_ciimport { router } from '@kit.ArkUI' 417e41f4b71Sopenharmony_ci 418e41f4b71Sopenharmony_ci@Entry 419e41f4b71Sopenharmony_ci@Component 420e41f4b71Sopenharmony_cistruct PageTransitionExample { 421e41f4b71Sopenharmony_ci @State scale1: number = 1 422e41f4b71Sopenharmony_ci @State opacity1: number = 1 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ci build() { 425e41f4b71Sopenharmony_ci Column() { 426e41f4b71Sopenharmony_ci Button("Page 2").onClick(()=>{ 427e41f4b71Sopenharmony_ci router.pushUrl({ 428e41f4b71Sopenharmony_ci url:"pages/Index" 429e41f4b71Sopenharmony_ci }) 430e41f4b71Sopenharmony_ci }) 431e41f4b71Sopenharmony_ci .width(200) 432e41f4b71Sopenharmony_ci .height(60) 433e41f4b71Sopenharmony_ci .fontSize(36) 434e41f4b71Sopenharmony_ci }.scale({ x: this.scale1 }).opacity(this.opacity1).height("100%").width("100%").justifyContent(FlexAlign.Center) 435e41f4b71Sopenharmony_ci } 436e41f4b71Sopenharmony_ci} 437e41f4b71Sopenharmony_ci``` 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ci 440