1e41f4b71Sopenharmony_ci# Page Transition Animation (Not Recommended) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciTo achieve a better transition effect, you are advised to use the [\<Navigation>](arkts-navigation-transition.md) component and [modal transition](arkts-modal-transition.md). 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciDuring page redirection, one page enters and the other page exits. You can customize the [page transition effects](../reference/apis-arkui/arkui-ts/ts-page-transition-animation.md) for these pages through the **pageTransition** function. Specifically, [PageTransitionEnter](../reference/apis-arkui/arkui-ts/ts-page-transition-animation.md#pagetransitionenter) defines the page entrance animation, while [PageTransitionExit](../reference/apis-arkui/arkui-ts/ts-page-transition-animation.md#pagetransitionexit) defines the page exit animation. 6e41f4b71Sopenharmony_ciThe **pageTransition** function is as follows: 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci```ts 9e41f4b71Sopenharmony_cipageTransition() { 10e41f4b71Sopenharmony_ci PageTransitionEnter() 11e41f4b71Sopenharmony_ci PageTransitionExit() 12e41f4b71Sopenharmony_ci} 13e41f4b71Sopenharmony_ci``` 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ciAPI of **PageTransitionEnter**: 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci```ts 19e41f4b71Sopenharmony_ciPageTransitionEnter({type?: RouteType,duration?: number,curve?: Curve | string,delay?: number}) 20e41f4b71Sopenharmony_ci``` 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciAPI of **PageTransitionExit**: 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci```ts 26e41f4b71Sopenharmony_ciPageTransitionExit({type?: RouteType,duration?: number,curve?: Curve | string,delay?: number}) 27e41f4b71Sopenharmony_ci``` 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ciBoth **PageTransitionEnter** and **PageTransitionExit** contain the **slide**, **translate**, **scale**, and **opacity** attributes. For **PageTransitionEnter**, these attributes indicate the start values for page entrance. For **PageTransitionExit**, these attributes indicate the end values for page exit. In this sense, configuration of page transition is similar to that of component transition. **PageTransitionEnter** provides the **onEnter** callback, and **PageTransitionExit** provides the **onExit** callback. 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ciIn the preceding APIs, the **type** parameter indicates the route type used in page navigation. Each page transition involves exit of one page and entrance of the other. If you switch from page A to page B through the **router.pushUrl** operation, page A exits, with the exit animation applied; and page B enters, with the entrance animation applied. If you switch from page B back to page A through the **router.back** operation, page B exits, , with the exit animation applied; and page A enters, with the entrance animation applied. That is, **PageTransitionEnter** of a page may be an entrance animation of a new page (pushed to the stack) or of an existing page (popped from the stack). To distinguish these two types of entrance animations, the **type** parameter is provided. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci## Setting type to RouteType.None 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ciWhen **type** is set to **RouteType.None** (default value), the page transition animations work for both the push and pop operations in the page stack. 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci```ts 42e41f4b71Sopenharmony_ci// page A 43e41f4b71Sopenharmony_cipageTransition() { 44e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the left, with the duration of 1200 ms. The settings take effect no matter whether the push or pop operation is performed on the page stack. 45e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.None, duration: 1200 }) 46e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 47e41f4b71Sopenharmony_ci // Configure the page exit animation to sliding out from the left, with the duration of 1000 ms. The settings take effect no matter whether the push or pop operation is performed on the page stack. 48e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.None, duration: 1000 }) 49e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 50e41f4b71Sopenharmony_ci} 51e41f4b71Sopenharmony_ci``` 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci```ts 54e41f4b71Sopenharmony_ci// page B 55e41f4b71Sopenharmony_cipageTransition() { 56e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the right, with the duration of 1000 ms. The settings take effect no matter whether the push or pop operation is performed on the page stack. 57e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.None, duration: 1000 }) 58e41f4b71Sopenharmony_ci .slide(SlideEffect.Right) 59e41f4b71Sopenharmony_ci // Configure the page exit animation to sliding out from the right, with the duration of 1200 ms. The settings take effect no matter whether the push or pop operation is performed on the page stack. 60e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.None, duration: 1200 }) 61e41f4b71Sopenharmony_ci .slide(SlideEffect.Right) 62e41f4b71Sopenharmony_ci} 63e41f4b71Sopenharmony_ci``` 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ciAssume that the page stack is in the multi-instance mode, that is, duplicate pages are allowed in the page stack. There may be four scenarios. The following table lists the page transition effects. 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci| Route Operation | Page A Transition Effect | Page B Transition Effect | 70e41f4b71Sopenharmony_ci| ---------------------------- | ---------------------------------- | ---------------------------------- | 71e41f4b71Sopenharmony_ci| **router.pushUrl** – redirection from page A to new page B| The page exits. The animation defined by **PageTransitionExit** is applied. In the example, the page slides out from the left of the screen. | The page enters. The animation defined by **PageTransitionEnter** is applied. In the example, the page slides in from the right of the screen.| 72e41f4b71Sopenharmony_ci| **router.back** – redirection from page B back to page A | The page enters. The animation defined by **PageTransitionEnter** is applied. In the example, the page slides in from the left of the screen.| The page exits. The animation defined by **PageTransitionExit** is applied. In the example, the page slides out from the right of the screen. | 73e41f4b71Sopenharmony_ci| **router.pushUrl** – redirection from page B to new page A| The page enters. The animation defined by **PageTransitionEnter** is applied. In the example, the page slides in from the left of the screen.| The page exits. The animation defined by **PageTransitionExit** is applied. In the example, the page slides out from the right of the screen. | 74e41f4b71Sopenharmony_ci| **router.back** – redirection from page A back to page B | The page exits. The animation defined by **PageTransitionExit** is applied. In the example, the page slides out from the left of the screen. | The page enters. The animation defined by **PageTransitionEnter** is applied. In the example, the page slides in from the right of the screen.| 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ciIf you want the page accessed by **router.pushUrl** to always slide in from the right and the page exited by **router.back** to always slide out from the right, the third and fourth cases in the preceding table do not meet the requirements. In this case, you need to define four page transition effects. 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci## Setting type to RouteType.Push or RouteType.Pop 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ciWhen **type** is set to **RouteType.Push**, the page transition animations work for only both the push operations in the page stack. When **type** is set to **RouteType.Pop**, the page transition animations work for only both the pop operations in the page stack. 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci```ts 86e41f4b71Sopenharmony_ci// page A 87e41f4b71Sopenharmony_cipageTransition() { 88e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the right, with the duration of 1200 ms. The settings take effect only when the push operation is performed on the page stack. 89e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.Push, duration: 1200 }) 90e41f4b71Sopenharmony_ci .slide(SlideEffect.Right) 91e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the left, with the duration of 1200 ms. The settings take effect only when the pop operation is performed on the page stack. 92e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.Pop, duration: 1200 }) 93e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 94e41f4b71Sopenharmony_ci // Configure the page exit animation to sliding out from the left, with the duration of 1000 ms. The settings take effect only when the push operation is performed on the page stack. 95e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.Push, duration: 1000 }) 96e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 97e41f4b71Sopenharmony_ci // Configure the page exit animation to sliding out from the right, with the duration of 1000 ms. The settings take effect only when the pop operation is performed on the page stack. 98e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.Pop, duration: 1000 }) 99e41f4b71Sopenharmony_ci .slide(SlideEffect.Right) 100e41f4b71Sopenharmony_ci} 101e41f4b71Sopenharmony_ci``` 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci```ts 104e41f4b71Sopenharmony_ci// page B 105e41f4b71Sopenharmony_cipageTransition() { 106e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the right, with the duration of 1000 ms. The settings take effect only when the push operation is performed on the page stack. 107e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.Push, duration: 1000 }) 108e41f4b71Sopenharmony_ci .slide(SlideEffect.Right) 109e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the left, with the duration of 1000 ms. The settings take effect only when the pop operation is performed on the page stack. 110e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.Pop, duration: 1000 }) 111e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 112e41f4b71Sopenharmony_ci // Configure the page exit animation to sliding out from the left, with the duration of 1200 ms. The settings take effect only when the push operation is performed on the page stack. 113e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.Push, duration: 1200 }) 114e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 115e41f4b71Sopenharmony_ci // Configure the page exit animation to sliding out from the right, with the duration of 1200 ms. The settings take effect only when the pop operation is performed on the page stack. 116e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.Pop, duration: 1200 }) 117e41f4b71Sopenharmony_ci .slide(SlideEffect.Right) 118e41f4b71Sopenharmony_ci} 119e41f4b71Sopenharmony_ci``` 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ciThe preceding code defines page transition effects for all possibles scenarios. Assume that the page stack is in the multi-instance mode, that is, duplicate pages are allowed in the page stack. There may be four scenarios. The following table lists the page transition effects. 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci| Route Operation | Page A Transition Effect | Page B Transition Effect | 126e41f4b71Sopenharmony_ci| ---------------------------- | ---------------------------------------- | ---------------------------------------- | 127e41f4b71Sopenharmony_ci| **router.pushUrl** – redirection from page A to new page B.| The page exits. The transition style of **PageTransitionExit** whose **type** is **RouteType.Push** takes effect. The page slides out from the left of the screen.| The page enters. The transition style of **PageTransitionEnter** whose **type** is **RouteType.Push** takes effect. The page slides in from the right of the screen.| 128e41f4b71Sopenharmony_ci| **router.back** – redirection from page B back to page A. | The page enters. The transition style of **PageTransitionEnter** whose **type** is **RouteType.Pop** takes effect. The page slides in from the left of the screen.| The page exits. The transition style of **PageTransitionExit** whose **type** is **RouteType.Pop** takes effect. The page slides out from the right of the screen.| 129e41f4b71Sopenharmony_ci| **router.pushUrl** – redirection from page B to new page A.| The page enters. The transition style of **PageTransitionEnter** whose **type** is **RouteType.Push** takes effect. The page slides in from the right of the screen.| The page exits. The transition style of **PageTransitionExit** whose **type** is **RouteType.Push** takes effect. The page slides out from the left of the screen.| 130e41f4b71Sopenharmony_ci| **router.back** – redirection from page A back to page B. | The page exits. The transition style of **PageTransitionExit** whose **type** is **RouteType.Pop** takes effect. The page slides out from the right of the screen.| The page enters. The transition style of **PageTransitionEnter** whose **type** is **RouteType.Pop** takes effect. The page slides in from the left of the screen.| 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci>**NOTE** 134e41f4b71Sopenharmony_ci> 135e41f4b71Sopenharmony_ci> 1. The transition style of each page can be independently configured. However, as each transition involves two pages, take into account the smoothness between page transitions, for example, the transition duration. 136e41f4b71Sopenharmony_ci> 137e41f4b71Sopenharmony_ci> 2. If no page transition style is defined, a page uses the default page transition style. 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci## Disabling Page Transition 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ci```ts 144e41f4b71Sopenharmony_cipageTransition() { 145e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.None, duration: 0 }) 146e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.None, duration: 0 }) 147e41f4b71Sopenharmony_ci} 148e41f4b71Sopenharmony_ci``` 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ciYou can disable the transition animation of a page by setting the page transition duration to 0. 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci## Example 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ciIn the following example, page transition animations are defined using [router.pushUrl](../reference/apis-arkui/js-apis-router.md#routerpushurl9) for all the page transition scenarios. 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci```ts 159e41f4b71Sopenharmony_ci// PageTransitionSrc1 160e41f4b71Sopenharmony_ciimport { router } from "@kit.ArkUI"; 161e41f4b71Sopenharmony_ci@Entry 162e41f4b71Sopenharmony_ci@Component 163e41f4b71Sopenharmony_cistruct PageTransitionSrc1 { 164e41f4b71Sopenharmony_ci build() { 165e41f4b71Sopenharmony_ci Column() { 166e41f4b71Sopenharmony_ci Image($r('app.media.mountain')) 167e41f4b71Sopenharmony_ci .width('90%') 168e41f4b71Sopenharmony_ci .height('80%') 169e41f4b71Sopenharmony_ci .objectFit(ImageFit.Fill) 170e41f4b71Sopenharmony_ci .syncLoad(true) // Load the image synchronously so that the image has been loaded when the page is displayed. 171e41f4b71Sopenharmony_ci .margin(30) 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ci Row({ space: 10 }) { 174e41f4b71Sopenharmony_ci Button("pushUrl") 175e41f4b71Sopenharmony_ci .onClick(() => { 176e41f4b71Sopenharmony_ci // Navigate to the next page, which is a push operation. 177e41f4b71Sopenharmony_ci router.pushUrl({ url: 'pages/myTest/pageTransitionDst1' }); 178e41f4b71Sopenharmony_ci }) 179e41f4b71Sopenharmony_ci Button("back") 180e41f4b71Sopenharmony_ci .onClick(() => { 181e41f4b71Sopenharmony_ci // Return to the previous page, which is equivalent to the pop operation. 182e41f4b71Sopenharmony_ci router.back(); 183e41f4b71Sopenharmony_ci }) 184e41f4b71Sopenharmony_ci }.justifyContent(FlexAlign.Center) 185e41f4b71Sopenharmony_ci } 186e41f4b71Sopenharmony_ci .width("100%").height("100%") 187e41f4b71Sopenharmony_ci .alignItems(HorizontalAlign.Center) 188e41f4b71Sopenharmony_ci } 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ci pageTransition() { 191e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the right, with the duration of 1000 ms. The settings take effect only when the push operation is performed on the page stack. 192e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.Push, duration: 1000 }) 193e41f4b71Sopenharmony_ci .slide(SlideEffect.Right) 194e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the left, with the duration of 1000 ms. The settings take effect only when the pop operation is performed on the page stack. 195e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.Pop, duration: 1000 }) 196e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 197e41f4b71Sopenharmony_ci // Configure the page exit animation to sliding out from the left, with the duration of 1000 ms. The settings take effect only when the push operation is performed on the page stack. 198e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.Push, duration: 1000 }) 199e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 200e41f4b71Sopenharmony_ci // Configure the page exit animation to sliding out from the right, with the duration of 1000 ms. The settings take effect only when the pop operation is performed on the page stack. 201e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.Pop, duration: 1000 }) 202e41f4b71Sopenharmony_ci .slide(SlideEffect.Right) 203e41f4b71Sopenharmony_ci } 204e41f4b71Sopenharmony_ci} 205e41f4b71Sopenharmony_ci``` 206e41f4b71Sopenharmony_ci 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci```ts 211e41f4b71Sopenharmony_ci// PageTransitionDst1 212e41f4b71Sopenharmony_ciimport { router } from "@kit.ArkUI"; 213e41f4b71Sopenharmony_ci@Entry 214e41f4b71Sopenharmony_ci@Component 215e41f4b71Sopenharmony_cistruct PageTransitionDst1 { 216e41f4b71Sopenharmony_ci build() { 217e41f4b71Sopenharmony_ci Column() { 218e41f4b71Sopenharmony_ci Image($r('app.media.forest')) 219e41f4b71Sopenharmony_ci .width('90%') 220e41f4b71Sopenharmony_ci .height('80%') 221e41f4b71Sopenharmony_ci .objectFit(ImageFit.Fill) 222e41f4b71Sopenharmony_ci .syncLoad(true) // Load the image synchronously so that the image has been loaded when the page is displayed. 223e41f4b71Sopenharmony_ci .margin(30) 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci Row({ space: 10 }) { 226e41f4b71Sopenharmony_ci Button("pushUrl") 227e41f4b71Sopenharmony_ci .onClick(() => { 228e41f4b71Sopenharmony_ci // Navigate to the next page, which is a push operation. 229e41f4b71Sopenharmony_ci router.pushUrl({ url: 'pages/myTest/pageTransitionSrc1' }); 230e41f4b71Sopenharmony_ci }) 231e41f4b71Sopenharmony_ci Button("back") 232e41f4b71Sopenharmony_ci .onClick(() => { 233e41f4b71Sopenharmony_ci // Return to the previous page, which is equivalent to the pop operation. 234e41f4b71Sopenharmony_ci router.back(); 235e41f4b71Sopenharmony_ci }) 236e41f4b71Sopenharmony_ci }.justifyContent(FlexAlign.Center) 237e41f4b71Sopenharmony_ci } 238e41f4b71Sopenharmony_ci .width("100%").height("100%") 239e41f4b71Sopenharmony_ci .alignItems(HorizontalAlign.Center) 240e41f4b71Sopenharmony_ci } 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ci pageTransition() { 243e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the right, with the duration of 1000 ms. The settings take effect only when the push operation is performed on the page stack. 244e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.Push, duration: 1000 }) 245e41f4b71Sopenharmony_ci .slide(SlideEffect.Right) 246e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the left, with the duration of 1000 ms. The settings take effect only when the pop operation is performed on the page stack. 247e41f4b71Sopenharmony_ci PageTransitionEnter({ type: RouteType.Pop, duration: 1000 }) 248e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 249e41f4b71Sopenharmony_ci // Configure the page exit animation to sliding out from the left, with the duration of 1000 ms. The settings take effect only when the push operation is performed on the page stack. 250e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.Push, duration: 1000 }) 251e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 252e41f4b71Sopenharmony_ci // Configure the page exit animation to sliding out from the right, with the duration of 1000 ms. The settings take effect only when the pop operation is performed on the page stack. 253e41f4b71Sopenharmony_ci PageTransitionExit({ type: RouteType.Pop, duration: 1000 }) 254e41f4b71Sopenharmony_ci .slide(SlideEffect.Right) 255e41f4b71Sopenharmony_ci } 256e41f4b71Sopenharmony_ci} 257e41f4b71Sopenharmony_ci``` 258e41f4b71Sopenharmony_ci 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci 264e41f4b71Sopenharmony_ciIn the following example, **type** is set to **RouteType.None**. 265e41f4b71Sopenharmony_ci 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ci 268e41f4b71Sopenharmony_ci```ts 269e41f4b71Sopenharmony_ci// PageTransitionSrc2 270e41f4b71Sopenharmony_ciimport { router } from "@kit.ArkUI"; 271e41f4b71Sopenharmony_ci@Entry 272e41f4b71Sopenharmony_ci@Component 273e41f4b71Sopenharmony_cistruct PageTransitionSrc2 { 274e41f4b71Sopenharmony_ci build() { 275e41f4b71Sopenharmony_ci Column() { 276e41f4b71Sopenharmony_ci Image($r('app.media.mountain')) 277e41f4b71Sopenharmony_ci .width('90%') 278e41f4b71Sopenharmony_ci .height('80%') 279e41f4b71Sopenharmony_ci .objectFit(ImageFit.Fill) 280e41f4b71Sopenharmony_ci .syncLoad(true) // Load the image synchronously so that the image has been loaded when the page is displayed. 281e41f4b71Sopenharmony_ci .margin(30) 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_ci Row({ space: 10 }) { 284e41f4b71Sopenharmony_ci Button("pushUrl") 285e41f4b71Sopenharmony_ci .onClick(() => { 286e41f4b71Sopenharmony_ci // Navigate to the next page, which is a push operation. 287e41f4b71Sopenharmony_ci router.pushUrl({ url: 'pages/myTest/pageTransitionDst2' }); 288e41f4b71Sopenharmony_ci }) 289e41f4b71Sopenharmony_ci Button("back") 290e41f4b71Sopenharmony_ci .onClick(() => { 291e41f4b71Sopenharmony_ci // Return to the previous page, which is equivalent to the pop operation. 292e41f4b71Sopenharmony_ci router.back(); 293e41f4b71Sopenharmony_ci }) 294e41f4b71Sopenharmony_ci }.justifyContent(FlexAlign.Center) 295e41f4b71Sopenharmony_ci } 296e41f4b71Sopenharmony_ci .width("100%").height("100%") 297e41f4b71Sopenharmony_ci .alignItems(HorizontalAlign.Center) 298e41f4b71Sopenharmony_ci } 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ci pageTransition() { 301e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the left, with the duration of 1000 ms. The settings take effect no matter whether the push or pop operation is performed on the page stack. 302e41f4b71Sopenharmony_ci PageTransitionEnter({ duration: 1000 }) 303e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 304e41f4b71Sopenharmony_ci // Configure the page exit animation to translating by 100 vp along the x- and y-axes and changing the opacity to 0, with the duration of 1200 ms. The settings take effect no matter whether the push or pop operation is performed on the page stack. 305e41f4b71Sopenharmony_ci PageTransitionExit({ duration: 1200 }) 306e41f4b71Sopenharmony_ci .translate({ x: 100.0, y: 100.0 }) 307e41f4b71Sopenharmony_ci .opacity(0) 308e41f4b71Sopenharmony_ci } 309e41f4b71Sopenharmony_ci} 310e41f4b71Sopenharmony_ci``` 311e41f4b71Sopenharmony_ci 312e41f4b71Sopenharmony_ci 313e41f4b71Sopenharmony_ci 314e41f4b71Sopenharmony_ci```ts 315e41f4b71Sopenharmony_ci// PageTransitionDst2 316e41f4b71Sopenharmony_ciimport { router } from "@kit.ArkUI"; 317e41f4b71Sopenharmony_ci@Entry 318e41f4b71Sopenharmony_ci@Component 319e41f4b71Sopenharmony_cistruct PageTransitionDst2 { 320e41f4b71Sopenharmony_ci build() { 321e41f4b71Sopenharmony_ci Column() { 322e41f4b71Sopenharmony_ci Image($r('app.media.forest')) 323e41f4b71Sopenharmony_ci .width('90%') 324e41f4b71Sopenharmony_ci .height('80%') 325e41f4b71Sopenharmony_ci .objectFit(ImageFit.Fill) 326e41f4b71Sopenharmony_ci .syncLoad(true) // Load the image synchronously so that the image has been loaded when the page is displayed. 327e41f4b71Sopenharmony_ci .margin(30) 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci Row({ space: 10 }) { 330e41f4b71Sopenharmony_ci Button("pushUrl") 331e41f4b71Sopenharmony_ci .onClick(() => { 332e41f4b71Sopenharmony_ci // Navigate to the next page, which is a push operation. 333e41f4b71Sopenharmony_ci router.pushUrl({ url: 'pages/myTest/pageTransitionSrc2' }); 334e41f4b71Sopenharmony_ci }) 335e41f4b71Sopenharmony_ci Button("back") 336e41f4b71Sopenharmony_ci .onClick(() => { 337e41f4b71Sopenharmony_ci // Return to the previous page, which is equivalent to the pop operation. 338e41f4b71Sopenharmony_ci router.back(); 339e41f4b71Sopenharmony_ci }) 340e41f4b71Sopenharmony_ci }.justifyContent(FlexAlign.Center) 341e41f4b71Sopenharmony_ci } 342e41f4b71Sopenharmony_ci .width("100%").height("100%") 343e41f4b71Sopenharmony_ci .alignItems(HorizontalAlign.Center) 344e41f4b71Sopenharmony_ci } 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci pageTransition() { 347e41f4b71Sopenharmony_ci // Configure the page entrance animation to sliding in from the left, with the duration of 1200 ms. The settings take effect no matter whether the push or pop operation is performed on the page stack. 348e41f4b71Sopenharmony_ci PageTransitionEnter({ duration: 1200 }) 349e41f4b71Sopenharmony_ci .slide(SlideEffect.Left) 350e41f4b71Sopenharmony_ci // Configure the page exit animation to translating by 100 vp along the x- and y-axes and changing the opacity to 0, with the duration of 1000 ms. The settings take effect no matter whether the push or pop operation is performed on the page stack. 351e41f4b71Sopenharmony_ci PageTransitionExit({ duration: 1000 }) 352e41f4b71Sopenharmony_ci .translate({ x: 100.0, y: 100.0 }) 353e41f4b71Sopenharmony_ci .opacity(0) 354e41f4b71Sopenharmony_ci } 355e41f4b71Sopenharmony_ci} 356e41f4b71Sopenharmony_ci``` 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ci 359e41f4b71Sopenharmony_ci 360e41f4b71Sopenharmony_ci 361