1# Motion Path Animation 2 3The motion path animation is used to animate a component along a custom path. 4 5> **NOTE** 6> 7> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8 9 10## Attributes 11 12| Name| Type| Default Value| Description| 13| -------- | -------- | -------- | -------- | 14| motionPath | {<br>path: string,<br>from?: number,<br>to?: number,<br>rotatable?: boolean<br>}<br>**NOTE**<br>In a path, **start** and **end** can be used to replace the start point and end point. Example:<br>'Mstart.x start.y L50 50 Lend.x end.y Z'<br>For more information, see [Path Drawing](../../ui/ui-js-components-svg-path.md).| {<br>'',<br>0.0,<br>1.0,<br>false<br>} | Motion path of the component.<br>- **path**: motion path of the translation animation. The value is an SVG path string.<br>- **from**: start point of the motion path.<br>Default value: **0.0**<br>Value range: [0, 1]<br>A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.<br>- **to**: end point of the motion path.<br>Default value: **1.0**<br>Value range: [0, 1]<br>A value less than 0 evaluates to the value **0**. A value larger than 1 evaluates to the value **1**.<br>- **rotatable**: whether to rotate along the path. | 15 16 17## Example 18 19```ts 20// xxx.ets 21@Entry 22@Component 23struct MotionPathExample { 24 @State toggle: boolean = true 25 26 build() { 27 Column() { 28 Button('click me').margin(50) 29 // Execute the animation: Move from the start point to (300,200), then to (300,500), and finally to the end point. 30 .motionPath({ path: 'Mstart.x start.y L300 200 L300 500 Lend.x end.y', from: 0.0, to: 1.0, rotatable: true }) 31 .onClick(() => { 32 animateTo({ duration: 4000, curve: Curve.Linear }, () => { 33 this.toggle =! this.toggle // Use this.toggle to change the position of the component. 34 }) 35 }) 36 }.width('100%').height('100%').alignItems(this.toggle ? HorizontalAlign.Start : HorizontalAlign.Center) 37 } 38} 39``` 40 41 42