1e41f4b71Sopenharmony_ci# Requesting Frame Rates for Animations
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciDuring application development, you can use the optional parameter [ExpectedFrameRateRange](../reference/apis-arkui/arkui-ts/ts-explicit-animation.md#expectedframeraterange11) to set an expected frame rate range for a [property animation](../reference/apis-arkui/arkui-ts/ts-animatorproperty.md) or an [explicit animation](../reference/apis-arkui/arkui-ts/ts-explicit-animation.md).
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci## Requesting a Frame Rate for a Property Animation
6e41f4b71Sopenharmony_ciThe code snippet below defines a property animation for the **Text** component and sets the frame rate to 60.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci   ```ts
9e41f4b71Sopenharmony_ci    Text()
10e41f4b71Sopenharmony_ci     .animation({
11e41f4b71Sopenharmony_ci        duration: 1200,
12e41f4b71Sopenharmony_ci        iterations: 10,
13e41f4b71Sopenharmony_ci        expectedFrameRateRange: { // Set the frame rate range of the property animation.
14e41f4b71Sopenharmony_ci          expected: 60, // Set the expected frame rate of the animation to 60 Hz.
15e41f4b71Sopenharmony_ci          min: 0, // Set the frame rate range.
16e41f4b71Sopenharmony_ci          max: 120, // Set the frame rate range.
17e41f4b71Sopenharmony_ci        },
18e41f4b71Sopenharmony_ci     })
19e41f4b71Sopenharmony_ci   ```
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci## Requesting a Frame Rate for an Explicit Animation
22e41f4b71Sopenharmony_ciThe code snippet below defines an explicit animation for the **Button** component and sets the frame rate to 30.
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci   ```ts
25e41f4b71Sopenharmony_ci   Button()
26e41f4b71Sopenharmony_ci    .onClick(() => {
27e41f4b71Sopenharmony_ci      animateTo({
28e41f4b71Sopenharmony_ci        duration: 1200,
29e41f4b71Sopenharmony_ci        iterations: 10,
30e41f4b71Sopenharmony_ci        expectedFrameRateRange: { // Set the frame rate range of the explicit animation.
31e41f4b71Sopenharmony_ci          expected: 30, // Set the expected frame rate of the animation to 30 Hz.
32e41f4b71Sopenharmony_ci          min: 0, // Set the frame rate range.
33e41f4b71Sopenharmony_ci          max: 120, // Set the frame rate range.
34e41f4b71Sopenharmony_ci        },
35e41f4b71Sopenharmony_ci      }, () => {
36e41f4b71Sopenharmony_ci      })
37e41f4b71Sopenharmony_ci    })
38e41f4b71Sopenharmony_ci   ```
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci## Sample Code
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci```ts
44e41f4b71Sopenharmony_ci@Entry
45e41f4b71Sopenharmony_ci@Component
46e41f4b71Sopenharmony_cistruct AnimationToAnimationDemo {
47e41f4b71Sopenharmony_ci  @State isAnimation: boolean = false;
48e41f4b71Sopenharmony_ci  @State translateX1: number = -100;
49e41f4b71Sopenharmony_ci  @State translateX2: number = -100;
50e41f4b71Sopenharmony_ci  @State translateX3: number = -100;
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci  build() {
53e41f4b71Sopenharmony_ci    Column() {
54e41f4b71Sopenharmony_ci      Row() {
55e41f4b71Sopenharmony_ci        Text('30')
56e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
57e41f4b71Sopenharmony_ci          .fontSize(16)
58e41f4b71Sopenharmony_ci          .fontColor(Color.White)
59e41f4b71Sopenharmony_ci          .textAlign(TextAlign.Center)
60e41f4b71Sopenharmony_ci          .borderRadius(10)
61e41f4b71Sopenharmony_ci          .backgroundColor(0xF56C6C)
62e41f4b71Sopenharmony_ci          .width(80)
63e41f4b71Sopenharmony_ci          .height(80)
64e41f4b71Sopenharmony_ci          .translate({ x: this.translateX1 })
65e41f4b71Sopenharmony_ci      }
66e41f4b71Sopenharmony_ci      .height('20%')
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci      Row() {
69e41f4b71Sopenharmony_ci        Text('40')
70e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
71e41f4b71Sopenharmony_ci          .fontSize(16)
72e41f4b71Sopenharmony_ci          .fontColor(Color.White)
73e41f4b71Sopenharmony_ci          .textAlign(TextAlign.Center)
74e41f4b71Sopenharmony_ci          .borderRadius(10)
75e41f4b71Sopenharmony_ci          .backgroundColor(0x2E8B57)
76e41f4b71Sopenharmony_ci          .width(80)
77e41f4b71Sopenharmony_ci          .height(80)
78e41f4b71Sopenharmony_ci          .translate({ x: this.translateX2 })
79e41f4b71Sopenharmony_ci      }
80e41f4b71Sopenharmony_ci      .height('20%')
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci      Row() {
83e41f4b71Sopenharmony_ci        Text('60')
84e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
85e41f4b71Sopenharmony_ci          .fontSize(16)
86e41f4b71Sopenharmony_ci          .fontColor(Color.White)
87e41f4b71Sopenharmony_ci          .textAlign(TextAlign.Center)
88e41f4b71Sopenharmony_ci          .borderRadius(10)
89e41f4b71Sopenharmony_ci          .backgroundColor(0x008B8B)
90e41f4b71Sopenharmony_ci          .width(80)
91e41f4b71Sopenharmony_ci          .height(80)
92e41f4b71Sopenharmony_ci          .translate({ x: this.translateX3 })
93e41f4b71Sopenharmony_ci          .animation({
94e41f4b71Sopenharmony_ci            duration: 1200,
95e41f4b71Sopenharmony_ci            iterations: 10,
96e41f4b71Sopenharmony_ci            playMode: PlayMode.AlternateReverse,
97e41f4b71Sopenharmony_ci            expectedFrameRateRange: { // Set the frame rate range of the property animation.
98e41f4b71Sopenharmony_ci              expected: 60, // Set the expected frame rate of the animation to 60 Hz.
99e41f4b71Sopenharmony_ci              min: 0, // Set the frame rate range.
100e41f4b71Sopenharmony_ci              max: 120, // Set the frame rate range.
101e41f4b71Sopenharmony_ci            },
102e41f4b71Sopenharmony_ci          })
103e41f4b71Sopenharmony_ci      }
104e41f4b71Sopenharmony_ci      .height('20%')
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci      Row() {
107e41f4b71Sopenharmony_ci        Button('Start')
108e41f4b71Sopenharmony_ci          .id('PropertyAnimationStart')
109e41f4b71Sopenharmony_ci          .fontSize(14)
110e41f4b71Sopenharmony_ci          .fontWeight(500)
111e41f4b71Sopenharmony_ci          .margin({ bottom: 10, left: 5 })
112e41f4b71Sopenharmony_ci          .fontColor(Color.White)
113e41f4b71Sopenharmony_ci          .onClick(() => {
114e41f4b71Sopenharmony_ci            this.isAnimation = !this.isAnimation;
115e41f4b71Sopenharmony_ci            this.translateX3 = this.isAnimation ? 100 : -100;
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci            animateTo({
118e41f4b71Sopenharmony_ci              duration: 1200,
119e41f4b71Sopenharmony_ci              iterations: 10,
120e41f4b71Sopenharmony_ci              playMode: PlayMode.AlternateReverse,
121e41f4b71Sopenharmony_ci              expectedFrameRateRange: { // Set the frame rate range of the explicit animation.
122e41f4b71Sopenharmony_ci                expected: 30, // Set the expected frame rate of the animation to 30 Hz.
123e41f4b71Sopenharmony_ci                min: 0, // Set the frame rate range.
124e41f4b71Sopenharmony_ci                max: 120, // Set the frame rate range.
125e41f4b71Sopenharmony_ci              },
126e41f4b71Sopenharmony_ci            }, () => {
127e41f4b71Sopenharmony_ci              this.translateX1 = this.isAnimation ? 100 : -100;
128e41f4b71Sopenharmony_ci            })
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci            animateTo({
131e41f4b71Sopenharmony_ci              duration: 1200,
132e41f4b71Sopenharmony_ci              iterations: 10,
133e41f4b71Sopenharmony_ci              playMode: PlayMode.AlternateReverse,
134e41f4b71Sopenharmony_ci              expectedFrameRateRange: { // Set the frame rate range of the explicit animation.
135e41f4b71Sopenharmony_ci                expected: 40, // Set the expected frame rate of the animation to 40 Hz.
136e41f4b71Sopenharmony_ci                min: 0, // Set the frame rate range.
137e41f4b71Sopenharmony_ci                max: 120, // Set the frame rate range.
138e41f4b71Sopenharmony_ci              },
139e41f4b71Sopenharmony_ci            }, () => {
140e41f4b71Sopenharmony_ci              this.translateX2 = this.isAnimation ? 100 : -100;
141e41f4b71Sopenharmony_ci            })
142e41f4b71Sopenharmony_ci          })
143e41f4b71Sopenharmony_ci          .width('40%')
144e41f4b71Sopenharmony_ci          .height(40)
145e41f4b71Sopenharmony_ci          .shadow(ShadowStyle.OUTER_DEFAULT_LG)
146e41f4b71Sopenharmony_ci      }
147e41f4b71Sopenharmony_ci      .width('100%')
148e41f4b71Sopenharmony_ci      .justifyContent(FlexAlign.Center)
149e41f4b71Sopenharmony_ci      .shadow(ShadowStyle.OUTER_DEFAULT_SM)
150e41f4b71Sopenharmony_ci      .alignItems(VerticalAlign.Bottom)
151e41f4b71Sopenharmony_ci      .layoutWeight(1)
152e41f4b71Sopenharmony_ci    }
153e41f4b71Sopenharmony_ci    .width('100%')
154e41f4b71Sopenharmony_ci    .justifyContent(FlexAlign.Center)
155e41f4b71Sopenharmony_ci    .shadow(ShadowStyle.OUTER_DEFAULT_SM)
156e41f4b71Sopenharmony_ci    .layoutWeight(1)
157e41f4b71Sopenharmony_ci  }
158e41f4b71Sopenharmony_ci}
159e41f4b71Sopenharmony_ci```
160